Ubuntu 14.4 Installation OpenVZ

Source: Internet
Author: User
Tags nameserver

Add source
vim /etc/apt/sources.list.d/openvz.list

Write to the following content to save
If necessary, you can change the comments as appropriate ... (If you do not understand, please do not care about this line of words)

deb http://download.openvz.org/debian wheezy main# deb http://download.openvz.org/debian wheezy-test main
Update after importing key
wget http://ftp.openvz.org/debian/archive.keyapt-key add archive.keyapt update
Configuring Kernel Parameters
vim /etc/sysctl.conf

Configure these items:

# On Hardware Node we generally need# packet forwarding enabled and proxy arp disablednet.ipv4.ip_forward = 1net.ipv6.conf.default.forwarding = 1net.ipv6.conf.all.forwarding = 1net.ipv4.conf.default.proxy_arp = 0# Enables source route verificationnet.ipv4.conf.all.rp_filter = 1# Enables the magic-sysrq keykernel.sysrq = 1# We do not want all our interfaces to send redirectsnet.ipv4.conf.default.send_redirects = 1net.ipv4.conf.all.send_redirects = 0

Let the changes take effect immediately:

sysctl -p
Installation

64-bit system with this

apt install -y linux-image-openvz-amd64 vzctl vzquota ploop vzstats

32-bit system with this

apt install -y linux-image-openvz-686 vzctl vzquota ploop vzstats
Enter the OpenVZ kernel

Reboot, select "Advance options for Ubuntu" in Grub to find a line with OpenVZ (more than one, choose the first one)

Use to create and initialize a virtual machine

Creating a virtual machine requires downloading a system template that will use a lot of traffic (how painful it is to understand ~)

#创建虚拟机,编号102 参数是:虚拟机编号  --ostemplate 系统模板vzctl create 102 --ostemplate debian-7.0-x86-minimal#限制CPUvzctl set 102 --cpuunits 1000 --savevzctl set 102 --cpulimit 50 --save#限制I/Ovzctl set 102 --iolimit 5M --save#设置内存和swapvzctl set 102 --ram 512M --swap 1G --save#设置硬盘大小 参数:编号 --diskspace 软限制:硬限制 --savevzctl set 102 --diskspace 4G:5G --save#设置ipvzctl set 102 --ipadd 192.168.0.2 --save#设定dns服务器vzctl set 102 --nameserver 8.8.8.8 --nameserver 8.8.4.4 --save#设置root用户密码(需要Cgroup)vzctl set 102 --userpasswd root:passwd#主机开机时自动运行虚拟机,酌情使用vzctl set 102 --onboot yes --save

The virtual machine created can be viewed with this command:

vzlist -a
Start
vzctl restart 102
Shut down
vzctl stop 102
Delete
vzctl destroy 102
View Resource Usage
vzcalc -v 102
Network configuration
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to x.x.x.xiptables -t nat -A PREROUTING -p tcp -m tcp --dport 10222 -j DNAT --to-destination 192.168.0.2:22
Reference articles

http://blog.topspeedsnail.com/archives/3720
https://www.ahao.me/archives/1009

Ubuntu 14.4 Installation OpenVZ

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.