现在虚拟化技术非常流行,本文介绍基于OpenVZ平台下的虚拟化配置安装,以及Vtonf Web界面管理虚拟机应用。本文为简易指导手册,代码不保证100%准确。本文根据英文教程创作演绎。
一、安装OpenVZ
1、第一次在CentOS中添加openVZ repository
打开终端复制以下命令
wget http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
cp openvz.repo /etc.recpo.d
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
cp openvz.repo /etc.recpo.d
2、安装openvz内核
yum install ovzkernel
3、编辑文件 /etc/systcl.conf
打开文件 /etc/systcl.conf
vi /etc/systcl.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.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
4、禁止Selinux
禁止Selinux,打开配置文件
vi /etc/selinux/config
找到以下内容,将SELINUX设置成disabled,如下所设:
SELINUX=disabled
5、安装openvz工具和插件
yum install vzctl vzquota
6、重启openv服务
service vz restart
二、建立虚拟操作系统
现在,我们已经安装好了Openvz,马上去建立一个虚拟操作系统吧。首先下载一下操作系统模板。
本例将使用Slackware模板,其它的操作系统模板你可以查看这里
1、首先建立和进入cache文件夹,本例如下:
mkdir -p /vz/template/cache
cd /vz/template/cache
2、接下来是下载模板
这个步骤可能会花去你很多时间,视网络状况,现在你可以浏览一下OSSS.CN开源社区,呵呵:
wget http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
下载屏幕如下列所示:
[root@localhost cache]# wget http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
--2010-06-27 16:55:33-- http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
Resolving download.openvz.org... 64.131.90.11
Connecting to download.openvz.org|64.131.90.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 39641862 (38M) [application/x-gzip]
Saving to: `slackware-13.0-i386-minimal.tar.gz'
100%[===============================================================>] 39,641,862 4.48M/s in 14s
2010-08-09 16:55:47 (2.71 MB/s) - `slackware-13.0-i386-minimal.tar.gz' saved [39641862/39641862]
--2010-06-27 16:55:33-- http://download.openvz.org/template/precreated/contrib/slackware-13.0-i386-minimal.tar.gz
Resolving download.openvz.org... 64.131.90.11
Connecting to download.openvz.org|64.131.90.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 39641862 (38M) [application/x-gzip]
Saving to: `slackware-13.0-i386-minimal.tar.gz'
100%[===============================================================>] 39,641,862 4.48M/s in 14s
2010-08-09 16:55:47 (2.71 MB/s) - `slackware-13.0-i386-minimal.tar.gz' saved [39641862/39641862]
3、建立虚拟机
假如虚拟机名为:VPS ossscn
vzctl create ossscn --ostemplate slackware-13.0-i386-minimal --config basic
屏幕输出:
Creating container private area (slackware-13.0-i386-minimal)
Performing postcreate actions
Container private area was created
Performing postcreate actions
Container private area was created
4、设置虚拟机
[root@localhost cache]# vzctl set ossscn --onboot yes --saveSaved parameters for CT 102make a Hostname for The machien:vzctl set 102 --hostname Hackers.example.com --saveGive Ip adress 192.168.0.130 to the machine:
[root@localhost cache]# vzctl set 102 --ipadd 192.168.0.130 --saveSaved parameters for CT 102
[root@localhost cache]#
[root@localhost cache]# vzctl set 102 --ipadd 192.168.0.130 --saveSaved parameters for CT 102
[root@localhost cache]#
5、启动虚拟机ossscn
vzctl start
屏幕输出:
ossscn Starting container ...Container is mountedAdding IP address(es): 192.168.0.130Setting CPU units: 1000Set hostname: Hackers.example.comContainer start in progress..
6、设置Root密码
vzctl exec ossscn passwd
New password: 123456
Re-enter new password: 123456
Changing password for root
Enter the new password (minimum of 5, maximum of 127 characters)Please use a combination of upper and lower case letters and numbers.Password changed
Re-enter new password: 123456
Changing password for root
Enter the new password (minimum of 5, maximum of 127 characters)Please use a combination of upper and lower case letters and numbers.Password changed
7、进入slackware虚拟机ossscn
vzctl enter 102
屏幕输出:
entered into CT ossscn
root@Hackers:/# cat /etc/slackware-version
Slackware 13.0.0.0.0
Stop of start or Exit
More commands :
To restart use : vzctl restart
To stop use : vzctl stop
to destroy the vm machine user : vzctl destro ossscn
For more commands use :vzctl -help
root@Hackers:/# cat /etc/slackware-version
Slackware 13.0.0.0.0
Stop of start or Exit
More commands :
To restart use : vzctl restart
To stop use : vzctl stop
to destroy the vm machine user : vzctl destro ossscn
For more commands use :vzctl -help
三、为OpenVZ安装Vtonf Web管理界面
VTONF是虚拟机控制面板,专门为GNU/Linux中运行OpenVZ虚拟机技术设计。VTONF是基于GPL许可证下发布的自由软件。
1、安装Vtonf
打开终端,输入以下命令,不要忘记将vtonf版本vtonfinstaller.x.x-beta1.tar.gz中的x改为你下载的版本。
cd /tmp
wget http://mesh.dl.sourceforge.net/sourceforge/vtonf/vtonfinstaller.x.x-beta1.tar.gz
tar xvfz vtonfinstaller.1.0-beta1.tar.gz
cd vtonfinstaller.x.x-beta1
./install
wget http://mesh.dl.sourceforge.net/sourceforge/vtonf/vtonfinstaller.x.x-beta1.tar.gz
tar xvfz vtonfinstaller.1.0-beta1.tar.gz
cd vtonfinstaller.x.x-beta1
./install
当Vtonf控制面板安装完成,你可以登陆系统:
http://192.168.0.109:8001/
用户名 : admin
密码 : admin
用户名 : admin
密码 : admin
时间:2010-08-10 10:12
来源:osss.cn
作者:osss.cn
原文链接