可以参考下官方的教程 https://openvz.org/Quick_Installation_CentOS_6
第一步:首先下载openvz.repo
wget -P /etc/yum.repos.d/ https://download.openvz.org/openvz.repo
然后只要用下面这个安装。
yum install vzctl
就会有下面依赖都会装起来
====================================================================================================== Package Arch Version Repository Size ====================================================================================================== Installing: vzctl x86_64 4.9.4-1 openvz-utils 145 k Installing for dependencies: rsync x86_64 3.0.6-12.el6 base 335 k vzctl-core x86_64 4.9.4-1 openvz-utils 289 k vzkernel x86_64 2.6.32-042stab128.2 openvz-kernel-rhel6 35 M vzquota x86_64 3.1-1 openvz-utils 93 k vzstats noarch 0.5.5-1 openvz-utils 23 k Transaction Summary ====================================================================================================== Install 6 Package(s)
安装完成后,有一些重要信息值得阅读
Adding the following option to /etc/modprobe.d/openvz.conf: options nf_conntrack ip_conntrack_disable_ve0=0 This change will take effect only after the next reboot. NOTE: if you need to change this setting, edit /etc/modprobe.d/openvz.conf now. DO NOT REMOVE the line, or it will be re-added! ============================================================================ vz-postinstall: /etc/sysconfig/selinux: set SELINUX = disabled vz-postinstall: /etc/yum.conf: add exclude=kernel Invalid UUID , aborting
最后重启CentOS6.9系统
第二步:开启包转发
vi /etc/sysctl.conf
然后打开
net.ipv4.ip_forward = 1
这样主机的路由才会通
开机教程,这样开的是一台全功能的centos7
vzctl create 241018 --hostname yy241018 --ostemplate centos-7-x86_64 --ipadd 10.42.241.18 --config basic
也可以开迷你版本
也可以开ubuntu16.04(这个没迷你版)
vzctl create 241019 --hostname yy241019 --ostemplate ubuntu-16.04-x86_64 --ipadd 10.42.241.19 --config basic
这个ubuntu16.04开机无法SSH登录,换个14.04的
vzctl create 241020 --ostemplate ubuntu-14.04-x86_64-minimal --ipadd 10.42.241.20 --config basic
这样就创建一台OVZ,这个OVZ的模板是自动下载的
--2018-04-04 10:28:00-- http://download.openvz.org/template/precreated/centos-7-x86_64.tar.gz Resolving download.openvz.org... 185.231.241.69 Connecting to download.openvz.org|185.231.241.69|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 221597800 (211M) [application/x-gzip] Saving to: `/vz/template/cache/centos-7-x86_64.tar.gz'
但是如果ploop没装会报错的
Can't load ploop library: libploop.so: cannot open shared object file: No such file or directory Please install ploop packages! Alternatively, if you can't or don't want to use ploop, please add --layout simfs option, or set VE_LAYOUT=simfs in /etc/vz/vz.conf Creation of container private area failed
以上就是报错的代码