安装lxc:
yum install libcap libcap-devel debootstrap -y
wget
tar -zxvf lxc-0.7.5.tar.gz
cd lxc-0.7.5
./configure
make&& make install
cd ..
mkdir /cgroup
vi /etc/fstab
cgroup /cgroup cgroup defaults 0 0
mount /cgroup
lxc-checkconfig
配置网络:
# cat ifcfg-br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.2.17
NETMASK=255.255.255.0
DNS2=202.106.196.115
TYPE=Bridge
GATEWAY=192.168.2.1
DNS1=202.106.0.20
cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BRIDGE=br0
如果有的话,禁用
service NetworkManager stop
chkconfig --level 35 NetworkManager off
vim /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
net.bridge.bridge-nf-filter-vlan-tagged = 0
sysctl -p
安装虚拟机
mkdir -p /home/zone/zone01
/usr/local/lib/lxc/templates/lxc-debian -p /home/zone/zone01
lxc-debina脚本要修改一下,要不会有些错误arch=$2 修改成arch=amd64,当然i386也可以
vi /home/zone/zone01/config
...
#network
lxc.utsname = zone01
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
#lxc.network.hwaddr = 00:FF:12:34:56:78
lxc.network.ipv4 = 192.168.2.18/24
lxc-create -n zone01 -f /hoem/zone/zone01/config
lxc-start -n zone01 -d
//启动
lxc-console -n zone01
//进入
阅读(1570) | 评论(0) | 转发(0) |