<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/ DTD/wml_1.1.xml">

<wml>
<head>
<meta http-equiv="cache-control" content="max-age=180,private" />
</head>
<card title="OpenVZ+HyperVM安装">
<p>
作者:<a href="index.php?action=showuser&amp;userid=1&amp;hash=">admin</a><br />时间:2009-06-15 15:34<br />分类:<a href="index.php?action=list&amp;cid=3&amp;hash=">电脑技术</a><br />内容:
OpenVZ+HyperVM安装


今天把简单的OPENVZ和HYPERVM的安装过程写一个,留下做个记号！


系统:CentOS 5.1 for vmware6.0


系统安装就不说了，选最简单的安装就行，还有把防火墙，SELinux关闭就了！


[root@localhost ~]# uname -r
2.6.18-53.el5


[root@localhost ~]# cat /boot/grub/menu.lst 
# 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 (2.6.18-53.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-53.el5.img



安装openvz


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


 


[root@bogon ~]# uname -r
2.6.18-92.1.13.el5.028stab059.6


安装完之后，会修改启动项，会把vz内核放到第一项去


[root@bogon ~]# cat /boot/grub/menu.lst
# 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-92.1.13.el5.028stab059.6)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-92.1.13.el5.028stab059.6 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-92.1.13.el5.028stab059.6.img
title CentOS (2.6.18-53.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-53.el5.img



安装vz工具


yum install vzctl vzquota


 


修改sysctl.conf


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


..........


 


sysctl -p (使sysctl.conf生效)


 


修改/etc/vz/vz.conf


vi /etc/sysconfig/selinux
........
SELINUX=disabled
........


 


好了，OPENVZ就这安装好了，接下来安装hypervm


wget http://download.lxlabs.com/download/hypervm/production/hypervm-install-master.sh


chmod 777 hypervm-install-master.sh
./hypervm-install-master.sh --virtualization-type=openvz


好了，，等他安装完再重启就OK了。








由于HyperVM的脚本在安装时，需要从官网下载大量的软件包，特别是OpenVZ的OSTemplate模板，数据量大，但传输速率又特别慢。为此，我在本地模拟了一个download.lxlabs.com的环境，把必要的软件包先预存放在服务器上。内容如下：


引用

# cd /var/www/html/
# tree download/
download/
|-- hypervm
|   `-- production
|       `-- hypervm
|           `-- hypervm-current.zip
|-- hypervm-thirdparty.2008.zip
|-- program-install.zip
|-- update
|   |-- lxgeneral
|   |   `-- repodata
|   |       |-- filelists.xml.gz
|   |       |-- other.xml.gz
|   |       |-- primary.xml.gz
|   |       `-- repomd.xml
|   `-- rhel-5.2
|       `-- x86_64
|           |-- lxphp
|           |   `-- lxphp-5.2.1-200.i386.rpm
|           |-- lxprg
|           |   |-- lxlighttpd-1.4.18-5.i386.rpm
|           |   `-- lxzend-3.3-100lxa.i386.rpm
|           `-- repodata
|               |-- filelists.xml.gz
|               |-- other.xml.gz
|               |-- primary.xml.gz
|               `-- repomd.xml
`-- vpstemplate
    `-- centos-5-i386-afull.tar.gz




除了vpstemplate下的文件外，其他软件都是必须的。其中，repodata的内容，可以使用createrepo命令自动生成。
本地下载：


下载文件 

点击这里下载文件




然后在/etc/hosts中加入本地到download.lxlabs.com的指向，并启动httpd服务：


# echo &quot;192.168.228.30 download.lxlabs.com&quot; &gt;&gt; /etc/hosts
# service httpd start



启动hypervm服务：


# service hypervm start
/usr/local/lxlabs/hypervm/httpdocs
Starting hypervm: mysqld (pid 8554) 正在运行...
Started hypervm



访问https://&lt;ip-address&gt;:8887 或 http://&lt;ip-address&gt;:8888：

（默认用户名和密码都是：admin）

简单使用
1、首次使用
首次进入，会提示您修改默认密码，输入两次新密码后，用update保存：

然后，会再提示您配置Lxguard设置，这是一个安全控制的配置。主要是可设置密码尝试次数，防止密码暴力破解，及设置允许访问的白名单IP信息，禁止的黑名单等：
然后，会再提示您配置Lxguard设置，这是一个安全控制的配置。主要是可设置密码尝试次数，防止密码暴力破解，及设置允许访问的白名单IP信息，禁止的黑名单等：
启动smtp服务：     # service postfix start

甚至还会有提示您做好服务器上的ssh安全设定等：
2、创建VPS
建议先创建IP Pools，今后虚拟机可从中自行调用该地址池：
（Gateway对于openvz没有意义，只对xen有用。记住，在最下面需要把允许使用该IP Pools的服务器选上）
然后创建Resource Plans：
最后，创建vps：



网上提供了破解方法
请参考：这里。（留意代码中全角双引号问题）
我用以下内容覆盖原来的：/usr/local/lxlabs/hypervm/httpdocs/display.php

&lt;?php
function crack( )
{
global $gbl;
global $sgbl;
global $login;
global $ghtml;
$license = $login-&gt;getObject( &quot;license&quot; );
$name = $license-&gt;licensecom_b-&gt;lic_ipaddress;
if ( stristr($name,&quot;Bendy&quot;)) {
return;
}
$license-&gt;licensecom_b-&gt;lic_ipaddress = &quot;crack by www.dezend.cc Bendy &quot;.stristr($name,&quot;(&quot;);
$license-&gt;licensecom_b-&gt;lic_domain_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;lic_pserver_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;lic_maindomain_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;lic_vps_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;maindomain_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;domain_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;vps_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;pserver_num = &quot;Unlimited&quot;;
$license-&gt;licensecom_b-&gt;client_num = &quot;Unlimited&quot;;
$login-&gt;priv-&gt;maindomain_num = &quot;Unlimited&quot;;
$login-&gt;priv-&gt;pserver_num = &quot;Unlimited&quot;;
$login-&gt;priv-&gt;vps_num = &quot;Unlimited&quot;;
$license-&gt;setUpdateSubaction( );
$license-&gt;write( );
$login-&gt;setUpdateSubaction( );
$login-&gt;write( );
throw new lxException (&quot;Crack OK! your have Unlimited domain/vps NUM and full fuction now!&quot;, &quot;&quot;);
exit;

}
$v = 0;
include_once( &quot;htmllib/coredisplaylib.php&quot; );
sleep( $v );
print_time( &quot;start&quot; );
display_init( );
print_time( &quot;start&quot;, &quot;Start&quot; );
crack();
display_exec( );
?&gt;






</p><p>
<a href="index.php?action=login&amp;hash=">立即登陆发表评论</a><br />
</p>
<p><a href="index.php?action=list&amp;hash=">返回日志列表</a><br /><a href="index.php?action=index&amp;hash=">返回主页</a></p>
</card>
</wml>
