Kvm虚拟机中使用OpenVZ Web Panel面板开Openvz小鸡

2018年7月24日星期二

Kvm虚拟机中使用OpenVZ Web Panel面板开Openvz小鸡




系统 CentOS 6.8 x64

开始安装openvz



先安装Openvz内核

cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
yum update -y
yum install vzkernel
yum install vzctl vzquota


修改/etc/sysctl.conf

vi /etc/sysctl.conf


修改以下两项设置转发

net.ipv4.ip_forward = 1
kernel.sysrq = 1


使上面的配置文件生效

modprobe bridge
lsmod|grep bridge


重启[必须]

reboot


完成Openvz安装
#检查开机是否设置为启动

chkconfig --list vz


#启动检查openvz是否启动

service vz status


#如果没自动启动执行,默认情况下会开机自动启动

service vz start


安装控制面板 OpenVZ Web Panel



#下载一键安装脚本

wget https://raw.githubusercontent.com/sibprogrammer/owp/master/installer/ai.sh


经测试默认脚本是使用googlecode托管的程序,但由于googlecode改版升级脚本里的下载地址是无效的,所以需要手动替换下载地址,国内可能需要fan墙

vi ai.sh




DOWNLOAD_URL="http://ovz-web-panel.googlecode.com/files/ovz-web-panel-$VERSION.tgz"


替换为

DOWNLOAD_URL="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/ovz-web-panel/ovz-web-panel-2.4.tgz"


然后执行脚本


sh ai.sh
#也可以查看 OpenVZ Web Panel 官方教程 https://github.com/sibprogrammer/owp/blob/master/INSTALL.md


OpenVZ Web Panel 面板安装完成
安装结束后,使用如下信息登录控制面板:
http://你的Ip地址:3000 默认OpenVZ Web Panel平台端口 3000
然后就可以创建你的openvz小鸡鸡了 `(*∩_∩*)′
常见问题
一. 在测试过程中,开通小鸡的时候提示:
[v_error]Internal error: Command 'vzctl create 1 --ostemplate centos-5-x86 --config vswap-1024m' execution failed with code 99 Output: Can't load ploop library: libploop.so: cannot open shared object file: No such file or directory Please install ploop packages! Alternatively, if you can't or don't want to use ploop, please add --layout simfs option, or set VE_LAYOUT=simfs in /etc/vz/vz.conf Creation of container private area failed[/v_error]
#提示 让你安装ploop 可以直接使用以下命令即可

yum install ploop


二.主机做nat转发映射到小鸡问题
#将主机的外网 2222端口映射到小鸡的22端口

iptables -t nat -A PREROUTING -d 你的外网IP -p tcp -m tcp --dport 2222 -j DNAT --to-destination 小鸡ip:22


#如果提示iptables v1.4.7: can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded.

vi /etc/modprobe.d/openvz.conf




options nf_conntrack ip_conntrack_disable_ve0=1


替换为

options nf_conntrack ip_conntrack_disable_ve0=0


然后重启

reboot


重启后执行

iptables -L -n -t nat


没报错那就在执行上面的iptables命令

0 评论 :

发表评论