海运的博客

Centos6服务器安装配置OpenVZ环境

发布时间:July 4, 2012 // 分类:虚拟化 // No Comments

OpenVZ是基于操作系统层面的虚拟化环境,所有虚拟机共享服务器资源,同等配置下比XEN能开较多的虚拟机,因此很多商家使用OpenVZ销售低端VPS产品。
OpenVZ安装:

#https://www.haiyun.me
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import  http://download.openvz.org/RPM-GPG-Key-OpenVZ
yum install vzkernel vzctl vzquota

配置内核参数:

vim /etc/sysctl.conf 
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

关闭SELinux避免不必要的麻烦:

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

修改GRUB配置以OpenVZ内核启动,一般OpenVZ安装后会自动配置。

cat /boot/grub/menu.lst 
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title OpenVZ (2.6.32-042stab057.1)
    root (hd0,0)

重启系统加载OpenVZ内核:

reboot

新建和管理OpenVZ虚拟机,为方便直接使用OpenVZ官方提供的模板新建虚拟机:

mkdir -p /vz/template/cache
cd /vz/template/cache
wget -c http://download.openvz.org/template/precreated/ubuntu-12.04-x86.tar.gz #使用ubuntu吧,这个模板最小。。。
vzctl create 101 --ostemplate ubuntu-12.04-x86 --ipadd 192.168.1.254 --host www.haiyun.me  #使用模板ubuntu-12.04创建ID为100的虚拟机

OpenVZ虚拟机设置管理:

vzctl set 101 --onboot yes --save #设置开机自动启动
vzctl set 101 --hostname www.haiyun.me --save #设置主机名
vzctl set 101 --ipadd 192.168.1.254 --save #设置IP地址
vzctl set 101 --nameserver 192.168.1.1 --save #设置DNS服务器
vzctl set 101 --diskspace 5G:5G --save #硬盘限制
vzctl set 101 --userpasswd user:passwd #设置用户、密码
vzctl exec 101 service ssh status #查看虚拟机ssh是否在运行
vzctl start 101 #启动ID为101的虚拟机
vzctl destroy 101 #删除ID为101的虚拟机
vzctl enter 101 #进入101虚拟机的Shell,可见OpenVZ下管理员掌控一切
vzlist -a #查看所有虚拟机列表
vzcalc -v 101 #查看虚拟机占用的资源

标签:openvz, openvz虚拟化, openvz安装管理, centos安装openvz, openvz设置

评论已关闭

分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...