debianインストールlxc

3052 ワード

コンパイル
apt-get install autoconf automake pkg-config make gcc debootstrap libvirt-bin bridge-utils

git clone https://github.com/lxc/lxc.git
cd lxc

./autogen.sh 
./configure     OR  ./configure --prefix=/usr/local
make 
make install
lxc.so が見つからない場合
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
  
ln -s  /usr/local/lib/liblxc.so.1 /usr/lib/liblxc.so.1


cgroup
変更/etc/fstab:
cgroup /sys/fs/cgroup cgroup defaults 0 0

  
mount /sys/fs/cgroup

ブリッジの追加(ubuntu省略、ubuntuデフォルトブリッジ搭載)/etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual
   pre-up   ifconfig $IFACE up
   pre-down ifconfig $IFACE down


auto br0
allow-hotplug br0
iface br0 inet static
    bridge_ports eth0
    address 192.168.100.1
    netmask 255.255.255.0
    gateway 192.168.0.1



検査lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-3.12-0.bpo.1-amd64
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
Network namespace: enabled
Multiple /dev/pts instances: enabled

--- Control groups ---
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled

--- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
File capabilities: enabled

Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/local/bin/lxc-checkconfig


lxcファイル位置グローバル:
/usr/local/share/lxc/config/debian.common.conf

デフォルトテンプレート:
/usr/local/etc/lxc/default.conf

コンテナファイルのパス:
/usr/local/var/lib/lxc/test/config 

マルチNIC構成

lxc.network.mtu = 1500
lxc.network.type = veth
lxc.network.name = eth0
lxc.network.link = br0
lxc.network.ipv4 = 192.168.0.2/16
lxc.network.flags = up

lxc.network.type = veth
lxc.network.link = br1
lxc.network.ipv4 = 10.10.0.2/16
lxc.network.name = eth1
lxc.network.flags = up



リファレンス


http://foaa.de/old-blog/2010/05/lxc-on-debian-squeeze/trackback/index.html