openvz

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xuejinliang/article/details/51315802
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ


cat >>/etc/sysctl.conf <<EOF
# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0


# Enables source route verification
net.ipv4.conf.all.rp_filter = 1


# Enables the magic-sysrq key
kernel.sysrq = 1


# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
EOF


sysctl -p




yum install vzkernel vzctl vzquota ploop -y


reboot os...




/etc/init.d/vz status


//网络
sed -i '/NEIGHBOUR_DEVS/a NEIGHBOUR_DEVS=all' /etc/vz/vz.conf
//硬盘模式 生产中还是用ploop好,可以做磁盘限止
sed -i 's#VE_LAYOUT=ploop#VE_LAYOUT=simfs#g' /etc/vz/vz.conf
//磁盘空间
sed -i 's#DISK_QUOTA=yes#DISK_QUOTA=no#g' /etc/vz/vz.conf






下载模板
cd /vz/template/cache/
yum install epel-* -y
rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum install axel -y
axel -n 10 http://download.openvz.org/template/precreated/centos-6-x86_64.tar.gz




创建VM脚本
vi openvz.sh
#!/bin/bash
id=$1
ip=$2
hostname=test$id.vz.vm


vzlist -a
echo $id $ip $hostname
read -p "hehe"


vzctl create $id --ostemplate centos-6-x86_64 --ipadd $ip --hostname $hostname
vzctl start $id
vzctl set $id --nameserver 114.114.114.114 --save
vzctl set $id --onboot yes --save
vzctl set $id --ram 512M --swap 1024M --save
vzctl set $id --userpasswd root:123456
#vzctl exec $id echo '123456'|passwd root --stdin
vzctl restart $id


clear
echo "==============================================="
echo "ip=$ip "
echo "run:vzctl exec $id passwordd:123456 ,change you password!"
echo "==============================================="



没有更多推荐了,返回首页