hive 쿼리 사용시 필드의 이름에 특수 문자가 포함될 수 있다.

이럴 때는 regexp_replace를 사용해 필드 문자열을 변경해야 한다. 



SELECT  get_json_object(regexp_replace(data, 'error.url', 'url'), '$.url'), data

FROM google_log_src

WHERE dt = '20180426'  and hr='10'  limit 10;




참조


https://jprakashblog.wordpress.com/2015/08/11/hive-get_json_object-having-special-characters/






Posted by '김용환'
,



클라우드 아키텍처 그림 그리는 툴


https://cloudcraft.co/app



1탭은 Design으로 그림을 그린다.


공유기능은 링크와 이미지만 있다. (visio처럼 xml로 나오지는 않는다.)


<링크>

https://cloudcraft.co/view/4d5731b7-7e14-43e2-b8e5-5b329a2bd6c3?key=3m40jn0enpfd2t90


<이미지>

https://cloudcraft.co/api/blueprint/4d5731b7-7e14-43e2-b8e5-5b329a2bd6c3/png?grid=true&transparent=false&width=1280&height=720






3탭의 예산 정보도 볼 수 있다.






2탭은 Live인데, 실제 그림 그리는대로 아마존 설계를 한다.


Welcome to Cloudcraft Live

Live mode allows you to link your real AWS infrastructure with your diagrams.


이 부분이 cloudcraft 회사가 창출하는 부분이다.




Posted by '김용환'
,



docker 파일에서 java docker repository를 사용하려 할 때 다음을 참조할 수 있다. 


https://github.com/docker-library/repo-info/tree/master/repos/java/remote




예를 들어 docker 파일에 아래와 같이 사용한다면.


FROM java:openjdk-8-jdk-alpine


바로 아래 url의 docker 이미지를 사용하게 된다.


https://github.com/docker-library/repo-info/blob/master/repos/java/remote/openjdk-8-jdk-alpine.md



openjdk 8 111 버전을 사용하는 버전이다.. 


Posted by '김용환'
,



일래스틱서치(elasticsearch) 6에서 템플릿 목록 보기


$ curl -s "http://es-server:9200/_cat/templates?v&s=order:desc,template"


name                                         template                                order version

slowlog                                      *                                                    0

template_name                            google_api-*                              0



특정 템플릿을 살펴보기


$ curl -s http://es-server:9200/_template/템플릿_이름 | python -mjson.tool


자세한 정보 나옴.




특정 템플릿 저장하기


$ curl -XPUT -H "Content-type:application/json" http://es-server:9200/_template/템플릿_이름 -d @파일이름



Posted by '김용환'
,





mesos 1.3.1 에서 mesos-slave를 재시작한 후 상태 로그를 확인하려면 다음과 같다. 


curl 'http://${mesos-slave IP}:5051/slave(1)/state'

...

"attributes": {

  "ip": "${mesos-slave IP}",

  "os": "Ubuntu",

  "os-version": 16

},

...




/etc/default/mesos-slave 설정을 수정할 때는 조심해야 한다. 



export MESOS_ATTRIBUTES="ip:1.1.1.1;os:Ubuntu;os-version:16;server-type:user"라는 기본 값이 있을 때..


key:value라는 값을 추가하니 동작한다. key=value하면 mesos-slave 데몬이 뜨지 않는다.  위의 상태 체크 URL를 호출해본다. 

아래와 같이 수정한다.


export MESOS_ATTRIBUTES="ip:1.1.1.1;os:Ubuntu;os-version:16;server-type:user;key:value" 




* 주의할 점.


1. 설정할 때 key=value가 아니라 key:value이다. (콤마)


2. /etc/default/mesos-slave의 property를 수정할 때는 


MESOS_WORK_DIR를 지정한 디렉토리의 모든 파일을 지우고(sudo rm -rf 메소스_작업_DIR/*) 재시작해야 한다. 

(예, export MESOS_WORK_DIR=/var/mesos)



만약 MESOS_WORK_DIR 디렉토리를 지우지 않고 재시작하면 아래와 같은 에러가 발생한다.


$ sudo service  mesos-slave status

● mesos-slave.service - Mesos Slave

   Loaded: loaded (/lib/systemd/system/mesos-slave.service; enabled; vendor preset: enabled)

   Active: activating (auto-restart) (Result: exit-code) since Fri 2018-12-13 19:38:33 KST; 7s ago

  Process: 3343 ExecStart=/usr/bin/mesos-init-wrapper slave (code=exited, status=1/FAILURE)

 Main PID: 3343 (code=exited, status=1/FAILURE)


Apr 13 19:38:33 media-site-node51 systemd[1]: mesos-slave.service: Unit entered failed state.

Apr 13 19:38:33 media-site-node51 systemd[1]: mesos-slave.service: Failed with result 'exit-code'.



Posted by '김용환'
,


레드햇에서 클라우드 네이티브 컨테이어 디자인 관련 문서(쿠버네티스)를 공유했다. 






http://blog.kubernetes.io/2018/03/principles-of-container-app-design.html?m=1




https://www.redhat.com/cms/managed-files/cl-cloud-native-container-design-whitepaper-f8808kc-201710-v3-en.pdf


PRINCIPLES OF

SOFTWARE DESIGN:

•Keep it simple, stupid (KISS)

•Don’t repeat yourself (DRY)

•You aren’t gonna need it

(YAGNI)

•Separation of concerns (SoC)

RED HAT APPROACH

TO CLOUD-NATIVE

CONTAINERS:

•Single concern principle (SCP)

•High observability

principle (HOP)

•Life-cycle conformance

principle (LCP)

•Image immutability

principle (IIP)

•Process disposability

principle (PDP)

•Self-containment

principle (S-CP)

•Runtime confinement

principle (RCP)



레드햇 아키텍트가 infoq에 쓴 글이다.


https://www.infoq.com/articles/kubernetes-effect



Posted by '김용환'
,


오픈 스택의 overcommit 정보



https://docs.openstack.org/arch-design/design-compute/design-compute-overcommit.html




오픈 스택의 가상화 서버의 overcommit 기본 값은 다음과 같이 되어 있다.  가상 서버를 사용할 때 효율을 위해서 비율이 크다.


  • CPU allocation ratio: 16:1
  • RAM allocation ratio: 1.5:1



CPU allocation ratio가 16:1이라는 의미는 스케쥴러가 물리 코어 하나 당 16개의 가상 코어를 쓸 수 있도록 할당하겠다는 의미이다. 물리 서버가 12코어가 있다면.. 스케쥴러는 192개의 가상 코어를 사용할 수 있다. 인스턴스당 4 가상 코어를 쓰겠다고 하면.. 물리 서버의 192개중 48 인스턴스를 제공한다는 의미이다.


오픈 스택 문서를 보면 설명이 잘 나와 있다. 


OR
CPU overcommit ratio (virtual cores per physical core)
PC
Number of physical cores
VC
Number of virtual cores per instance

인스턴스 개수 = (OR*PC)/VC





https://inter6.github.io/2016/04/22/nova-overcommit/ 이 분의 글이 좋아서 발췌한다.



  • (Instance Count) = (Overcommit Ratio) * (Physical Cores) / (vCores per Instance)
  • (Overcommit Ratio) = (Instance Count) / (Physical Cores) * (vCores per Instance)



만약 인텔의 Hyper-Thread 기능을 사용할 경우, Mirantis에서는 총 코어 개수를 물리 코어 x 1.3 으로 계산할 것을 가이드한다.

다음 환경에서 오버커밋 비율로 생성해낼 수 있는 인스턴스 개수는 다음과 같다.

  • 인텔 E5-2640 v3 2.6Ghz 8Core x 2way
  • Hyper-Thread 활성화
  • 인스턴스당 평균 4개의 코어를 사용
Overcommit RatioInstance CountPhysical CoresvCores per Instance
15.220.84
210.420.84
420.820.84
841.620.84
1683.220.84



Posted by '김용환'
,

스프링 보안 이슈(https://spring.io/blog/2018/04/09/cve-2018-1275-address-partial-fix-for-cve-2018-1270)가 발생했다.


Spring Framework, versions 5.0.x prior to 5.0.5 and versions 4.3.x prior to 4.3.16, and older unsupported versions allow applications to expose STOMP over WebSocket endpoints with a simple, in-memory STOMP broker through the spring-messaging module. A malicious user (or attacker) can craft a message to the broker that can lead to a remote code execution attack.


https://spring.io/blog/2018/04/05/multiple-cve-reports-published-for-the-spring-framework




spring 2.0.1과 spring 1.5.12를 사용하길 권고한다고 떴다.


https://spring.io/blog/2018/04/05/spring-boot-2-0-1-available-now


https://spring.io/blog/2018/04/10/spring-boot-1-5-12-available-now



요약하면.



Spring Framework 5.0.x ->Spring Framework 5.0.5 로 업그레이드

Spring Framework 4.3.x -> Spring Framework 4.3.16 로 업그레이드


Spring Boot 2.0.0 -> Spring Boot 2.0.1로 업그레이드

Spring Boot 1.x.0 -> Spring Boot 1.5.12로 업그레이드



Posted by '김용환'
,


Dockerfile에서  USER를 nobody로 설정해서. docker container를 띄워서 톰캣이 재시작되지 않는 버그를 발견했다.


centos, mac에서는 잘 동작하는데, ubuntu에서만 동작하지 못했다.


Permission denied.. 분명 권한이 있는데로 파일 생성을 어느 path에서는 할 수 있고, 어느 path에서는 할 수 없었다.



nobody@08678a6be7c9:/usr/local/tomcat$ ls -al
total 120
drwxr-sr-x 28 nobody nogroup  4096 Apr  9 15:32 .
drwxrwsr-x 23 root   staff    4096 Apr  9 15:32 ..
-rw-r-----  1 nobody nogroup 57092 Sep 28  2017 LICENSE
-rw-r-----  1 nobody nogroup  1723 Sep 28  2017 NOTICE
-rw-r-----  1 nobody nogroup  7064 Sep 28  2017 RELEASE-NOTES
-rw-r-----  1 nobody nogroup 15946 Sep 28  2017 RUNNING.txt
drwxr-x---  2 nobody nogroup  4096 Nov  8 19:45 bin
drwx--S---  2 nobody nogroup  4096 Apr  9 15:30 conf
drwxr-x---  2 nobody nogroup  4096 Nov  8 19:45 lib
drwxr-x---  2 nobody nogroup  4096 Sep 28  2017 logs
drwxr-x---  2 nobody nogroup  4096 Nov  8 19:45 temp
drwxr-x---  9 nobody nogroup  4096 Apr  9 15:32 webapps
drwxr-x---  2 nobody nogroup  4096 Sep 28  2017 work

nobody@08678a6be7c9:/usr/local/tomcat$ touch a
nobody@08678a6be7c9:/usr/local/tomcat$ ls a
-rw-r--r--  1 nobody nogroup     0 Apr  9 16:51 a


nobody@08678a6be7c9:/usr/local/tomcat/logs$ touch a
touch: cannot touch ‘a’: Permission denied


docker info를 통해 driver를 확인했다. 

mac은 overlay2를 사용하고 있고. centos는 overlay, ubuntu는 aufs를 사용하고 있었다.


aufs 정보는 다음과 같으며 https://docs.docker.com/storage/storagedriver/aufs-driver/..


docker 공식 문서에서는 더 이상 aufs를 사용하지 않고 overlay를 사용하라고 되어 있다.

https://docs.docker.com/storage/storagedriver/overlayfs-driver/





mesos, docker 장비에서 docker 파일 드라이버를 aufs로 overlay로 변경했다. 



로컬에 저장된 기존 도커 container 모두 중단 및 docker image 삭제한다.


$ docker rm $(docker ps -qa)

$ docker images

$ docker rmi ...




시스템 설정을 변경한다.



$ sudo -i

 

$ CONFIGURATION_FILE=$(systemctl show --property=FragmentPath docker | cut -f2 -d=)

#/etc/systemd/system/docker.service


$ cp $CONFIGURATION_FILE /etc/systemd/system/docker.service

 

$ perl -pi -e 's/^(ExecStart=.+)$/$1 -s overlay/' /etc/systemd/system/docker.service



$ cat > /etc/docker/daemon.json

{

    "storage-driver": "overlay"

}


$ service mesos-slave restart #메소스 사용중이라면.. 반드시.

$ service docker restart 



그리고.  $ docker info를 실행해 docker 기본 filer driver가 overlay인지 확인한다.

docker container를 실행한 후, docker insepect $container_id로 확인해서. overlay인지 확인한다.

정상적으로 잘 동작하면 ok










'Cloud' 카테고리의 다른 글

java docker image 확인하기  (0) 2018.04.19
[openstack] 오버 커밋(overcommit) 공부  (0) 2018.04.11
fluentd 정규식 확인하기  (0) 2018.04.10
[fluentd] format json  (0) 2018.04.10
[openstack] keystone 인증(auth)만 해보기  (0) 2018.02.07
Posted by '김용환'
,


fluentd에서 가장 까다로운 것이 로그를 정규표현식으로 분석하는 것이다.

잘못하면 로그가 drop될 수 있기 때문에.. 신중하게 써야 하는데.


헤로쿠의 다음 url에서 fluent의 정규 표현식을 테스트해볼 수 있다. 


http://fluentular.herokuapp.com/




예를 들어 다음 로그를


"192.168.6.118 - - [25/May/2014:23:44:21 +0000]  GET /images/templates/main/favicon_16_24_32.ico HTTP/1.1 \"200\" 1811 \"-\" \"test-domain.com\" test-domain.com \"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36\" \"-\" upstream_response_time 0.028 upstream_addr 192.168.6.7:8017 msec 1401061461.752 request_time 0.028"



다음과 같은 regex로 파싱할 수 있다. 


^(?<remote_addr>[^ ]*) - (?<remote_user>[^ ]*) \[(?<time>[^\]]*)\]\s+(?<request_type>[^ ]*) (?<request_url>[^ ]*) (?<request_http_protocol>[^ ]*) "(?<status>[^"]*)" (?<body_bytes_sent>[^ ]*) "(?<http_referer>[^"]*)" "(?<http_host>[^"]*)" (?<host>[^ ]*) "(?<http_user_agent>[^"]*)" "(?<http_x_forwarded_for>[^"]*)" upstream_response_time (?<upstream_response_time>[^ ]*) upstream_addr (?<upstream_addr>[^ ]*) msec (?<msec request_time>[^ ]*) request_time (?<request_time>[^ ]*)



url은 get으로 볼 수 있다.


http://fluentular.herokuapp.com/parse?regexp=%5E%28%3F%3Cremote_addr%3E%5B%5E+%5D*%29+-+%28%3F%3Cremote_user%3E%5B%5E+%5D*%29+%5C%5B%28%3F%3Ctime%3E%5B%5E%5C%5D%5D*%29%5C%5D%5Cs%2B%28%3F%3Crequest_type%3E%5B%5E+%5D*%29+%28%3F%3Crequest_url%3E%5B%5E+%5D*%29+%28%3F%3Crequest_http_protocol%3E%5B%5E+%5D*%29+%22%28%3F%3Cstatus%3E%5B%5E%22%5D*%29%22+%28%3F%3Cbody_bytes_sent%3E%5B%5E+%5D*%29+%22%28%3F%3Chttp_referer%3E%5B%5E%22%5D*%29%22+%22%28%3F%3Chttp_host%3E%5B%5E%22%5D*%29%22+%28%3F%3Chost%3E%5B%5E+%5D*%29+%22%28%3F%3Chttp_user_agent%3E%5B%5E%22%5D*%29%22+%22%28%3F%3Chttp_x_forwarded_for%3E%5B%5E%22%5D*%29%22+upstream_response_time+%28%3F%3Cupstream_response_time%3E%5B%5E+%5D*%29+upstream_addr+%28%3F%3Cupstream_addr%3E%5B%5E+%5D*%29+msec+%28%3F%3Cmsec+request_time%3E%5B%5E+%5D*%29+request_time+%28%3F%3Crequest_time%3E%5B%5E+%5D*%29&input=%22192.168.6.118+-+-+%5B25%2FMay%2F2014%3A23%3A44%3A21+%2B0000%5D++GET+%2Fimages%2Ftemplates%2Fmain%2Ffavicon_16_24_32.ico+HTTP%2F1.1+%5C%22200%5C%22+1811+%5C%22-%5C%22+%5C%22test-domain.com%5C%22+test-domain.com+%5C%22Mozilla%2F5.0+%28Windows+NT+6.3%3B+WOW64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F35.0.1916.114+Safari%2F537.36%5C%22+%5C%22-%5C%22+upstream_response_time+0.028+upstream_addr+192.168.6.7%3A8017+msec+1401061461.752+request_time+0.028%22&time_format=






<source> 
  type tail 
  path /var/log/foo/bar.log 
  pos_file /var/log/td-agent/foo-bar.log.pos 
  tag foo.bar 
  format /^(?<remote_addr>[^ ]*) - (?<remote_user>[^ ]*) \[(?<time>[^\]]*)\]\s+(?<request_type>[^ ]*) (?<request_url>[^ ]*) (?<request_http_protocol>[^ ]*) "(?<status>[^"]*)" (?<body_bytes_sent>[^ ]*) "(?<http_referer>[^"]*)" "(?<http_host>[^"]*)" (?<host>[^ ]*) "(?<http_user_agent>[^"]*)" "(?<http_x_forwarded_for>[^"]*)" upstream_response_time (?<upstream_response_time>[^ ]*) upstream_addr (?<upstream_addr>[^ ]*) msec (?<msec request_time>[^ ]*) request_time (?<request_time>[^ ]*)/ 
</source>



Posted by '김용환'
,