LXC (2)
気を取り直して,Plamo Linux 4.71 で lxc を.
準備
lxc-0.6.4.tar.gz をダウンロード.展開.
カーネル再構築
標準カーネルではオプションが足りないので,有効にする.
lxc アーカイブ中の doc/lxc.7 を見ると,以下を有効にせよ,と書いてあります.README にも記述があるが,以下と違って足りない.README の通りにやっても動かなかった気がします.ただ,色々試行錯誤してたので,動くのかもしれません.
* General setup * Control Group support -> Namespace cgroup subsystem -> Freezer cgroup subsystem -> Cpuset support -> Simple CPU accounting cgroup subsystem -> Resource counters -> Memory resource controllers for Control Groups * Group CPU scheduler -> Basis for grouping tasks (Control Groups) * Namespaces support -> UTS namespace -> IPC namespace -> User namespace -> Pid namespace -> Network namespace * Device Drivers * Character devices -> Support multiple instances of devpts * Network device support -> MAC-VLAN support -> Virtual ethernet pair device * Networking * Networking options -> 802.1d Ethernet Bridging * Security options -> File POSIX Capabilities
3,4c3,4 # diff /boot/config-2.6.31.6-plamoSMP /usr/src/linux/.config < # Linux kernel version: 2.6.31.5 < # Tue Nov 3 09:12:21 2009
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
cgroup を有効に
# mkdir /cgroup # mount -t cgroup cgroup /cgroup
最小限の機能のコンテナを作製
コンテナ内で sshd が動く最小限のものを作ってみます.まず,ホストで動いている sshd を停止します.
bash-3.2# lxc-sshd create What is the container name ? [sshd] What hostname do you wish for this container ? [sshd] What IP address do you wish for this container ? [172.20.0.20/24] 192.168.0.8/24 no configuration path defined ! Done. You can run your container with: 'lxc-execute -n sshd /usr/sbin/sshd &' bash-3.2# lxc-execute -n sshd /usr/sbin/sshd & [1] 5906 bash-3.2# lxc-info -n sshd 'sshd' is RUNNING
母艦で ps でみると,
bash-3.2# ps aux | grep sshd root 5885 0.0 0.0 1772 628 pts/0 S 19:14 0:00 lxc-execute -n sshd /usr/sbin/sshd root 5886 0.0 0.0 1772 452 pts/0 S 19:14 0:00 /usr/libexec/lxc-init -- /usr/sbin/sshd root 5888 0.0 0.0 3800 968 ? Ss 19:14 0:00 /usr/sbin/sshd root 5899 0.0 0.0 2952 864 pts/0 R+ 19:15 0:00 grep sshd
コンテナ内に入るために ssh ログインすると,
bash-3.2# slogin localhost Password: Last login: Tue Dec 15 18:58:40 2009 from localhost Linux 2.6.31.6-plamoSMP-PAE-2 (Plamo-4.7) #8 SMP PREEMPT Tue Dec 15 14:22:54 JST 2009 enterprise:~# ps ax PID TTY STAT TIME COMMAND 1 pts/0 S+ 0:00 /usr/libexec/lxc-init -- /usr/sbin/sshd 3 ? Ss 0:00 /usr/sbin/sshd 4 ? Ss 0:00 sshd: root@pts/3 7 pts/3 Ss 0:00 -bash 17 pts/3 R+ 0:00 ps ax
と,これだけしかプロセスが見えません.
本当はコンテナにもアドレスを与えて実験しないとダメですが,とりあえずこんな手抜きで.