on-premises-cloud-and-docker
by
Yuuki Tsubouchi (yuuk1)
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
ΦϯϓϨϛεɺΫϥυ ͦͯ͠%PDLFS Hatena Engineer Seminar #3 id:y_uuki
Slide 2
Slide 2 text
@y_uuk1 id:y_uuki ӡ༻
Slide 3
Slide 3 text
Agenda ͯͳͷΠϯϑϥࣄ Docker ΛͲͷΑ͏ʹଊ͍͑ͯΔ͔ ͯͳͷWebΦϖϨʔγϣϯΤϯδχΞ
Slide 4
Slide 4 text
ͯͳͷ Πϯϑϥࣄ
Slide 5
Slide 5 text
%BUB$FOUFS "84 ࣗ࡞ αʔό 9FO ϕϯμ αʔό &$ 4 $MPVE'SPOU 3PVUF -74LFFQBMJWFE (MBJDJFS 71$ &-# )"1SPYZ .PHJMF'4 "LBNBJ
Slide 6
Slide 6 text
DC ͱ AWS • DCͰ Xen ͬͯͨΓ͢Δͱ AWS ͷ෦ΛͳΜͱͳ͘༧ Ͱ͖ͨΓ͢Δ • ͳΜ͔ϩʔυόϥϯαͷεϧʔϓοτͰͳ͍ → ϋΠύʔ όΠβଆͰ nf_conntrack ᷓΕٙ • ΠϯελϯελΠϓ͝ͱʹ state ͷ্ݶҧ͏ٙ • Domain 0ಉډΠϯελϯε • ΞΫςΟϒɾελϯόΠ2ͱಉډͰ೦ • Ϧιʔεͷ৯͍߹͍ (CPU %steal)
Slide 7
Slide 7 text
%FW 0QT $IFG $BQJTUSBOP /BHJPT .BDLFSFM .JEMMFXBSF "QQMJDBUJPO +FOLJOT 04
Slide 8
Slide 8 text
Dev ͱ Ops • αʔόͬΆ͍͜ͱʢσϓϩΠΑΓԼʣ͍͍ͩͨ Ops • Ξϥʔτ Dev ड͚ͱΔ • Dev ͱ Ops ͕ڠྗͯ͠োରԠ • DevνʔϜͷmeetingʹఆظతʹࢀՃ • Ops GHE ͷ issue ΈΔ (ઃఆม͑Δͱ͖PR) • ༵ۚϦϦʔε͠ͳ͍ • ஈ֊తͳϦϦʔε
Slide 9
Slide 9 text
՝
Slide 10
Slide 10 text
DCڥͱAWSڥͷڞ௨Խ • αʔόߏཧ Chef ✓ • ωοτϫʔΫ(VPC + VPN) ✓ • αʔόཧ/ϞχλϦϯάπʔϧ (Mackerel) ✓ • ࢹ(Nagios) ✓ • ϑΣΠϧΦʔό ✘ • Chef ద༻લͷOSΠϝʔδ(Packer) ✘
Slide 11
Slide 11 text
AWSͷݻ༗ͷػೳ͕͍ͮΒ͍ AWSϩοΫΠϯ AWSαʔϏεʹґଘͨ͠ΈΛ࡞ΔͱDC ଆʹྲྀ༻ͮ͠Β͍
Slide 12
Slide 12 text
Dev ͱ Ops ͷίϛϡχέʔγϣϯ • Dev ͔Β Ops ʹϗετߏஙΛґཔ • ຊ൪ʹ Redis ͕ͳͯ͘ࣄނ • Dev ͔Β Ops ʹ Jenkins ϗετʹඞཁͳύοέʔ δΛΠϯετʔϧґཔ • ޓ͍ʹ໘ • ΄͍͠ਓͱ༻ҙ͢Δਓ͕ҟͳΔͷ͕ • ͦͦ Dev ͕ϗετߏங͍͢͠ڥ͕Α͍
Slide 13
Slide 13 text
Docker
Slide 14
Slide 14 text
It is Not Docker • VMͱ͔ੜLXC Έ͍ͨʹϩάΠϯͯ͠ੜ׆͢Δ ͷͰͳ͍ • Linuxίϯςφ ≠ Docker • Docker ಛผɺେنڥ͚ͱ͍͏Θ͚Ͱ ͳ͍
Slide 15
Slide 15 text
It is Docker • Linux ͷϢʔβϥϯυڥΛؙ͝ͱΠϝʔδԽ • ΞϓϦέʔγϣϯ͝ͱʹίϯςφԽ • ls ίϚϯυ͚ͩͷ Docker ίϯςφͱ͔ • Dockerίϯςφͷ࣮ମͨͩͷOSͷϓϩηε • Χʔωϧ෦Ͱִ͞ΕͯΔ
Slide 16
Slide 16 text
όʔδϣϯͷҧ͏ MySQL Λ3 ಉ͡ϗετͰಈ͔ͤ·͔͢ʁ
Slide 17
Slide 17 text
user, datadir, port, socket, pidfile, install_dir, my.cnf ! ͳͲͷϦιʔεΛ3ͭͣͭ࡞Δ UNIX ʹ౷తʹϦιʔε ػೳ͕ͳ͍
Slide 18
Slide 18 text
$ docker run -d mysql:5.5 $ docker run -d mysql:5.6 $ docker run -d mysql:5.7 It is Docker
Slide 19
Slide 19 text
Chef ͱ͔ͬͯOSͷϢʔβϥϯυ γεςϜ͕ෳࡶ͗ͯ͢ཧͰ͖ͳ͍ ! ·ͱʹཧ͢ΔͷΛ͖͋ΒΊͯ ΞϓϦέʔγϣϯ͝ͱʹ ϢʔβϥϯυΛ༻ҙ͍͢͠ΈΛ ఏڙͨ͠ͷ͕ Docker
Slide 20
Slide 20 text
DockerͰͳʹ͕Ͱ͖Δ͔ • DC ڥ ͱ Ϋϥυڥͷڞ௨Խ • DCͱΫϥυͰಉ͡ Docker image ͕ಈ͘ • αʔϏεͷਰʹซͤͯɺDC <=> Ϋϥυ • Dev ͱ Ops ͷίϛϡχέʔγϣϯ • Dev ΤϯδχΞ͕ඞཁͳΞϓϦέʔγϣϯͷ Dockerfile Λॻ͍ͯɺOps ΤϯδχΞ͕ϨϏϡʔͯ͠ ͦͷ··σϓϩΠ • ΄͍͠ਓ͕४උ͍͢͠
Slide 21
Slide 21 text
ͦΕDockerͰͰ͖ΔΑ
Slide 22
Slide 22 text
Docker͕ؔΘΔྖҬଟ͍ • ΞϓϦέʔγϣϯσϓϩΠ • ϩʔΧϧڥ͔Β CI Λܦ༝ͯ͠ຊ൪·Ͱ • ߏཧπʔϧʢChef, Puppet…) • Docker ࣌ͷαʔόϞχλϦϯά • Docker ࣌ͷϩάऩू • LinuxΧʔωϧ • LinuxίϯςφɺAUFS ͳͲ
Slide 23
Slide 23 text
ΞϓϦέʔγϣϯσϓϩΠ • શͯͷڥͰಉ͡ Docker image ΛΘͳ͍ͱ ϝϦοτ͕ബ͍ • ϩʔΧϧڥɺ։ൃڥɺstagingڥɺCI ڥɺຊ൪ڥ • ෦తʹಋೖ͢Δͱ Docker ڥͱ௨ৗͷ ڥΛ྆ํϝϯς͠ͳ͍ͱ͍͚ͳ͘ͳΔ • ։ൃνʔϜͷΤϯδχΞશһ+σβΠφʔ DockerڥͰ։ൃ͢Δ͜ͱʹͳΔ
Slide 24
Slide 24 text
@ Hatena
Slide 25
Slide 25 text
߹॓ͰσϓϩΠཧπʔϧ࣮ ࣮ࡍʹෳࡶ࣮͗ͯ͢༻͔ͬͨ͠ *NNVUBCMF*OGSBTUSVDUVSFʹඞཁͳཁૉ٧·ͬͯͨ
Slide 26
Slide 26 text
SQN EFCύοέʔδΛ࡞ΔڥΛ࡞Δͷ͕໘ͩͬͨ
Slide 27
Slide 27 text
DBUVTSCJOSSEUPPM CJOTI FYFDEPDLFSSVOSNNBDLFSFMSSEUPPM! RRDtool ☓ Docker Πϯετʔϧ͕໘ͳίϚϯυΛ%PDLFSԽ $POUBJOFS$PNNBOE1BUUFSO
Slide 28
Slide 28 text
Graphite ☓ Docker • Graphite ͷΑ͏ͳڥߏங͕໘ͳͷ Docker ͰϩʔΧϧڥͱCIڥΛߏங • https://registry.hub.docker.com/u/mackerel/graphite/ EPDLFSSVOEOBNFHSBQIJUFWUNQMPHWBSMPHHSBQIJUFW UNQXIJTQFSWBSMJCHSBQIJUFTUPSBHFXIJTQFSQQ QNBDLFSFMHSBQIJUF
Slide 29
Slide 29 text
Docker ΞΠσΞ • ϒϥϯν͝ͱʹαʔϏεηοτΛ࡞ΔΈ • ϚΠΫϩαʔϏεͷ֤ίϯϙʔωϯτΛDockerԽ • ڥߏங͕؆୯ʹͳΔ • ςετͰଞαʔϏεΛୟ͘ͱ͖ʹϞοΫԽ͍ͯ͠ ͨͱ͜ΖΛຊΛ͚ͨͨͨΓ͢Δ • Docker cron • cron ͕ಈ͔ͳ͍ • खݩͰ࣮ߦ͍͢͠Α͏ʹ
Slide 30
Slide 30 text
Docker ࣗମΛ ࣗલͰӡ༻͢Δ or ͠ͳ͍
Slide 31
Slide 31 text
Docker ͷӡ༻ • Docker ࣗମͷτϥϒϧγϡʔςΟϯά • ಥવDNSҾ͚ͳ͘ͳΔ • ΰϛআ (ཹ͢Δίϯςφ) • ϚϧνϗετσϓϩΠ • ΦʔέετϨʔγϣϯπʔϧԿΛ͏͔ • Kubernetes, fleet, Consul, … • DNSͰσΟεΧόϦͨ͘͠ͳ͍ • Docker ίϯςφͷωοτϫʔΫߏ • ϗετଆͱϑϥοτ or NAPT • ௐࠪͷํ๏ͷཱ֬ • ssh ͰϩάΠϯͱ͍͏ੈքͰͳ͍ (docker exec /bin/bash)
Slide 32
Slide 32 text
ΫϥυαʔϏε • AWS EC2 Container Service • Google Container Engine ! • Dockerͷӡ༻Λશ෦ͤΒΕΔ • AWS <-> Google Մ
Slide 33
Slide 33 text
ઐ༻αʔό • શͯͷαʔϏεΛΫϥυʹͷͤΔͱߴ͍ • ωοτϫʔΫ&ϋʔυΣΞཧΛΦϑϩʔυͭ͠ ্͕ͭ҆Γ • Xen ͰԾԽͤͣʹɺཧϋʔυͷ্ʹίϯςφ • Docker ͳΒ Ϋϥυ 㱻 ΦϯϓϨϛεͷҠಈ͕ Γ͍͢ • ৽αʔϏεશ෦Ϋϥυ -> ྲྀߦΒͳ͔ͬͨΒ ઐ༻αʔόڥୀආ ͷΑ͏ͳઓུ͕ͱΓ͍͢
Slide 34
Slide 34 text
ͦΕͰ·ͩෆ҆ • ࠓॻ͍ͨ Dockerfile 1 ޙಈ͔ͳ͍Մೳੑ (DockerfileࣗମͰόʔδϣϯݻఆͱ͔Ͱ͖ΔΘ ͚Ͱͳ͍) • Docker image Λޙੜେࣄʹ͓࣋ͬͯ͘ඞཁ ͕͋Δ • ࠓ࡞ͬͨ Docker image ͕1ޙͷDocker runtimeͰಈ͔͘Ͳ͏͔
Slide 35
Slide 35 text
Docker ύϥμΠϜΛม͑Δ
Slide 36
Slide 36 text
͔ͩΒͦ͜ӡ༻ج൫ͱ։ൃج൫Λ શͯDockerલఏͰߟ͑ͳ͍ͱ Ձ͕Ͱͳ͍
Slide 37
Slide 37 text
No content
Slide 38
Slide 38 text
ͯͳͷ WebΦϖϨʔγϣϯ ΤϯδχΞ
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
ͬͯΔ͜ͱ͕ҧ͏
Slide 41
Slide 41 text
y_uuki ͷ߹
Slide 42
Slide 42 text
ɾΞϧόΠτ࣌: ࣾMackerel։ൃ(Perl) (YAPC Asia) ɾೖࣾ: EC2Ͱ HAProxy νϡʔχϯά http://yuuki.hatenablog.com/entry/2014/03/20/085600 ɾXen, LVS(keepalived), Chef, Nagios Ұ௨Γ ɾ߹॓: Docker + Mesos σϓϩΠཧπʔϧ࡞Δ http://yuuki.hatenablog.com/entry/2013/12/22/174813 ! ɾ৽αʔϏεͷߏஙӡ༻ʢMackerelʣ ɾJVM, PostgreSQL, Graphite(࣌ܥྻDB) ɾmackerel-agent ύοέʔδఏڙ http://yuuki.hatenablog.com/entry/docker-package-ci ! ɾJVM Operation Casual http://yuuki.hatenablog.com/entry/2014/04/08/074507 ɾGraphiteνϡʔχϯά http://yuuki.hatenablog.com/entry/monitoringcasual6 ɾMackerel OSS ·ΘΓϝϯςφϯε ɾISUCON4 ຊઓग़ http://yuuki.hatenablog.com/entry/dockerized-isucon ɾMackerel CLI tool github.com/y-uuki/gomkr ɾ߹॓: GoͰδϣϒΩϡʔγεςϜ
Slide 43
Slide 43 text
WebΞϓϦέʔγϣϯ։ൃ ϋʔυΣΞௐୡͱ͔ωοτϫʔΫઃܭ ্ Լ OSΧʔωϧ ϛυϧΣΞ: MySQL, PostgreSQL, Redis, memcached, Nginx, Apache, Elasticsearch, Solr, Varnish, Squid Jenkins(CI) Capistrano(σϓϩΠ) Nagios Chef
Slide 44
Slide 44 text
ࣗͷϨΠϠʔ: N N → N - 1 N + 1 → N ! ͕Ͱ͖Δڥ
Slide 45
Slide 45 text
ઍਓ
Slide 46
Slide 46 text
ઍਓ ʜ ৽αʔϏε ৽αʔϏε ৽αʔϏε
Slide 47
Slide 47 text
5ਓʂʁ
Slide 48
Slide 48 text
CRITICAL
Slide 49
Slide 49 text
We are Hiring! IUUQIBUFOBDPSQKQSFDSVJUDBSFFSPQFSBUJPOFOHJOFFS