欢迎来到CentOS问吧,从这里您能进入CentOS世界!

CentOS问吧

当前位置: 主页 > CentOS虚拟化 > OpenVZ >

在CentOS5.6安装OpenVZ

时间:2011-07-11 09:33来源:未知 作者:admin 点击:
1.安装 执行安装 cd /etc/yum.repos.d wget http://download.openvz.org/openvz.repo rpm import http://download.openvz.org/RPM-GPG-Key-OpenVZ yum install ovzkernel yum install vzctl vzquota 修改grub,从open Kernel引导系统,如:

1.安装
执行安装
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ
yum install ovzkernel
yum install vzctl vzquota
修改grub,从open Kernel引导系统,如:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS OpenVZ (2.6.18-238.5.1.el5.028stab085.5)
root (hd0,0)
kernel /vmlinuz-2.6.18-238.5.1.el5.028stab085.5 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-238.5.1.el5.028stab085.5.img
title CentOS (2.6.18-238.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-238.el5.img

对sysctl做一些小修改
vi /etc/sysctl.conf
net.ipv4.ip_forward = 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
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1
停用selinux
cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX=disabled
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted – Only targeted network daemons are protected.
# strict – Full SELinux protection.
SELINUXTYPE=targeted

# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0

重启系统

2.使用openvz
下载一个VPS模板
cd /vz/template/cache
wget http://download.openvz.org/template/precreated/centos-5-x86.tar.gz
根据模板创建虚拟机
vzctl create 101 –ostemplate centos-5-x86 –config basic
vzctl set 101 –onboot yes –save ###设为开机启动
vzctl set 101 –hostname test.example.com –save###设主机名
vzctl set 101 –ipadd 192.168.0.101 –save###设IP地址
vzctl set 101 –numothersock 120 –save ###设打开的sockets为120
vzctl set 101 –nameserver 8.8.8.8 –nameserver 8.8.4.4 –save ###设nameserver

vzctl start 101 ###启动VPS
vzctl exec 101 passwd ###设置VPS的root密码
vzctl stop 101 ###关掉VPS
vzctl restart 101 ###重启VPS

vzlist -a ###查看启动的VPS列表

vzctl exec 101 passwd 这条命令可以换成任何VPS服务器中任意指令,在物理主机中显示

(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
验证码: 点击我更换图片
栏目列表
推荐内容