If you didn’t set this limit container can eat all your nic traffic, this is danger:
DEV=eth0
iptables -I FORWARD 1 -o $DEV -s X.X.X.X -m limit –limit 200/sec -j ACCEPT
iptables -I FORWARD 2 -o $DEV -s X.X.X.X -j DROP
If you didn’t set this limit container can eat all your nic traffic, this is danger:
DEV=eth0
iptables -I FORWARD 1 -o $DEV -s X.X.X.X -m limit –limit 200/sec -j ACCEPT
iptables -I FORWARD 2 -o $DEV -s X.X.X.X -j DROP
for ctid in `vzlist -SHo ctid`; do vzctl start $ctid; done
if you want stop all running OpenVZ containers:
for ctid in `vzlist -aHo ctid`; do vzctl stop $ctid; done
vzctl set 100 –diskspace 99999G:99999G –save
or if you want remove disk quota in container config file:
DISK_QUOTA=no
This is also possible via this option:
DISKSPACE=”unlimited”
This bash script is useful to create Centos or other new VPS in few seconds. You can download it cr_vm.
Source below:
#!/bin/bash
if [ -z "$2" ]; then
echo usage: $0 ctid ipaddr
echo example: 521 192.168.122.152
exit
fi
if [ -f /vz/template/cache/centos-6-x86_64-20130522.tar.xz ]; then
echo "OK"
else
echo "================================================================"
echo "Download a Centos (6.0) template"
echo "================================================================"
wget http://mirror.duomenucentras.lt/openvz/contrib/template/precreated/centos-6-x86_64-20130522.tar.xz -O /vz/template/cache/centos-6-x86_64-20130522.tar.xz
fi
echo "================================================================"
echo "Create a new container named $1"
echo "================================================================"
vzctl create $1 --ostemplate centos-6-x86_64-20130522
echo "================================================================"
echo "Set the hostname"
echo "================================================================"
vzctl set $1 --hostname $1 --save
echo "================================================================"
echo "Set the IP address"
echo "================================================================"
vzctl set $1 --ipadd $2 --save
echo "================================================================"
echo "Set OpenDNS servers 208.67.222.222 and 208.67.220.220"
echo "================================================================"
vzctl set $1 --nameserver 208.67.222.222 --nameserver 208.67.220.220 --save
echo "================================================================"
echo "Set ROOT user password"
echo "================================================================"
vzctl set $1 --userpasswd root:plainpass
echo "================================================================"
echo "Stop and start the container named $1 and wait 10 secs"
echo "================================================================"
vzctl stop $1 && vzctl start $1 && sleep 10
echo "================================================================"
echo "Ping test to google.com"
echo "================================================================"
vzctl exec $1 ping -c 3 google.com
echo "================================================================"
echo "Restarting the node $1"
echo "================================================================"
vzctl restart $1
echo "================================================================"
echo "Test command 'ps aux' executed in the node $1"
echo "================================================================"
vzctl exec $1 ps aux
You can edit this script for your needs.
Assuming you have a running container identified by $CTID
. The following needs to be done:
# Known snapshot ID ID=$(uuidgen) VE_PRIVATE=$(VEID=$CTID; source /etc/vz/vz.conf; source /etc/vz/conf/$CTID.conf; echo $VE_PRIVATE) # Take a snapshot without suspending a CT and saving its config vzctl snapshot $CTID --id $ID --skip-suspend --skip-config # Perform a backup using your favorite backup tool # (cp is just an example) cp $VE_PRIVATE/root.hdd/* /backup/destination # Delete (merge) the snapshot vzctl snapshot-delete $CTID --id $ID
Assuming you have a running container identified by $CTID
. The following needs to be done:
# Known snapshot ID ID=$(uuidgen) # Directory used to mount a snapshot MNTDIR=./mnt mkdir $MNTDIR # Take a snapshot without suspending a CT and saving its config vzctl snapshot $CTID --id $ID --skip-suspend --skip-config # Mount the snapshot taken vzctl snapshot-mount $CTID --id $ID --target $MNTDIR # Perform a backup using your favorite backup tool # (tar is just an example) tar cf backup.tar.xz $MNTDIR # Unmount the snapshot vzctl snapshot-umount $CTID --id $ID # Delete (merge) the snapshot vzctl snapshot-delete $CTID --id $ID
In addition:
How to start?
In global VZ configuration file /etc/vz/vz.conf:
VE_LAYOUT=ploop
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
OpenVZ kernel:
yum install vzkernel
sysctl options:
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 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
Disable selinux:
echo "SELINUX=disabled" > /etc/sysconfig/selinux
OpenVZ user level tools: yum install vzctl vzquota ploop
And reboot.