Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Joe's and working with LXC
Search
O. Ikehara
June 17, 2017
Technology
340
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Joe's and working with LXC
第11回 コンテナ型仮想化の情報交換会@大阪
O. Ikehara
June 17, 2017
Other Decks in Technology
See All in Technology
APIセキュリティを組織で実現するには~注力する点と設計・実装に入れたい対策~
riiimparm
3
870
アクセスキー流出時の対応で再認識した攻撃側と防御側の非対称性について
kazzpapa3
1
520
Backstageでつくるセルフサービスな社内開発基盤
kikunosuke75
1
190
どんな手を使っても絶対間に合わせるスケジューラ
asari194617
0
1.5k
いかに伝えるか 〜新卒エンジニアの教育のための、ライトノベル活用の一例
ikedon
1
160
Bet AI Day 2026丨Production-Ready AI Agents — エンタープライズの実務を任せるための設計と運用
layerx
PRO
2
1.6k
Kiro5兄弟のいまどきのセキュリティ基礎知識
kentapapa
0
500
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
77k
生成AI時代の クレデンシャルとパーミッション設計
nrinetcom
PRO
3
760
KPIだけでは評価できないプロダクトが考えるべき Evalsという第二の評価系 / Beyond KPIs: Evals as a Second Evaluation Framework for Products #PdEConf
aki_iinuma
0
520
Bet AI Day 2026丨バクラク Autopilot、業務システムの再設計
layerx
PRO
1
810
『自分で判断できるか』を基準に、プロダクトのハンズオン研修でAI利用の線を引いてみた / Where We Drew the Line on AI in Hands-on Training
honyanya
1
800
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
1
490
Agile that works and the tools we love
rasmusluckow
331
22k
Chasing Engaging Ingredients in Design
codingconduct
0
290
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
GraphQLとの向き合い方2022年版
quramy
50
15k
Unsuck your backbone
ammeep
672
58k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
220
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
590
Producing Creativity
orderedlist
PRO
348
41k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Are puppies a ranking factor?
jonoalderson
2
3.9k
Transcript
Joe'sとLXCとその運用実例と June, 17th 2017
2 今日話すこと LXCでサーバー運用するとこんな感じ LXCも意外と面白いんじゃない?
3 Joe's Cloud Computing 設立 2002年7月 資本金 1,000万円 従業員数 11名
代表者 代表取締役社長 田中 邦裕 親会社 さくらインターネット株式会社 所在地 大阪本社 大阪市北区梅田1-11-4-923 大阪駅前第4ビル 9F 銀座オフィス 東京都中央区銀座1-3-3 G1ビル 7F 青山オフィス 東京都港区南青山2-11-13 南青山ビル 4F
4 Joe's Cloud Computing クラウドホスティング事業 – https://www.joeswebhosting.net/ – フルマネージドサービスを中心にインフラ・運用サポートを提供 –
共用サーバー・専用サーバー・VPS(仮想サーバー)・IP分散サーバー
5 Joe's Cloud Computing 国内最大級のSSL証明書販売サービス「Joe’s SSL市場」 – https://joes-ssl.com/ – 主要5ブランドのSSL証明書を40~70%引きで販売
– 申請から取得まで、すべて日本語で対応 – シマンテック・ジオトラスト・グローバルサイン・コモド・セコム
6 Joe's Cloud Computing 経営支援事業 – バーチャルオフィス「Joe’s Business Center」 –
https://www.joes-office.com/ – 月額4,000円から銀座・青山・梅田の一等地に仮想的なオフィスが持てる – 住所利用・郵便物受取(転送)・電話転送・月8時間まで会議室無料
7 Speaker紹介 Osamu Ikehara 1971年産 大阪生まれ大阪育ち 2006年 Joe's入社 サーバーインフラ、カスタマサポート担当 趣味はスキーとか釣りとか 愛車:YZF-R1
'07 twitter : samai fb : https://www.facebook.com/samaiyou
8 Joe'sとLXC 2001年 Scientific Linux6 with kernel 2.6.32.41 +
patch zfs on fuse 当初よりテンプレートを意識した設計 2010年~ ubuntuに乗り換え LXDへの移行模索中
9 Joe'sとLXC 現在 – 共用サーバーの半分がLXC駆動 • リソースの有効活用 • 古いサーバーの統合のため
• cPanelのライセンスがVPSでいける!
10 LXCと仮想サーバー 仮想化の違い – ハイパーバイザー型 • 完全仮想化 – ハードウェアをエミュレーション
• 準仮想化 – システムコールなどをハイパーバイザーが最適化 – コンテナ – hostのプロセスをうまく権限分離して利用
11 LXCとDocker Dockerと何が違うのか – Docker • 基本的にアプリケーションコンテナ • 一度作ったら基本変更しない
– LXC • OSをまるごとコンテナ化 • コンテナ内で作業を行う
12 kvmとの比較 ベンチマーク – kvm kvm xfs qemu 2cpu
1G Dhrystone 2 using register variables 56792694.6 lps (10.0 s, 7 samples) Double-Precision Whetstone 6810.8 MWIPS (10.0 s, 7 samples) Execl Throughput 5672.4 lps (29.9 s, 2 samples) File Copy 1024 bufsize 2000 maxblocks 1248151.2 KBps (30.0 s, 2 samples) File Copy 256 bufsize 500 maxblocks 338920.3 KBps (30.0 s, 2 samples) File Copy 4096 bufsize 8000 maxblocks 3407075.7 KBps (30.0 s, 2 samples) Pipe Throughput 2262617.5 lps (10.0 s, 7 samples) Pipe-based Context Switching 446836.1 lps (10.0 s, 7 samples) Process Creation 19729.1 lps (30.0 s, 2 samples) Shell Scripts (1 concurrent) 8706.8 lpm (60.0 s, 2 samples) Shell Scripts (8 concurrent) 1099.2 lpm (60.1 s, 2 samples) System Call Overhead 3152446.2 lps (10.0 s, 7 samples) System Benchmarks Index Values BASELINE RESULT INDEX Dhrystone 2 using register variables 116700.0 56792694.6 4866.6 Double-Precision Whetstone 55.0 6810.8 1238.3 Execl Throughput 43.0 5672.4 1319.2 File Copy 1024 bufsize 2000 maxblocks 3960.0 1248151.2 3151.9 File Copy 256 bufsize 500 maxblocks 1655.0 338920.3 2047.9 File Copy 4096 bufsize 8000 maxblocks 5800.0 3407075.7 5874.3 Pipe Throughput 12440.0 2262617.5 1818.8 Pipe-based Context Switching 4000.0 446836.1 1117.1 Process Creation 126.0 19729.1 1565.8 Shell Scripts (1 concurrent) 42.4 8706.8 2053.5 Shell Scripts (8 concurrent) 6.0 1099.2 1832.1 System Call Overhead 15000.0 3152446.2 2101.6 ======== System Benchmarks Index Score 2105.3
13 kvmとの比較 ベンチマーク – lxc lxc 2cpu 1G memory
Dhrystone 2 using register variables 56862017.1 lps (10.0 s, 7 samples) Double-Precision Whetstone 7563.2 MWIPS (8.4 s, 7 samples) Execl Throughput 8277.0 lps (29.7 s, 2 samples) File Copy 1024 bufsize 2000 maxblocks 1079453.4 KBps (30.0 s, 2 samples) File Copy 256 bufsize 500 maxblocks 280578.7 KBps (30.0 s, 2 samples) File Copy 4096 bufsize 8000 maxblocks 3060459.2 KBps (30.0 s, 2 samples) Pipe Throughput 2798487.3 lps (10.0 s, 7 samples) Pipe-based Context Switching 440048.3 lps (10.0 s, 7 samples) Process Creation 20450.4 lps (30.0 s, 2 samples) Shell Scripts (1 concurrent) 9387.7 lpm (60.1 s, 2 samples) Shell Scripts (8 concurrent) 1269.3 lpm (60.2 s, 2 samples) System Call Overhead 2850317.5 lps (10.0 s, 7 samples) System Benchmarks Index Values BASELINE RESULT INDEX Dhrystone 2 using register variables 116700.0 56862017.1 4872.5 Double-Precision Whetstone 55.0 7563.2 1375.1 Execl Throughput 43.0 8277.0 1924.9 File Copy 1024 bufsize 2000 maxblocks 3960.0 1079453.4 2725.9 File Copy 256 bufsize 500 maxblocks 1655.0 280578.7 1695.3 File Copy 4096 bufsize 8000 maxblocks 5800.0 3060459.2 5276.7 Pipe Throughput 12440.0 2798487.3 2249.6 Pipe-based Context Switching 4000.0 440048.3 1100.1 Process Creation 126.0 20450.4 1623.0 Shell Scripts (1 concurrent) 42.4 9387.7 2214.1 Shell Scripts (8 concurrent) 6.0 1269.3 2115.5 System Call Overhead 15000.0 2850317.5 1900.2 ======== System Benchmarks Index Score 2175.6
14 kvmとの比較 プロセス管理 – kvm libvirt+ 3025 10.8 6.2
8994740 4139096 ? Sl 2017 100573:22 qemu-system-x86_64 -enable-kvm -name server.xxxxxxxxxxxxxxx.com -S -machine pc-i440fx-trusty,accel=kvm,usb=off -m 4096 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 16897bd1-c520-4f31-8673-8955996e2201 -n
15 kvmとの比較 プロセス管理 – lxc root 28021 0.0 0.0
51560 1688 ? Ss Jun06 0:00 lxc-start -n hogehoge root 28040 0.0 0.0 35896 5284 ? Ss Jun06 0:00 \_ /sbin/init root 29750 0.0 0.0 49264 1356 ? Ss Jun06 0:00 \_ /lib/systemd/systemd-udevd --daemon message+ 29853 0.0 0.0 256224 28844 ? Ssl Jun06 0:32 \_ rsyslogd root 29966 0.0 0.0 12776 844 pts/3 Ss+ Jun06 0:00 \_ /sbin/getty -8 38400 tty4 root 29973 0.0 0.0 12780 856 pts/1 Ss+ Jun06 0:00 \_ /sbin/getty -8 38400 tty2 root 29974 0.0 0.0 12780 852 pts/2 Ss+ Jun06 0:00 \_ /sbin/getty -8 38400 tty3 root 29987 0.0 0.0 23648 1036 ? Ss Jun06 0:01 \_ cron root 29994 0.0 0.0 61376 3056 ? Ss Jun06 0:00 \_ /usr/sbin/sshd -D root 30043 0.0 0.0 274448 17340 ? Ss Jun06 0:26 \_ php-fpm: master process (/etc/php5/fpm/php-fpm.conf) 1001 26110 0.4 0.0 283240 36216 ? S 15:13 0:11 | \_ php-fpm: pool www 1001 4828 1.1 0.0 290696 43288 ? S 15:17 0:30 | \_ php-fpm: pool www 1001 10901 0.4 0.0 286024 32992 ? S 15:42 0:05 | \_ php-fpm: pool www 1001 30362 0.0 0.0 12740 444 ? Ss Jun06 0:00 \_ /usr/sbin/fcgiwrap -f root 30400 0.0 0.0 86012 1604 ? Ss Jun06 0:00 \_ nginx: master process /usr/sbin/nginx 1001 30403 0.0 0.0 87164 4420 ? S Jun06 1:05 | \_ nginx: worker process 1001 30404 0.0 0.0 87308 4532 ? S Jun06 1:04 | \_ nginx: worker process 1001 30405 0.0 0.0 87416 4556 ? S Jun06 1:05 | \_ nginx: worker process 1001 30407 0.0 0.0 87164 4404 ? S Jun06 1:02 | \_ nginx: worker process root 13076 0.0 0.0 12640 1736 ? S Jun06 0:00 \_ /bin/bash /usr/bin/mysqld_safe
16 LXC運用のメリット リソース管理がし易い – ダウンタイムの減少 – マネージドの管理がしやすい
17 LXC運用 実際のところJoe'sでどんなLXCの使い方をして いるのか。 – zabbix運用 – 障害対応 –
IPブロック – プロセス管理
18 運用例 さまよえるzabbix 運用テストでLXCでzabbixを作成 – nagiosがごちゃごちゃしすぎてたのでアップ デートが難しかった裏事情 – IPもったいなかったのでNATで設定
# lxc-create -t download -n zabbix –- -d ubuntu -r trusty -a amd64 # lxc-attach -n zabbix apt-get -y install zabbix-server-mysql # iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 10051 -j DNAT --to-destination 10.0.3.218:10051 # iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.0.3.218:443
19 運用例 さまよえるzabbix いい感じなのでどんどん監視対象追加 – テスト運用なので古い遅いマシン – どんどんリソースが足りなくなってきた
じゃあそのまま本番環境に…… – 本番用のちゃんとしたマシンにubuntuを入れて old # lxc-stop -n zabbix old # rsync -av –numeric-ids /var/lib/lxc/zabbix/ newserver:/var/lib/lxc/zabbix/ new # lxc-start -d -n zabbix
20 運用例 さまよえるzabbix 同一ネットワークだと監視の意味が じゃあさくらクラウドに移しちゃえ…… – さくらクラウド2CPU4Gにubuntuを入れて new
# lxc-stop -n zabbix new # rsync -av –numeric-ids /var/lib/lxc/zabbix/ newserver:/var/lib/lxc/zabbix/ sakura # lxc-start -d -n zabbix
21 運用例 障害対応 やばいハードウェア障害が!
22 運用例 障害対応 ヽ(`Д´)ノウワァァァン – MBRが読み込めなかったり – 古いシステムで起動しないとか –
データはあるのにどうしたら
23 運用例 障害対応 起動しなくてもデータが有るのなら – 一旦全部吸い出してLXCで起動しよう! – PXEやUSBのレスキュー環境から –
こんな感じで/からまるごと吸い上げ – rc.sysinitとかrc.localなんかの不要な部分を消し # rsync -av –numeric-ids –exclude=/proc/ --exclude=/sys/ /mnt/resucuedevice/ lxchost:/var/lib/lxc/rescue/rootfs/ # lxc-start -d -n rescue
24 運用例 IPブロック LXCコンテナにアタックが – ipsetとiptables FORWARDチェインでブロック – FORWARDなので失敗しても取り消しやすい
例 ロシアからのsmtpをブロックする # wget http://www.ipdeny.com/ipblocks/data/countries/ru.zone # ipset create BLACKLIST hash:net # for i in `cat ru.zone `;do ipset add BLACKLIST $i;done # iptables -A FORWARD -p tcp -m state --state NEW -m tcp --dport 25 -m set --match-set BLACKLIST src -j DROP
25 運用例 プロセス管理 ホスト側から監視 – htopで見てみる
26 これからのLXCホスティング デプロイ速度の向上 – テンプレートの活用 仮想コンソールの実装 – 簡単に自分のコンテナにアタッチしたい
Migration / HAの実装 まだまだこれから楽しめる分野
27 ご清聴ありがとうございました Any Question?
28 使用したツールとか OSSに感謝 – linux • https://www.kernel.org/ • https://www.ubuntu.com/
– LXC / LXD • https://linuxcontainers.org/ – Unixbench • https://github.com/kdlucas/byte-unixbench.git