96MB Forum
How to install OpenVZ - Printable Version

+- 96MB Forum (http://96forum.com)
+-- Forum: VPS Discussions (http://96forum.com/forumdisplay.php?fid=32)
+--- Forum: VPS Tutorials (http://96forum.com/forumdisplay.php?fid=33)
+---- Forum: OpenVZ Tutorials (http://96forum.com/forumdisplay.php?fid=13)
+---- Thread: How to install OpenVZ (/showthread.php?tid=24)



How to install OpenVZ - jarland - 03-25-2013

This is a bash script to install OpenVZ on a dedicated server running CentOS 6. I stole this from github and remove some of the excess. I also combined it with some of Tim's (from Hostigation) cent6.sh script. This sits in my personal collection of scripts. No harm in taking the easy way out on a task that can get repetitive.

Code:
#!/bin/bash
yum update -y
yum install -y wget
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
yum install -y vzkernel.x86_64
yum install -y vzctl vzquota
sed -i 's/kernel.sysrq = 0/kernel.sysrq = 1/g' /etc/sysctl.conf
sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
echo 'net.ipv4.conf.default.proxy_arp = 0' >> /etc/sysctl.conf
echo 'net.ipv4.conf.all.rp_filter = 1' >> /etc/sysctl.conf
echo 'net.ipv4.conf.default.send_redirects = 1' >> /etc/sysctl.conf
echo 'net.ipv4.conf.all.send_redirects = 0' >> /etc/sysctl.conf
echo 'net.ipv4.icmp_echo_ignore_broadcasts=1' >> /etc/sysctl.conf
echo 'net.ipv4.conf.default.forwarding=1' >> /etc/sysctl.conf
sysctl -p
sed -i 's/NEIGHBOUR_DEVS=detect/NEIGHBOUR_DEVS=all/g' /etc/vz/vz.conf
sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/sysconfig/selinux
cd /vz/template/cache
wget http://download.openvz.org/template/precreated/centos-6-x86_64.tar.gz
yum install -y ntp
ntpdate -u us.pool.ntp.org
chkconfig ntpd on
service iptables stop
service ip6tables stop
chkconfig iptables off
chkconfig ip6tables off



RE: How to install OpenVZ - matthewvz - 03-26-2013

Very nice!


RE: How to install OpenVZ - coreymanshack - 05-07-2013

Thank you. I've been meaning to add this to my scripts and this post just prompted me to do exactly that. Although - why turn off iptables?


RE: How to install OpenVZ - jarland - 05-27-2013

(05-07-2013, 10:10 AM)coreymanshack Wrote: Thank you. I've been meaning to add this to my scripts and this post just prompted me to do exactly that. Although - why turn off iptables?

Right after install on a CentOS 6 system, iptables will block forwarding. This could be solved with:
iptables -D FORWARD 1

Some people also prefer not to use iptables, so it just gives you a clean slate to figure out what you want to do.