JavaScript must be enabled in order for you to see "WP Copy Data Protect" effect. However, it seems JavaScript is either disabled or not supported by your browser. To see full result of "WP Copy Data Protector", enable JavaScript by changing your browser options, then try again.

Setup and use the environment about the container with OpenVZ on the CentOS 6.7 x64


Hello everyone, it’s time to post as rubbish! Let’s to talk about the today’s topic.I want to introduce the container of OpenVZ, that is belong to the field of LXC, and its mechanism is like the docker. It’s different with the method about KVM or Xen. How do we setup and operate it? Let’s keep reading:

1) Add the OpenVZ yum repo to the CentOS
#wget -O /etc/yum.repos.d/openvz.repo http://download.openvz.org/openvz.repo
#rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

2) Install the related packages and utilities about OpenVZ(Check the boot order)
#yum install vzkernel
#yum install vzctl vzquota ploop
#cat /boot/grub/menu.lst
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_openvz-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title OpenVZ (2.6.32-042stab108.8)
root (hd0,0)
kernel /vmlinuz-2.6.32-042stab108.8 ro root=/dev/mapper/vg_openvz-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_openvz/lv_swap rd_NO_MD
SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_openvz/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-042stab108.8.img
title CentOS 6 (2.6.32-573.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-573.el6.x86_64 ro root=/dev/mapper/vg_openvz-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_openvz/lv_swap rd_NO_MD
SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_openvz/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-573.el6.x86_64.img

3) Tune the parameters about the /etc/sysctl.conf
#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

4) Create the network interface about the type of bridge
#vi /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
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="br0"

5) Configure the network for the container w/ the bridge for OpenVZ
#vi /etc/vz/vznet.conf
#!/bin/bash
EXTERNAL_SCRIPT="/usr/sbin/vznetaddbr"
#vi /usr/sbin/vznetaddbr
...
[ -n "$bridge" ] ||
bridge=br0
...
#init 6
#uname -a
Linux server101.sit.com 2.6.32-042stab108.8 #1 SMP Wed Jul 22 17:23:23 MSK 2015 x86_64 x86_64 x86_64 GNU/Linux

6) Create a VENET container about the OpenVZ
#vzctl create 101 --ostemplate centos-6-x86_64 --config vswap-1g -> Create a CT
#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

7) Create a VETH container about the OpenVZ
#vzctl create 102 --ostemplate centos-6-x86_64 --config vswap-1g
#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
#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

8) Basic commands about the OpenVZ for the container(You can download the CT from here or through –ostemplate)
#vzctl exec 101 ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 19236 248 ? Ss Aug29 0:00 init
root 2 0.0 0.0 0 0 ? S 08:03 0:00 [kthreadd/101]
root 3 0.0 0.0 0 0 ? S 08:03 0:00 [khelper/101]
root 126 0.0 0.0 10644 272 ? S<s Aug29 0:00 /sbin/udevd -d
root 498 0.0 0.0 183556 704 ? Sl Aug29 0:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root 532 0.0 0.0 66228 864 ? Ss Aug29 0:00 /usr/sbin/sshd
root 542 0.0 0.0 21720 236 ? Ss Aug29 0:00 xinetd -stayalive -pidfile /var/run/xinetd.pid
root 553 0.0 0.0 66412 652 ? Ss Aug29 0:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
root 555 0.0 0.0 66412 652 ? S Aug29 0:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a pam -n 2
root 574 0.0 0.1 82644 1928 ? Ss Aug29 0:00 sendmail: accepting connections
smmsp 583 0.0 0.1 78228 1464 ? Ss Aug29 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root 595 0.0 0.1 175216 1784 ? Ss Aug29 0:00 /usr/sbin/httpd
apache 606 0.0 0.1 175216 1768 ? S Aug29 0:00 /usr/sbin/httpd
root 607 0.0 0.0 20028 868 ? Ss Aug29 0:00 crond
root 614 0.0 0.0 4068 84 tty1 Ss+ Aug29 0:00 /sbin/mingetty console
root 615 0.0 0.0 4068 84 tty2 Ss+ Aug29 0:00 /sbin/mingetty tty2
root 724 0.0 0.1 13372 1052 ? Rs 08:35 0:00 ps aux
#vzctl enter 101
entered into CT 101
#exit
logout
exited from CT 101
#vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 19 running 192.168.1.101 server101.sit.com
#ls /vz/template/cache/
centos-6-x86_64.tar.gz
#cat /proc/vz/veinfo
101 2 19 192.168.1.101
0 0 288
#vzctl status 101
CTID 101 exist mounted running
#vzlist -o ctid,diskinodes.s -s diskinodes.s
CTID DINODES.S
101 961920
#vzlist -o name 101
NAME
server101
#ls -l /etc/vz/names/ | grep /101.conf
lrwxrwxrwx 1 root root 21 Aug 29 20:25 server101 -> /etc/vz/conf/101.conf
#grep NAME= /etc/vz/conf/101.conf
NAME="server101"
HOSTNAME="server101.sit.com"
#vzctl set 101 --description "Container 101
owner - Willy
purpose - test the func of OpenVZ" --save
UB limits were set successfully
CT configuration saved to /etc/vz/conf/101.conf
#vzlist -o description 101
#vzctl stop CTID
Stopping container ...
Container was stopped
Container is unmounted
#vzctl destroy CTID

◎、Above information is the brief introduction about the usage of the container with OpenVZ on the CentOS 6.7 x64. You can see that for more detail information if you have the interesting. That’s all for today, see you next time!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
This site is protected by WP-CopyRightPro