debian 安装 lxc

编译

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 

多网卡配置

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

你可能感兴趣的:(debian 安装 lxc)