Skip to content

Instantly share code, notes, and snippets.

@v-thomp4
Last active July 5, 2019 04:02
Show Gist options
  • Save v-thomp4/7e89da839ee911497863cabf1bd2c584 to your computer and use it in GitHub Desktop.
Save v-thomp4/7e89da839ee911497863cabf1bd2c584 to your computer and use it in GitHub Desktop.
setup openvz centos 6
wget http://download.openvz.org/openvz.repo -O /etc/yum.repos.d/openvz.repo
yum install vzkernel vzctl vzquota
vim /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
vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
vim /etc/sysconfig/iptables
:FORWARD ACCEPT [0:0]
-P FORWARD ACCEPT
-F FORWARD
:OUTPUT ACCEPT [0:0]
#-A FORWARD -j REJECT –reject-with icmp-host-prohibited
service iptables restart
vim /etc/vz/vz.conf
VE_LAYOUT=simfs
reboot
cd /vz/template/cache/
wget http://download.openvz.org/template/precreated/ubuntu-11.10-x86.tar.gz
vzctl create 101 --ostemplate ubuntu-11.10-x86 --config basic
vzctl set 101 --onboot yes --save
vzctl set 101 --hostname ubuntu-vm.local --save
vzctl set 101 --ipadd 192.168.255.113 --save
vzctl set 101 --nameserver 8.8.8.8 --nameserver 4.2.2.1 --save
vzctl set 101 --numproc 200 --save
vzctl set 101 --cpus 4 --save
vzctl set 101 --privvmpages 4096m --save
vzctl set 101 --diskspace 45G:49G --save
vzctl set 101 --diskinodes 4000000:4400000 --save
vzctl start 101
vzctl exec 101 passwd
vzctl enter 101
vzctl destroy 101
vzlist -a
vzctl exec 101 cat /proc/user_beancounters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment