2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# 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
|
本文转自 jie783213507 51CTO博客,原文链接:http://blog.51cto.com/litaotao/1186929,如需转载请自行联系原作者