Contenu connexe Similaire à OpenVZ - Linux Containers:第2回 コンテナ型仮想化の情報交換会@東京 (20) Plus de Kentaro Ebisawa (20) OpenVZ - Linux Containers:第2回 コンテナ型仮想化の情報交換会@東京3. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
こんなんやってます @ebiken
• Parallels Inc. パラレルス株式会社
– Solution Architect, APAC
– Parallels Automation (BSS/OSS)
• Business Support System / Operation Support System
• Japan Vyatta Users Group
– VYATTA USERS MEETING Autumn 2013
– @新宿住友ホール・スカイルーム5
– 2013年10月11日(金)
– http://atnd.org/event/jvum2013a
• パケット関連:
– Internet Week 2012: D1 パケットフォワーディングを支える技術
• https://www.nic.ad.jp/iw2012/program/d1/
– Internet Week 2011: S9 仮想化時代のパケットフォワーディング
• https://www.nic.ad.jp/iw2011/program/s09/
3
5. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
コンテナ型仮想化のいろいろ
• OpenVZ
• Virtuozzo
• LXC (Linux Container)
• Linux-Vserver
• Solaris Zones
• FreeBSD Jails
• Google Container (独自)
• Facebook??
5
6. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
ハードウェア仮想化 OS仮想化
仮想マシン
Virtual Machine(VM)
コンテナ
Container(CT)
Virtual Environment (VE)
仮想化のレベル
ハードウェア環境を仮想化 OS環境を仮想化
物理サーバー毎の混在環境
異なるOSが共存可能
異なるディストリビューション
が共存可能(カーネル共通)
仮想環境の起動
OSを起動 プロセスを起動
ネットワークアクセス
仮想ハードウェア経由 仮想インターフェース経由
仮想化方式の比較
6
7. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05) 7
OS仮想化=コンテナの特徴
起動が早い(OSはブート済み)
高密度(カーネル・メモリを共有)
ハードウェア仮想化のオーバーヘッド無し
コンテナ毎のリソース
root / users / groups IPアドレス
メモリ プロセス
設定ファイル ライブラリ
仮想化方式の比較
9. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
Isolation & Resource Control
• (Namespace) Isolation
– Mechanism which adds an additional indirection or
translation layer to the naming/visibility of some unix
resource space (such as process ids, or network interfaces) for
a specific set of processes.
– Typically the existence of isolation itself is invisible to the
processes being isolated.
• Resource control
– Mechanism which can do either or both of:
– A. Tracking how much of a resource is being consumed by a
set of processes
– B. imposing quantitative limits on that consumption, either
absolutely, or just in times of contention.
9
“Adding Generic Process Containers to the Linux Kernel”
Paul B. Menage @ Google / Balbir Singh and Srivatsa Vaddagiri @ IBM
10. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
リソース空間の分離 & リソースの管理
• リソース空間の分離
– プロセスの集合を識別するための名前付けを実施、
– リソース空間を分割し、参照可能な範囲を規定。
– 各プロセスは分離されている事を認識しない
• リソース管理・制限
– あるプロセスの集合が使用しているリソースを追跡
– リソース使用量の制限(絶対量 or 相対量)
10
※ リソース空間=プロセスID、ネットワークインターフェース、メモリ、CPU 等
11. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
リソース空間の分離 & リソースの管理
• リソース空間の分離
– プロセスの集合を識別するための名前付けを実施、
– リソース空間を分割し、参照可能な範囲を規定。
– 各プロセスは分離されている事を認識しない
• リソース管理・制限
– あるプロセスの集合が使用しているリソースを追跡
– リソース使用量の制限(絶対量 or 相対量)
11
※ リソース空間=プロセスID、ネットワークインターフェース、メモリ、CPU 等
namespace
cgroups
12. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
USER PID COMMAND
root 1 init
root 2 kthreadd
root 3 migration/0
root 4 ksoftirqd/0
root 4301 sshd
ebiken 4303 sshd
ebiken 4304 bash
root 7604 init
root 7605 kthreadd/100
root 7606 khelper/100
51 8511 sendmail
48 8522 httpd
root 8527 crond
root 8598 init
root 8599 kthreadd/200
root 8600 khelper/200
51 9824 sendmail
48 9835 httpd
root 9840 crond
root 1 init
root 2 kthreadd/100
root 3 khelper/100
smmsp 555 sendmail
apache 566 httpd
root 571 crond
root 1 init
root 2 kthreadd/200
root 3 khelper/200
smmsp 506 sendmail
apache 517 httpd
root 522 crond
cgroups
eth0 eth1
br0
venet0
veth100.0
eth0
veth200.0
venet0 eth0venet0
namespace
コンテナ① コンテナ②
12
13. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
vzctl : OpenVZ containers control utility
• vzctl
• vzlist
• vzcalc
• vzcfgvalidate
• vzcpucheck
• vzeventd
• vzifup-post
• vzmemcheck
• vzmigrate
• vznetaddbr
• vznetcfg
• vzpid
• vzsplit
• vzubc
13
コンテナ操作のためのコマンド群
14. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
ploop: disk loopback block device
• 今まで:コンテナ専用のフォルダ⇒chroot()
– 同じファイルシステム上のため、quota/inode 管理が煩雑
– コンテナのバックアップ・マイグレーションに課題
• ファイルコピーになるため、inode番号が変わる
• ファイル数が多いため、バックアップ&スナップショットに時間が…
• ploop
• ファイルをブロックデバイスとしてファイルシステムを構築
– Linux loop と同じコンセプト
– Write tracker
– Snapshots
14
LXC はどうやってるんだっけ?
15. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
CRIU: checkpoint/restore in userspace
• Using this tool, you can freeze a running
application (or part of it) and checkpoint it to a
hard drive as a collection of files.
• コンテナの全プロセスのスナップショット
• ploop + CRIU でライブマイグレーションを効率化
– Disk IOが大きい場合のフリーズタイム短縮
– ネットワークタイムアウト防止
15
18. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
誰が作ってるの?
18
• Parallels の開発者+Contributor
• Parallels 商用製品の基盤
– Virtuozzo
• コンテナ仮想化
– Parallels Cloud Server (PCS)
• コンテナ+バーチャルマシン 混在
http://openvz.org/Main_Page
Kirill Kolyshkin
Team Leader, Open VZ
19. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
オープンソース貢献へさらに注力
=> Main Line へ統合!
19
• 2011年5月 「蝶ネクタイの偉人」を採用
James Bottomley
• CTO, Server Virtualisation at Parallels
• Linux Kernel maintainer
– SCSI subsystem, PA-RISC Linux and
the 53c700 set of drivers.
• Linux Foundation
– Director on the Board
– Chair of Technical Advisory Board
20. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
http://openvz.org/File:Kernel_patches_stats.png
Kernel updates by OpenVZ Team (3.8-rc4)
20
network namespaces
James Join
21. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
vzctl for upstream kernel
• vzctl を mainline で使える!
• OpenVZ Kernel じゃなくてもコンテナ作れる!
http://wiki.openvz.org/Vzctl_for_upstream_kernel
21
22. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
“OpenVZ Maintenance Partnership”
• 有償サポート
• チケット購入
– $499 = 10 チケット/ 年
• バグ修正
– 年間最大10個の “high priority bugs” 登録
• 機能追加リクエスト
– 開発チームがレビューし実装までの見積もりを回答
22
http://www.parallels.com/support/virtualization-suite/openvz/
23. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
ちょっとCM:Parallels Cloud Server 6.0
23
Parallels Cloud Server 6.0
• Parallels Cloud Storage
– 稼働するゲストOS(Linux)の最適化
– 未使用のディスクスペースからゲストOSのた
めのストレージプールを用意
– 拡張性、伸縮性の両方に対応
– 高パフォーマンス、高可用性ストレージ
サービスを提供
– 高速なライブマイグレーション
– 可用性を高める実データのレプリケーション
• Parallels Containers
– I/O及びメモリ処理のボトルネックを削減する
効率的なメモリキャッシング
– 容易なマイグレーション、バックアップを
可能にする新しいコンテナレイヤ
– Kernelアップデート時のゲストOSダウンを
防ぐリブートレスアップデート
• Parallels Hypervisor Virtualization
– ゲストOSの自由選択可
– ベアメタルインストール
- OSベンダー提供のインストーラーを使用
コンテナ+仮想マシン 共存仮想プラットフォーム
Parallels Containers Parallels Hypervisor
25. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
1. Install OpenVZ Kernel
# wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
# rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
# yum install vzkernel
2. Install User Level Tools
# yum install vzctl vzquota ploop
3. Reboot !!
#[ebiken@openvz01 ~]$ uname -a
Linux openvz01 2.6.32-042stab081.3 #1 SMP Mon Sep 9 20:07:47 MSK
2013 x86_64 x86_64 x86_64 GNU/Linux
http://wiki.openvz.org/Quick_installation
OpenVZ のインストール on CentOS
25
26. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
コンテナの作成
26
1. Download OS templates
ここから >> http://openvz.org/Download/template/cache
# wget -P /vz/template/cache
http://download.openvz.org/template/precreated/centos-6-
x86_64.tar.gz
2. Create Container
# vzctl create CTID --ostemplate osname
# vzctl set CTID --ipadd a.b.c.d --save
# vzctl set CTID --nameserver a.b.c.d --save
# vzctl start CTID
vzctl create 100 --ostemplate centos-6-x86_64
vzctl set 100 --ipadd 192.168.146.200 --hostname ct01 --save
vzctl set 100 --nameserver 8.8.8.8 --save
vzctl start 100
https://wiki.openvz.org/Basic_operations_in_OpenVZ_environment
28. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZ のコマンド
28
[root@ovz01 100]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
100 16 running 10.10.0.100 ct100
200 - stopped 10.10.0.200 ct200
[root@ovz01 100]# vzctl stop 100
Stopping container ...
Container was stopped
[root@ovz01 100]# vzctl start 100
Starting container ...
...<snip>...
Container start in progress...
[root@ovz01 100]# vzctl exec 100 uname -a
Linux ct100 2.6.32-042stab059.7 #1 SMP Tue Jul 24 19:12:01 MSK 2012 i68
[root@ovz01 100]# uname -a
Linux ovz01 2.6.32-042stab059.7 #1 SMP Tue Jul 24 19:12:01 MSK 2012 x86
29. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZ のコマンド
[root@ovz01 100]# vzctl enter 100
entered into CT 100
[root@ct100 /]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqu
link/void
inet 127.0.0.1/32 scope host venet0
inet 10.10.0.100/24 brd 10.10.0.255 scope global venet0:0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
link/ether 00:18:51:c2:fd:7b brd ff:ff:ff:ff:ff:ff
inet 10.10.0.110/24 brd 10.10.0.255 scope global eth0
inet6 fe80::218:51ff:fec2:fd7b/64 scope link
valid_lft forever preferred_lft forever
29
31. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
namespace & cgroups
# cgroups = Control Groups
namespace cgroups
File system cpuset
Process ID cpu
IPC cpuacct
network devices
UTS freezer
/proc blkio
/sys
31
32. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
File System
• ファイルシステムの分離
• /vz/root/<ctid> が各コンテナの / (root) となる
namespace
参考:http://wiki.openvz.org/WP/What_are_containers
/ (root)
/bin /etc /usr /proc /sys /dev /vz
/root
/bin
/100 /200 /<CTID>
/lib
/ (CT100 root)
/bin /etc /usr /proc /sys /dev
/bin /lib
32
33. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
Process ID , IPC
• Process ID
– ホスト、各コンテナで独自のプロセスID空間を持つ
– 例:/sbin/init のプロセスID
• 各コンテナ内で参照:1
• ホストから参照:ホストの init のみ 1. コンテナのは1以外
– コンテナから他のコンテナ、ホストのプロセスは参照不
可
• IPC (Inter-Process Communication)
– ホスト、各コンテナで独自のIPC空間を持つ
– Pipe, Semaphore, Shared memory 等
– 例:ipcsの出力結果が各コンテナで異なる
参考:http://wiki.openvz.org/WP/What_are_containers
namespace
33
34. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
Networking , UTS
• network
– network namespace毎に loopback device を持ち、
任意の物理・仮想ネットワークデバイスを追加可能
– コンテナ毎にIPアドレス、ルーティング、ソケット、
フィルタ等を独立させるために利用
• UTS
– コンテナが独自に
ホスト名を管理可能
struct new_utsname {
char sysname[__NEW_UTS_LEN + 1];
char nodename[__NEW_UTS_LEN + 1];
char release[__NEW_UTS_LEN + 1];
char version[__NEW_UTS_LEN + 1];
char machine[__NEW_UTS_LEN + 1];
char domainname[__NEW_UTS_LEN + 1];
};
namespace
34
36. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
[root@ovz01 ~]# ls /proc
1 14 1721 2017 32 44 63 8134 913 cmdline keys slabinfo
10 1410 1733 2019 33 45 64 8147 914 cpt kmsg softirqs
10111 1439 1741 2021 34 46 65 8154 915 cpuinfo kpagecount stat
10113 1453 18 2023 35 460 66 8161 916 crypto kpageflags swaps
10114 1471 1817 21 36 47 67 8162 917 devices loadavg sys
10137 1499 1833 22 367 48 68 8491 918 diskstats locks sysrq-trigger
10140 15 1841 23 368 49 69 8511 919 dma mdstat sysvipc
10171 1500 1849 24 369 5 7 8519 920 driver meminfo timer_list
10174 1501 1857 246 37 50 730 8522 921 execdomains misc timer_stats
10263 1502 1868 25 370 51 74 8527 922 fairsched modules tty
10534 1506 1881 259 371 52 75 8598 963 fairsched2 mounts uptime
10535 16 19 26 38 53 76 8599 9802 fb mtd user_beancounters
10536 1600 1942 260 39 54 7604 8600 9824 filesystems mtrr version
10561 1611 1943 262 4 55 7605 8776 9832 fs net vmallocinfo
11 1636 1944 263 40 56 7606 889 9835 interrupts pagetypeinfo vmstat
111 1645 1966 27 41 58 77 9 9840 iomem partitions vz
12 1646 2 28 42 59 7774 9099 acpi ioports rst zoneinfo
1289 1674 20 29 43 6 79 9112 bc irq sched_debug
1290 1685 2000 3 4301 60 8 9119 buddyinfo kallsyms schedstat
13 17 2013 30 4303 61 80 9126 bus kcore scsi
1384 1705 2015 31 4304 62 81 9127 cgroups key-users self
[root@ct100 ~]# ls /proc
1 476 504 566 635 devices fs meminfo partitions sys user_beancounters
116 489 546 571 cgroups fairsched kmsg modules self sysrq-trigger version
2 496 555 615 cmdline fairsched2 loadavg mounts stat sysvipc vmstat
3 503 563 616 cpuinfo filesystems locks net swaps uptime vz
[root@ct200 ~]# ls /proc
1 451 479 517 564 devices fs meminfo partitions sys user_beancounters
128 464 497 522 cgroups fairsched kmsg modules self sysrq-trigger version
2 471 506 548 cmdline fairsched2 loadavg mounts stat sysvipc vmstat
3 478 514 549 cpuinfo filesystems locks net swaps uptime vz
namespaceホスト
CT100
CT200
36
37. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
[root@ovz01 ebiken]# ls /sys/devices/
LNXSYSTM:00 cpu pci0000:00 platform pnp0 software system
tracepoint virtual
[root@ovz01 ebiken]# ls /sys/devices/virtual/
bdi cpuid graphics input misc net thermal usbmon vtconsole
block dmi hwmon mem msr raw tty vc vzctl
[root@ovz01 ebiken]# ls /sys/devices/virtual/net/
lo venet0 veth100.0 vzbr0
namespace
[root@ct100 ~]# ls /sys/devices/
virtual
[root@ct100 ~]# ls /sys/devices/virtual/
mem net tty
[root@ct100 ~]# ls /sys/devices/virtual/net/
eth0 lo venet0
[root@ct200 ~]# ls /sys/devices/
virtual
[root@ct200 ~]# ls /sys/devices/virtual/
mem net tty
[root@ct200 ~]# ls /sys/devices/virtual/net/
lo venet0
ホスト
CT100
CT200
37
38. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
USER PID COMMAND
root 1 init
root 2 kthreadd
root 3 migration/0
root 4 ksoftirqd/0
root 2301 sshd
ebiken 2305 sshd
ebiken 3304 bash
root 7601 init
root 7602 kthreadd/100
root 7603 khelper/100
51 7604 sendmail
48 8511 httpd
root 8527 crond
root 7604 init
root 7605 kthreadd/100
root 7606 khelper/100
51 8511 sendmail
48 8522 httpd
root 8527 crond
process ID namespace とコンテナの移動
ホスト① ホスト②
USER PID COMMAND
root 1 init
root 2 kthreadd
root 3 migration/0
root 4 ksoftirqd/0
root 4301 sshd
ebiken 4303 sshd
ebiken 4304 bash
root 7604 init
root 7605 kthreadd/100
root 7606 khelper/100
51 8511 sendmail
48 8522 httpd
root 8527 crond
38
39. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
USER PID COMMAND
root 1 init
root 2 kthreadd
root 3 migration/0
root 4 ksoftirqd/0
root 2301 sshd
ebiken 2305 sshd
ebiken 3304 bash
root 7601 init
root 7602 kthreadd/100
root 7603 khelper/100
51 7604 sendmail
48 8511 httpd
root 8527 crond
root 7604 init
root 7605 kthreadd/100
root 7606 khelper/100
51 8511 sendmail
48 8522 httpd
root 8527 crond
process ID namespace とコンテナの移動
!! PIDの衝突 !!
ホスト① ホスト②
USER PID COMMAND
root 1 init
root 2 kthreadd
root 3 migration/0
root 4 ksoftirqd/0
root 4301 sshd
ebiken 4303 sshd
ebiken 4304 bash
root 7604 init
root 7605 kthreadd/100
root 7606 khelper/100
51 8511 sendmail
48 8522 httpd
root 8527 crond
39
40. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
USER PID COMMAND
root 1 init
root 2 kthreadd
root 3 migration/0
root 4 ksoftirqd/0
root 4301 sshd
ebiken 4303 sshd
ebiken 4304 bash
root 7604 init
root 7605 kthreadd/100
root 7606 khelper/100
51 8511 sendmail
48 8522 httpd
root 8527 crond
root 1 init
root 2 kthreadd/100
root 3 khelper/100
smmsp 555 sendmail
apache 566 httpd
root 571 crond
USER PID COMMAND
root 1 init
root 2 kthreadd
root 3 migration/0
root 4 ksoftirqd/0
root 2301 sshd
ebiken 2305 sshd
ebiken 3304 bash
root 7601 init
root 7602 kthreadd/100
root 7603 khelper/100
51 7604 sendmail
48 8511 httpd
root 8527 crond
process ID namespace とコンテナの移動
root 1 init
root 2 kthreadd/100
root 3 khelper/100
smmsp 555 sendmail
apache 566 httpd
root 571 crond
ホスト① ホスト②
40
41. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
cgroups
• リソース管理のフレームワーク
– プロセスのグループ化
• 子プロセスも同じグループに
– 階層状にグループ化
• Group1 :CPU1/2割り当て
• > Group1a:CPU1割り当て
• > Group1b:CPU2割り当て
• 実際の制御はサブシステムが実施
– 利用量のモニタリング
– アクセス制限
– 利用制限
cgroups
41
42. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
/proc/vz/container
cgroups
42
[root@ovz01 ~]# ls /proc/vz/container
100 devices.allow release_agent
200 devices.deny self_destruction
cgroup.event_control devices.list tasks
cgroup.procs notify_on_release
[root@ovz01 ~]# ls /proc/vz/container/100
cgroup.event_control devices.allow notify_on_release
cgroup.procs devices.deny self_destruction
tasks devices.list freezer.state
[root@ovz01 ~]# cat /proc/vz/container/100/cgroup.procs
7604
7605
7606
7774
8134
...
コンテナに含まれるプロセス
43. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
[root@ovz01 ~]# cd /proc/vz/container/100
[root@ovz01 100]# while read pss; do ps ax -o user,pid,stime,comm
| grep "$pss" | grep -v "grep"; done < cgroup.procs
[root@ovz01 100]# vzctl exec 100 ps ax -o user,pid,stime,comm
USER PID STIME COMMAND
root 1 15:04 init
root 2 15:04 kthreadd/100
root 3 15:04 khelper/100
root 116 15:04 udevd
root 476 15:04 rsyslogd
root 489 15:04 sshd
root 496 15:04 xinetd
root 503 15:04 saslauthd
root 504 15:04 saslauthd
root 546 15:09 sendmail
smmsp 555 15:14 sendmail
root 563 15:14 httpd
apache 566 15:14 httpd
root 571 15:14 crond
USER PID STIME COMMAND
root 7604 21:04 init
root 7605 21:04 kthreadd/100
root 7606 21:04 khelper/100
root 7774 21:04 udevd
root 8134 21:04 rsyslogd
root 8147 21:04 sshd
root 8154 21:04 xinetd
root 8161 21:04 saslauthd
root 8162 21:04 saslauthd
root 8491 21:09 sendmail
51 8511 21:14 sendmail
root 8519 21:14 httpd
48 8522 21:14 httpd
root 8527 21:14 crond
ホスト コンテナ内
namespace
43
44. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
USER PID STIME COMMAND
root 1 15:04 init
root 2 15:04 kthreadd/100
root 3 15:04 khelper/100
root 116 15:04 udevd
root 476 15:04 rsyslogd
root 489 15:04 sshd
root 496 15:04 xinetd
root 503 15:04 saslauthd
root 504 15:04 saslauthd
root 546 15:09 sendmail
smmsp 555 15:14 sendmail
root 563 15:14 httpd
apache 566 15:14 httpd
root 571 15:14 crond
USER PID STIME COMMAND
root 7604 21:04 init
root 7605 21:04 kthreadd/100
root 7606 21:04 khelper/100
root 7774 21:04 udevd
root 8134 21:04 rsyslogd
root 8147 21:04 sshd
root 8154 21:04 xinetd
root 8161 21:04 saslauthd
root 8162 21:04 saslauthd
root 8491 21:09 sendmail
51 8511 21:14 sendmail
root 8519 21:14 httpd
48 8522 21:14 httpd
root 8527 21:14 crond
[root@ovz01 ebiken]# grep ^root /etc/passwd
root:x:0:0:root:/root:/bin/bash
[root@ovz01 ebiken]# vzctl exec 100 grep ^root /etc/passwd
root:x:0:0:root:/root:/bin/bash
[ebiken@ovz01 ~]$ grep 51 /etc/passwd
[ebiken@ovz01 ~]$ grep 48 /etc/passwd
[root@ovz01 100]# vzctl exec 100 egrep "smmsp¥|apache" /etc/passwd
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
namespace
ホスト コンテナ内
44
45. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
プロセス ⇒ cgroup
[root@ovz01 ebiken]# ps ax -o user,pid,stime,comm | grep ini[t]
root 1 Nov16 init
root 7604 21:04 init
root 8598 21:44 init
[root@ovz01 100]# cat /proc/1/cgroup
3:freezer,devices,name=container:/
2:cpuacct,cpu,cpuset,name=fairsched:/0
1:blkio,name=beancounter:/0
[root@ovz01 100]# cat /proc/7604/cgroup
3:freezer,devices,name=container:/100
2:cpuacct,cpu,cpuset,name=fairsched:/100
1:blkio,name=beancounter:/100
[root@ovz01 100]# cat /proc/8598/cgroup
3:freezer,devices,name=container:/200
2:cpuacct,cpu,cpuset,name=fairsched:/200
1:blkio,name=beancounter:/200
cgroups
/proc/<id>/cgroup
45
47. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZのネットワークタイプ
venet veth
Layer Layer 3 (IP) Layer 2 (Ethernet)
受信 venet0 経由 Bridge経由
L2アドレス
(ARP返信)
無し(*1) veth毎(*2)
(*1) Proxy ARPにより宛先インタフェースのMACアドレスを返信
(*2) veth毎に異なるMACアドレスを返信
47
48. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
Logical Topology: venet
CT100
CT200
p2p1
p2p2
venet0:0
venet0
venet0:1
venet0:0
Kernel
A
B
C
ARP request : IP-A
ARP reply : MAC-p2p1
ARP request : IP-B
ARP request : IP-C
ARP reply : MAC-p2p2
Proxy Arp
48
49. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
venet のパケット転送(補足)
static const struct net_device_ops
venet_netdev_ops = {
.ndo_start_xmit = venet_xmit
...
venet_xmit () {
rcv = skb->owner_env->_venet_dev;
skb->pkt_type = PACKET_HOST;
skb->dev = rcv;
netif_rx(skb); drivers/net/venet_core.c
49
50. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
Logical Topology: veth
CT100
CT200
eth0
Kernel
A veth0
br0
p2p1
eth0 veth1
B
ARP request : IP-A
ARP reply : MAC-A
ARP request : IP-B
ARP reply : MAC-B
Linux
Bridge
50
51. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
[root@ovz01 ~]# ifconfig
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet6 addr: fe80::1/128 Scope:Link
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:384 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:19584 (19.1 KiB) TX bytes:0 (0.0 b)
[root@ovz01 ~]# vzctl exec 100 ifconfig
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0
Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:96 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:4896 (4.7 KiB)
venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.10.0.100 P-t-P:10.10.0.100 Bcast:10.10.0.255
Mask:255.255.255.0
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
ホスト
コンテナ
ifconfig output : venet
51
52. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
[root@ovz01 ~]# ifconfig
veth100.0 Link encap:Ethernet HWaddr 00:18:51:1D:38:B4
inet6 addr: fe80::218:51ff:fe1d:38b4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:2 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:552 (552.0 b) TX bytes:172 (172.0 b)
[root@ovz01 ~]# vzctl exec 100 ifconfig
eth0 Link encap:Ethernet HWaddr 00:18:51:C2:FD:7B
inet addr:10.10.0.110 Bcast:10.10.0.255 Mask:255.255.255.0
inet6 addr: fe80::218:51ff:fec2:fd7b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:172 (172.0 b) TX bytes:552 (552.0 b)
ホスト
コンテナ
ifconfig output : veth
52
53. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
ホスト コンテナ
eth/veth/venet 処理パス比較
App
NIC
routing
TCP/UDP
App
NIC
routing (CT)
TCP/UDP
bridge
veth
App
NIC
routing (CT)
TCP/UDP
routing
venet
53
55. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
Kernel
Linux
Bridge
CT100 p2p1venet0venet0:0
CT200
p2p1
eth0 veth1
br0
OpenVZ
インストール
CT作成
venet設定
Bridge作成
veth設定
OpenVZ, veth/venet 設定方法
55
56. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZ, veth/venet 設定方法
OpenVZ
インストール
CT作成
venet設定
Bridge作成
veth設定
1. コンテナのテンプレートを取得
# pwd
/vz/template/cache
# wget
http://download.openvz.org/template/precreated/centos-6-
x86-devel.tar.gz
2. コンテナ作成&メモリ設定
# vzctl create 100 --hostname ct100
--ostemplate centos-6-x86-devel
# vzctl set 100 --ram 1024M --swap 1024M --save
3. IP アドレス、nameserver設定(CT内venet自動生成)
# vzctl set 100 --ipadd 10.10.0.1
--nameserver 8.8.8.8 --save
4. コンテナ開始
# vzctl start 100
http://wiki.openvz.org/Quick_installation
56
57. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZ, veth/venet 設定方法
CT作成
venet設定
Bridge作成
veth設定
OpenVZ
インストール
1. bridge-utilsのインストール
[host]# yum install bridge-utils
2. Bridge (vzbr0) の作成
[host]# cd /etc/sysconfig/network-scripts/
[host]# vi ifcfg-vzbr0
DEVICE="vzbr0"
ONBOOT="yes"
TYPE="Bridge"
BOOTPROTO="static"
NETMASK=255.255.255.0
IPADDR=10.10.0.10
3. eth0 (*) の Bridge への参加+IPコメントアウト
[host]# vi ifcfg-eth0
#IPADDR=10.10.0.1
#NETMASK=255.255.255.0
BRIDGE="vzbr0"
4. [host]# service network restart
http://wiki.openvz.org/Quick_installation
(*) ホスト側物理NIC
57
58. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZ, veth/venet 設定方法
CT作成
venet設定
Bridge作成
veth設定
OpenVZ
インストール
http://wiki.openvz.org/Quick_installation
5. コンテナへの veth 追加
[host]# vzctl set 100 --netif_add eth0,,,,vzbr0 --save
Configure veth devices: veth100.0
CT configuration saved to /etc/vz/conf/100.conf
6. コンテナへ入り eth0(ホストのveth100.0)設定
[host]# vzctl enter 100
[CT]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="none"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=10.10.0.110
NETMASK=255.255.240.0
[CT]# service network restart
7. Bridge (vzbr0) へ veth (veth100.0) を追加
[host]# brctl addif vzbr0 veth100.0
58
59. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZ, veth/venet 設定方法ホストからの見え方
[host]# brctl show
bridge name bridge id STP enabled interfaces
vzbr0 8000.0018511d38b4 no eth0
veth100.0
[host]# ifconfig
... snip ...
veth100.0 Link encap:Ethernet HWaddr 00:18:51:1D:38:B4
inet6 addr: fe80::218:51ff:fe1d:38b4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33 errors:0 dropped:0 overruns:0 frame:0
TX packets:51 errors:0 dropped:5 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2148 (2.0 KiB) TX bytes:3316 (3.2 KiB)
vzbr0 Link encap:Ethernet HWaddr 00:18:51:1D:38:B4
inet addr:10.10.0.10 Bcast:10.10.0.255 Mask:255.255.255.0
inet6 addr: fe80::218:51ff:fe1d:38b4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:248 errors:0 dropped:0 overruns:0 frame:0
TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:12624 (12.3 KiB) TX bytes:3046 (2.9 KiB)
59
60. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
OpenVZ, veth/venet 設定方法
[CT]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:18:51:C2:FD:7B
inet addr:10.10.0.110 Bcast:10.10.0.255 Mask:255.255.255.0
inet6 addr: fe80::218:51ff:fec2:fd7b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:55 errors:0 dropped:0 overruns:0 frame:0
TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3524 (3.4 KiB) TX bytes:2148 (2.0 KiB)
... snip ...
venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:168 (168.0 b) TX bytes:5064 (4.9 KiB)
venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.10.0.100 P-t-P:10.10.0.100 Bcast:10.10.0.255 Mask:255.255.255
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1
コンテナからの見え方
60
62. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
eth/veth/venet性能比較:測定環境
Kernel
Linux
Bridge
CT100 p2p1venet0venet0:0
Host p2p1
CT100
p2p1
eth0 veth1
br0
Linux
running
pktgen
62
63. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
eth/veth/venet 性能比較 (pps)
63
0
200,000
400,000
600,000
800,000
1,000,000
1,200,000
60 124 252 508 1020 1276 1514
eth0
veth
venet
Packet Size = Bytes
64. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
eth/veth/venet 性能比較 (Mbps)
64
0
1,000
2,000
3,000
4,000
5,000
6,000
7,000
8,000
9,000
10,000
60 124 252 508 1020 1276 1514
eth0
veth
venet
Packet Size = Bytes
65. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
仮想化プラットフォームによる性能比較
65
Benchmark Description
Response Time
Microbenchmark demonstrating latency issues of interactive
applications in virtualized and loaded systems (netperf RR in various
conditions).
Network Throughput 10Gbit simple network throughput comparison using netperf test.
LAMP
Linux Apache+MySql+PHP (LAMP) stack benchmark in multiple
simultaneously running virtualization instances.
vConsolidate-UP
UP configuration of Intel vConsolidate server consolidation benchmark
(Java+Apache+MySQL workloads).
vConsolidate-SMP SMP configuration of Intel vConsolidate server consolidation benchmark
(Java+Apache+MySQL workloads).
Microbenchmarks Various microbenchmarks like context switch, system call, etc. Plus
Unixbench resuls.
@ OpenVZ Wiki
http://wiki.openvz.org/Performance
66. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
ネットワーク送受信性能比較 (netperf)
66
Performance/Network Throughput from OpenVZ Wiki
http://wiki.openvz.org/Performance/Network_Throughput
コンテナ
サイコー
67. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05) 67
I spent about a year leading SWsoft QA team, mostly testing
Linux kernels, and trying to make sure test results are sane
and reproducible (not dependent on the moon phase etc).
http://openvz.livejournal.com/43275.html
By Kir Kolyshkin(意訳)
テスト結果なんて
お月様次第だぜ!
But...
!!性能テストはご自分の環境で!!
68. 第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)第2回 コンテナ型仮想化の情報交換会@東京 (2013/10/05)
参考資料一覧
• OpenVZ Wiki - http://wiki.openvz.org/
• CRIU - http://www.criu.org/
• Linux Kernel Newbies / Kernel Changes -
http://kernelnewbies.org/LinuxChanges
• O’Reilly, Linux Device Drivers (3rd Edition)
• O’Reilly, Understanding Linux Network Internals
• O’Reilly, Understanding the Linux Kernel (3rd Edition)
• “Adding Generic Process Containers to the Linux Kernel”, Paul B. Menage @
Google / Balbir Singh and Srivatsa Vaddagiri @ IBM
• Managing system resources on Red Hat Enterprise Linux 6.
– https://access.redhat.com/knowledge/docs/en-
US/Red_Hat_Enterprise_Linux/6/html-single/Resource_Management_Guide/
68