系统环境:
[root@openvz ~]# cat /etc/redhat-releaseCentOS release 6.5 (Final)[root@openvz ~]# uname -aLinux openvz 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux[root@openvz ~]# lsb_release -aLSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarchDistributor ID: CentOSDescription: CentOS release 6.5 (Final)Release: 6.5Codename: Final
开始安装:
[root@openvz ~]# cd /etc/yum.repos.d/[root@openvz yum.repos.d]# wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo[root@openvz yum.repos.d]# rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ[root@openvz yum.repos.d]# yum install vzkernel[root@openvz yum.repos.d]# echo "SELINUX=disabled" > /etc/sysconfig/selinux[root@openvz yum.repos.d]# cat /etc/sysctl.conf |grep -v "#"|grep -v ^$net.ipv4.ip_forward = 1net.ipv6.conf.default.forwarding = 1net.ipv6.conf.all.forwarding = 1net.ipv4.conf.default.proxy_arp = 0net.ipv4.conf.all.rp_filter = 1net.ipv4.conf.default.send_redirects = 1net.ipv4.conf.all.send_redirects = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 1kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1net.bridge.bridge-nf-call-ip6tables = 0net.bridge.bridge-nf-call-iptables = 0net.bridge.bridge-nf-call-arptables = 0kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296[root@openvz yum.repos.d]# sysctl -p[root@openvz yum.repos.d]# yum install vzctl vzquota ploop[root@openvz yum.repos.d]# reboot
openvz安装完成
下载系统模板
模板在这里http://openvz.org/Download/template/cache
[root@openvz ~]# uname -aLinux openvz 2.6.32-042stab085.20 #1 SMP Fri Mar 21 19:07:05 MSK 2014 x86_64 x86_64 x86_64 GNU/Linux[root@openvz ~]# cd /vz/template/cache/[root@openvz cache]# wget http://download.openvz.org/template/precreated/centos-5-x86.tar.gz[root@openvz cache]# vzctl create 1 --ostemplate centos-5-x86[root@openvz cache]# vzctl set 1 --onboot yes --save[root@openvz cache]# vzctl set 1 --ipadd 172.16.10.21 --save[root@openvz cache]# vzctl set 1 --nameserver 114.114.114.114 --save[root@openvz cache]# vzctl set 1 --hostname centos5.nowsafe.org --save[root@openvz cache]# vzctl set 1 --diskspace 10G:10G --save[root@openvz cache]# vzctl start 1 启动为1的虚拟机Starting container...Container is mountedAdding IP address(es): 172.16.10.21Setting CPU units: 1000Container start in progress...[root@openvz cache]# vzctl exec 1 passwd 修改序号为1的虚拟机ROOT密码New UNIX password: redhatBAD PASSWORD: it is based on a dictionary wordRetype new UNIX password: redhatChanging password for user root.passwd: all authentication tokens updated successfully.[root@openvz cache]# vzlist 查看序号为1的虚拟机 CTID NPROC STATUS IP_ADDR HOSTNAME 1 21 running 172.16.10.21 centos5.nowsafe.org [root@openvz cache]# vzcalc -v 1 查看序号1 占用的资源[root@openvz cache]# ping 172.16.10.21PING 172.16.10.21 (172.16.10.21) 56(84) bytes of data.64 bytes from 172.16.10.21: icmp_seq=1 ttl=64 time=0.276 ms64 bytes from 172.16.10.21: icmp_seq=2 ttl=64 time=0.041 ms[root@openvz cache]# vzctl enter 1 进入 guest 相当于 xen 的 xm console ,不过从 guest 退出来不需特殊按键直接 exit 就可以退出entered into CT 1[root@centos5 /]# uname -aLinux centos5.nowsafe.org 2.6.32-042stab085.20 #1 SMP Fri Mar 21 19:07:05 MSK 2014 i686 i686 i386 GNU/Linux[root@centos5 /]# cat /etc/redhat-releaseCentOS release 5.10 (Final)
OK大概先到这里