|
|
| Line 1: |
Line 1: |
| − | {{Warning|This is an unofficial guide, use at your own risk. For an official guide, see [[Quick installation]].}}
| + | error |
| − | | |
| − | This quick installation quide assumes you have CentOS 6 64-bit installed with [http://wiki.centos.org/HowTos/Virtualization/OpenVZ SELinux and Firewall disabled], and that the containers will be on the same subnet as the host node.
| |
| − | | |
| − | The node's IP is 192.168.1.99/24 and the gateway is 192.168.1.1. The containers will have 192.168.1.101, 192.168.1.102, etc...
| |
| − | | |
| − | * Add the OpenVZ yum repo
| |
| − | <pre>
| |
| − | # wget -O /etc/yum.repos.d/openvz.repo http://download.openvz.org/openvz.repo
| |
| − | # rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
| |
| − | </pre>
| |
| − | | |
| − | * Ensure the yum repo points to RHEL6 packages
| |
| − | <pre>
| |
| − | # vi /etc/yum.repos.d/openvz.repo
| |
| − | </pre>
| |
| − | | |
| − | * Install the OpenVZ kernel and ensure it's the 1st option in grub
| |
| − | <pre>
| |
| − | # yum install vzkernel
| |
| − | # vi /boot/grub/menu.lst
| |
| − | </pre>
| |
| − | | |
| − | * Install the OpenVZ utilities
| |
| − | <pre>
| |
| − | # yum install vzctl vzquota ploop
| |
| − | </pre>
| |
| − | | |
| − | * Tune /etc/sysctl.conf
| |
| − | <pre>
| |
| − | # vi /etc/sysctl.conf
| |
| − | 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
| |
| − | </pre>
| |
| − | | |
| − | The last 2 steps are necessary only if you are planning on using '''veth''' containers
| |
| − | | |
| − | * Create a vmbr0 bridge and add the host's interface to it
| |
| − | <pre>
| |
| − | # vi /etc/sysconfig/network-scripts/ifcfg-vmbr0
| |
| − | DEVICE="vmbr0"
| |
| − | BOOTPROTO="static"
| |
| − | IPV6INIT="no"
| |
| − | ONBOOT="yes"
| |
| − | TYPE="Bridge"
| |
| − | DELAY=0
| |
| − | IPADDR=192.168.1.99
| |
| − | NETMASK=255.255.255.0
| |
| − | GATEWAY=192.168.1.1
| |
| − | | |
| − | # vi /etc/sysconfig/network-scripts/ifcfg-eth0
| |
| − | DEVICE="eth0"
| |
| − | ONBOOT="yes"
| |
| − | IPV6INIT="no"
| |
| − | TYPE="Ethernet"
| |
| − | BRIDGE="vmbr0"
| |
| − | </pre>
| |
| − | | |
| − | * Create /etc/vz/vznet.conf with the following content. This will automatically add/remove the container's interface to the bridge when you start/stop the container.
| |
| − | <pre>
| |
| − | # vi /etc/vz/vznet.conf
| |
| − | #!/bin/bash
| |
| − | EXTERNAL_SCRIPT="/usr/sbin/vznetaddbr"
| |
| − | </pre>
| |
| − | | |
| − | * Done. Reboot
| |
| − | | |
| − | == Create a VENET Container ==
| |
| − | | |
| − | * Create a CT
| |
| − | <pre>
| |
| − | # vzctl create 101 --ostemplate centos-6-x86_64 --config vswap-1g
| |
| − | </pre>
| |
| − | | |
| − | * Configure the CT
| |
| − | <pre>
| |
| − | # vzctl set 101 --save --name server101
| |
| − | # vzctl set 101 --save --onboot yes
| |
| − | # vzctl set 101 --save --hostname server101.example.com
| |
| − | # vzctl set 101 --save --ipadd 192.168.1.101
| |
| − | # vzctl set 101 --save --searchdomain example.com
| |
| − | # vzctl set 101 --save --nameserver 8.8.8.8 --nameserver 8.8.4.4
| |
| − | # vzctl set 101 --save --cpus 4
| |
| − | # vzctl set 101 --save --ram 8G
| |
| − | # vzctl set 101 --save --swap 4G
| |
| − | # vzctl set 101 --save --diskspace 100G
| |
| − | # vzctl start 101
| |
| − | # vzctl exec 101 passwd
| |
| − | </pre>
| |
| − | | |
| − | * Done. Enjoy your new VENET container
| |
| − | | |
| − | == Create a VETH Container ==
| |
| − | | |
| − | * Create a CT
| |
| − | <pre>
| |
| − | # vzctl create 102 --ostemplate centos-6-x86_64 --config vswap-1g
| |
| − | </pre>
| |
| − | | |
| − | * Configure the CT
| |
| − | <pre>
| |
| − | # vzctl set 102 --save --name server102
| |
| − | # vzctl set 102 --save --onboot yes
| |
| − | # vzctl set 102 --save --hostname server102.example.com
| |
| − | # vzctl set 102 --save --netif_add eth0,,,FE:FF:FF:FF:FF:FF
| |
| − | # vzctl set 102 --save --searchdomain example.com
| |
| − | # vzctl set 102 --save --nameserver 8.8.8.8 --nameserver 8.8.4.4
| |
| − | # vzctl set 102 --save --cpus 4
| |
| − | # vzctl set 102 --save --ram 8G
| |
| − | # vzctl set 102 --save --swap 4G
| |
| − | # vzctl set 102 --save --diskspace 100G
| |
| − | # vzctl start 102
| |
| − | # vzctl exec 102 passwd
| |
| − | </pre>
| |
| − | | |
| − | FE:FF:FF:FF:FF:FF will ensure a permanent MAC address on the bridge interface.
| |
| − | | |
| − | (Linux bridges behave strangely. They use the smallest MAC address of all the attached interfaces. If you add a new interface to the bridge with an even smaller MAC, the MAC of the bridge will change causing network interruption until the switch re-learns the new MAC)
| |
| − | | |
| − | * Configure the network of a RHEL-based container
| |
| − | <pre>
| |
| − | # cat << _EOF_ > /vz/root/102/etc/sysconfig/network-scripts/ifcfg-eth0
| |
| − | DEVICE="eth0"
| |
| − | HOSTNAME="server102"
| |
| − | IPV6INIT="no"
| |
| − | MTU="1500"
| |
| − | TYPE="Ethernet"
| |
| − | ONBOOT=yes
| |
| − | BOOTPROTO=static
| |
| − | IPADDR=192.168.1.102
| |
| − | NETMASK=255.255.255.0
| |
| − | GATEWAY=192.168.1.1
| |
| − | _EOF_
| |
| − | | |
| − | # vzctl exec 102 /etc/init.d/network restart
| |
| − | </pre>
| |
| − | | |
| − | * Configure the network of a Debian-based container
| |
| − | <pre>
| |
| − | # cat << _EOF_ > /vz/root/102/etc/network/interfaces
| |
| − | auto lo eth0
| |
| − | iface lo inet loopback
| |
| − | iface eth0 inet static
| |
| − | address 192.168.1.102
| |
| − | netmask 255.255.255.0
| |
| − | gateway 192.168.1.1
| |
| − | _EOF_
| |
| − | | |
| − | # vzctl exec 102 /etc/init.d/networking restart
| |
| − | </pre>
| |
| − | | |
| − | * Done. Enjoy your new VETH container
| |
| − | | |
| − | [[Category: Installation]]
| |
| − | [[Category: HOWTO]]
| |