오픈 스택의 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 '김용환'
,

[fluentd] format json

Cloud 2018. 4. 10. 18:20


아파치나 nginx로그를 fluentd로 전달하고 싶을 때 regex를 사용하는 것보다 format json을 사용하는 것이 좋다.


https://docs.fluentd.org/v0.12/articles/recipe-json-to-elasticsearch



<source>
  @type tail
  path /var/log/httpd-access.log #...or where you placed your Apache access log
  pos_file /var/log/td-agent/httpd-access.log.pos # This is where you record file position
  tag foobar.json #fluentd tag!
  format json # one JSON per line
  time_key time_field # optional; default = time
</source>


Posted by '김용환'
,


마라톤 lb에서 포트별 설정(첫 번째, 두 번째... 등등)을 할 수 있다. 


https://github.com/mesosphere/marathon-lb/blob/master/Longhelp.md


Templates

The following is a list of the available HAProxy templates. Some templates are global-only (such as HAPROXY_HEAD), but most may be overridden on a per service port basis using the HAPROXY_{n}_... syntax.





Labels

HAPROXY_0_MODE=http

HAPROXY_0_VHOST=plus.google.com

HAPROXY_0_SSL_CERT=/etc/ssl/marathon/250.pem



Posted by '김용환'
,



지도를 통한 미세먼지 

https://earth.nullschool.net/#current/chem/surface/level/overlay=cosc/orthographic=-234.88,34.11,1109







일본텐키

http://www.tenki.jp/particulate_matter/ (pc)

http://www.tenki.jp/lite/particulate_matter/  (모바일)






Posted by '김용환'
,


마라톤(marathon)에서 자원 (메모리)가 없으면 다음과 가은 에러가 발생한다. (비슷하게 다른 자원도 해결할 수 있다)


눈으로 볼 때는 메모리 자원 여유는 있지만.. 


앱을 재시작하면서 순간적으로 용량이 부족할 수 있기 때문에, 항상 기존 앱 + 새로 시작할 앱 사이에 2배 공간의 여유가 순간적으로 있을 수 있으니.. 적당하게 공간을 할애하는 것이 좋다. 


 



INFO Offer [c6424609-c06c-463b-91bb-97962d915e56-O374]. Considering resources with roles {googledev, *} without resident reservation labels. Not all basic resources satisfied: cpus SATISFIED (0.1 <= 0.1), mem NOT SATISFIED (256.0 > 176.0) (mesosphere.mesos.ResourceMatcher$:marathon-akka.actor.default-dispatcher-2)



INFO Offer [c6424609-c06c-463b-91bb-97962d915e56-O374]. Insufficient resources for [/plus-stage] (need cpus=0.1, mem=256.0, disk=0.0, gpus=0, ports=(), available in offer: [id { value: "c6424609-c06c-463b-91bb-97962d915e56-O374" } framework_id { value: "3549a1e4-9a61-4bb1-9a0a-8fc66d4e76f4-0000" } slave_id { value: "c6424609-c06c-463b-91bb-97962d915e56-S1" } hostname: "11.11.11.11" resources { name: "cpus" type: SCALAR scalar { value: 7.4 } role: "*" } resources { name: "mem" type: SCALAR scalar { value: 176.0 } role: "*" } resources { name: "disk" type: SCALAR scalar { value: 45240.0 } role: "*" } resources { name: "ports" type: RANGES ranges { range { begin: 31000 end: 31021 } range { begin: 31023 end: 31075 } range { begin: 31077 end: 31136 } range { begin: 31138 end: 31345 } range { begin: 31347 end: 31560 } range { begin: 31562 end: 31856 } range { begin: 31858 end: 32000 } } role: "*" } url { scheme: "http" address { hostname: "10.197.1.63" ip: "10.197.1.63" port: 5051 } path: "/slave(1)" }] (mesosphere.mesos.TaskBuilder$:marathon-akka.actor.default-dispatcher-2)




INFO Finished processing c6424609-c06c-463b-91bb-97962d915e56-O374 from 10.197.1.63. Matched 0 ops after 1 passes. cpus(*) 7.4; mem(*) 176.0; disk(*) 45240.0; ports(*) 31000->31021,31023->31075,31077->31136,31138->31345,31347->31560,31562->31856,31858->32000 left. (mesosphere.marathon.core.matcher.manager.impl.OfferMatcherManagerActor:marathon-akka.actor.default-dispatcher-25)





그러나... 마라톤에서는 계속 Deploying 으로 뜨고 자원도 좀 있었긴 했다...

mesos slave간에 통신으로 mesos에서 저런 에러를 내보낼 수 있다.. 마라톤 하위 버전(1.0.1이었음)이라면 의심해도 좋다.


mesos 슬레이브 에러 로그를 확인하니.. 메소스 통신 중에 문제가 있었고.. 그 여파가 마라톤에서 앱 배포가 문제가 발생했다.


E0409 18:14:34.853005  2198 slave.cpp:3456] Failed to update resources for container 41283b2f-3d3f-40d6-9c37-0011f1dfaa52 of executor 'plus-stage.489512aa-9618-11e7-8450-0242540dd87f' running task plus-stage.489512aa-9618-11e7-8450-0242540dd87f on status update for terminal task, destroying container: Failed to determine cgroup for the 'cpu' subsystem: Failed to read /proc/15390/cgroup: Failed to open file: No such file or directory




문제 해결을 하려면 메소스 버전업을 진행해야 한다. 


Posted by '김용환'
,


테스크 코드를 실행할 때 자바/스칼라 메모리가 부족할 수 있다.


sbt의 경우에는 아래와 같이 사용할 수 있다.


javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled")




메이븐(maven)의 경우는 3가지 방식으로 사용할 수 있다 .(아래 참조)
https://maven.apache.org/configure.html


주로는 다음과 같은 방식을 사용한다.

export MAVEN_OPTS="-Xms512M -Xmx32048M"











Posted by '김용환'
,


페이스북에서 개인정보 이슈로 공격을 받으면서 인스타그램 API의 관련와 관련된 대부분이 deprecated 되었다..



https://instagram.com/developer/changelog/


Platform Changelog

April 4, 2018

The following endpoints are deprecated immediately:

  • Follows and Relationships
    • GET /users/self/follows
    • GET /users/self/followed-by
    • GET /users/self/requested-by
    • GET /users/{user-id}/relationship
    • POST /users/{user-id}/relationship
  • Commenting on Public Content
    • GET /media/{media-id}/comments (Deprecation not relevant when fetching comments for self media)
    • POST /media/{media-id}/comments
    • DEL /media/{media-id}/comments/comment-id
  • Likes
    • GET /media/{media-id}/likes
    • POST /media/{media-id}/likes
    • DEL /media/{media-id}/likes
  • User Search
    • GET /users/{user-id}
    • GET /users/{user-id}/media/recent
    • GET /users/self/media/liked
    • GET /users/search
  • Subscriptions - to receive notifications when media is posted
  • Some information on Public Content returned through hashtag and location search will be removed - Name, Bio, Comments, Commenters, Follower Count, Following Count, Post Count, and Profile Picture


Posted by '김용환'
,