openvz官网:
https://wiki.openvz.org/Main_Page
openvz7链接:
https://wiki.openvz.org/News/updates#OpenVZ_7.0_GA
openvz镜像地址:
https://mirrors.openvz.org/
ftp://mirror.klaus-uwe.me/openvz/template/precreated/
yum install epel-release -y
yum localinstall -y https://download.openvz.org/virtuozzo/releases/openvz-7.0.3-479/x86_64/os/Packages/o/openvz-release-7.0.3-3.vz7.x86_64.rpm
rpm --import http://repo.virtuozzo.com/vzlinux/security/VZLINUX_GPG_KEY
centos:yum update -y openvz-release
ubuntu:apt-get update -y openvz-release
yum install -y vzkernel prlctl prl-disp-service
reboot
systemctl start vz
modprobe ploop
modprobe pfmt_ploop1
modprobe pfmt_raw
modprobe pio_direct
systemctl stop vz
mv /vz /vz.bak
dd if=/dev/zero of=disk.img bs=10M count=1024
mkfs.ext4 -F disk.img
mkdir /vz
mount -t ext4 -o loop disk.img /vz
cp -r /vz.bak/* /vz
systemctl start vz
modprobe ploop
modprobe pfmt_ploop1
modprobe pfmt_raw
modprobe pio_direct
vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE='eth0:0'
NM_CONTROLLED='yes'
ONBOOT='yes'
IPADDR='10.233.0.1'
NETMASK='255.255.255.0'
service network restart
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
根据网口配置,如果根据ip配置可能会出问题;
如果提示:
iptables v1.4.7: can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded.
vi /etc/modprobe.d/openvz.conf
options nf_conntrack ip_conntrack_disable_ve0=1
替换为
options nf_conntrack ip_conntrack_disable_ve0=0
然后重启
reboot
vzctl create 100 --ostemplate centos-7-x86_64-minimal
vzctl set 100 --onboot yes --ipadd 10.233.0.100 --nameserver 8.8.8.8 --hostname localhost --diskspace 2G:2G --ram 1024G --swap 64M --userpasswd root:locmjj --save
vzctl start 100
openvz管理命令:
vzctl :创建(create),配置vm(set),删除(destroy)
vzlist:查看所有vm; vzlist -a(查看所有虚拟机);
vzpkg:查看安装openvz系统模板;
vzpkg list --available #查看可用的openvz系统模板
openvz7创建vm命令增加prlctl,类似vzctl:
prlctl: create(创建)、set(配置)、destroy(删除)、list(列表);
转载于:https://blog.51cto.com/summer37/2175390