您的位置:首页 > 运维架构 > Shell

linux   shell   openvz (vps)

2013-04-26 07:00 148 查看
# the first script is install openvz
#!/bin/bash
#this script install openvz(vps)#
#Attention openvz you must downlown in the Internet,so you linux host must be can  surf the Internet
cd /etc/yum.repos.d/
yum -y install wget
wget http://download.openvz.org/openvz.repo rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ ker=`uname -m`
CONF=/etc/vz/vz.conf
if [ $ker==i686 ];then
yum -y install vzkernel vzctl vzquota
else
yum -y install ovzkernel vzctl.x86_64 vzquota.x86_64
fi
cat >> /etc/sysctl.conf << EOF
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
EOF
sysctl -p
#sed -i '/NEIGHBOUR_DEVS/d' $CONF
## echo "NEIGHBOUR_DEVS=all" >> $CONF
sed -i -e 's/NEIGHBOUR_DEVS/#NEIGHBOUR_DEVS/' -e '/\<NEIGHBOUR_DEVS\>/ a NEIGHBOUR_DEVS=all' $CONF
setenforce 0       #sed  -i 's/enforcing/disabled/g'  /etc/sysconfig/selinux
echo "###now,reboot the linux server####"
reboot
the second script is crate a new vps
#!/bin/bash
#this script is crate a vps host#
cd /vz/template/cache
##please download a os tar package for vps#
wget http://download.openvz.org/template/precreated/contrib/centos-5-i386-default.tar.gz vzctl create 101 --ostemplate centos-5-i386-default --config basic
##set the vps os ip,dns,hostname,port number,boot from the rev.###
vzctl set 101 --onboot yes –-save
vzctl set 101 --hostname supervm1.jie.com --save
vzctl set 101 --ipadd 192.168.4.78 --save
vzctl set 101 --diskspace 10G:10G --save
vzctl set 101 --nameserver 192.168.4.10 --nameserver 8.8.8.8 --save
vzctl set 101 --numothersock 120 --save
vzctl start 101
##set vps password
vzctl exec 101 passwd
echo "####the vps root passwd####"
vzlist -a
两个脚本 一个是搭建vps,一个是在vps上面安装一个centos
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux   shell &