#!/bin/bash #openvz install cd /etc/yum.repos.d wget http://download.openvz.org/openvz.repo rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ yum -y update yum install -y ovzkernel #disable selinux echo "SELINUX=disabled" > /etc/sysconfig/selinux #configure sysctl mv /etc/sysctl.conf /etc/sysctl.conf.bak cat << EOF >>/etc/sysctl.conf # 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 #install openvz tools yum install -y vzctl vzquota ploop echo "Installation has been completed." echo "Your system will be reboot!" sleep 5; reboot
https://code.xiaofengsky.com/openvz/openvz.sh
openvz模板仓库下载: 模板存放路径:/vz/template/cache 下载地址:http://download.openvz.org/template/precreated/ cd /vz/template/cache wget https://download.openvz.org/template/precreated/centos-6-x86.tar.gz
openvz虚拟机的管理
vzctl create 1001 --ostemplate centos-6-x86 #centos-6-x86是模板的名字 vzctl set 1001 --onboot yes --save #1001是虚拟机的ID,随意正整数 vzctl set 1001 --ipadd 192.168.1.1 --save #给虚拟机分配IP vzctl set 1001 --nameserver 8.8.8.8 --save #给虚拟机配置NS vzctl set 1001 --hostname server.domain.com --save #设置VPS的主机名 vzctl set 1001 --diskspace 10G:10G --save #给虚拟机分配硬盘大小 vzctl start 1001 #启动虚拟机 vzctl exec 1001 passwd #创建虚拟机的密码 vzctl start 1001 #启动虚拟机 vzctl restart 1001 #重启虚拟机 vzctl stop 1001 #停止虚拟机 vzctl destroy 1001 #删除虚拟机 vzlist #查看正在运行的虚拟机 vzctl enter 1001 #进入虚拟机 vzcalc -v 1001 #查看虚拟机1001用到的资源
官方网站:https://openvz.org/
文章评论