Find the answer to your Linux question:
Results 1 to 1 of 1
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Apr 2008

    Arrow [SOLVED] open vz kernal installation and management of (vps,containers) virtual priva

    This article deals with how to compile an an open Vz kernal on a centos5.2 platform.
    Hardware and os requirement's
    Pentium4, AMD64 for good performance
    1gb Ram for 1to4 container running on the sever 20 Gb HDD
    centos 5.0 or 5.2


    1. First set up the yum repositary by downloading the reopsitay from openvz website.
    [root@vm ~]#wget
    just plece it in the yum.repos.d directory

    2. Installing the kernal via yum
    [root@vm ~]#yum install ovzkernel

    3. setup the sysctl.conf file such that the ip is forwared and other kernal parametres are set
    net.ipv4.ip_forward = 1
    kernel.sysrq = 1
    Add the strings in the sysctl
    net.ipv4.conf.default.proxy_arp = 0
    net.ipv4.conf.default.send_redirects = 1
    net.ipv4.conf.all.send_redirects = 0

    4.sysctl -p

    5. Setting up the grub
    check the grub that the new kernal is placed correctly.
    title CentOS (2.6.18-92.1.13.el5.028stab059.6)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-92.1.13.el5.028stab059.6 ro root=LABEL=/ rhgb quiet
    initrd /initrd-2.6.18-92.1.13.el5.028stab059.6.img
    title CentOS (2.6.18-92.el5)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet
    initrd /initrd-2.6.18-92.el5.img

    6. Disable Selinux
    [root@vm ~]#vi /etc/sysconfig/selinux SELINUX=disabled
    7. Reboot the box

    8. check the kernal which is booted
    [root@vm ~]#uname -a
    Linux 2.6.18-92.1.13.el5.028stab059.6 #1 SMP Fri Nov 14 20:22:51 MSK 2008 i686 athlon i386 GNU/Linux

    9.start the open vz service
    [root@vm ~]#service vz start

    10. installing the utilities via yum
    yum install vz*
    it will install all the utilities and commands for vz.

    11.Restart the vz once
    [root@vm ~]#service vz restart

    12.installing the template via yum
    yum install vztmpl-centos-4-2.0-2
    alernatively it can be downloaded too

    13.preparing the cache for the template
    [root@vm ~]#vzpkgcache

    14.list the packages installed
    [root@vm ~]#vzpkgls

    15.create the container
    [root@vm ~]#vzctl create 102 --ostemplate centos-4-i386-minimal

    16. Adding hostname for container
    [root@vm ~]#vzctl set 102 --hostname My works - Powered by CO.CC –save

    17. Adding ip for container
    [root@vm ~]#vzctl set 102 --ipadd –save

    18. Adding nameserver to container
    [root@vm ~]#vzctl set 102 --nameserver –save

    19.To start container while server reboot

    [root@vm ~]#vzctl set 102 --onboot yes --save

    20. starting the container
    [root@vm ~]#vzctl set 102 --userpasswd root:bigjoe

    21.listing the container
    [root@vm ~]# vzlist -a
    102 3 running

    22. entering into the container that has been created
    [root@vm ~]# vzctl enter 102
    entered into CT 102
    [root@www /]#

    23. installing yum and other essential services to container
    [root@vm ~]# vzyum 102 install httpd
    [root@vm ~]# vzyum 102 install yum
    starting the httpd
    [root@vm ~]# vzctl exec 102 service httpd start

    24. Few commands

    To destroy a container
    1st stop the container
    [root@vm ~]#vzctl stop 102
    [root@vm ~]#vzctl destroy 102
    To check cpu utilization
    [root@vm ~]# vzcpucheck

    Current CPU utilization: 3000 Power of the node: 100697

    To set cpu limits such that cpu canot cross 10% usage

    [root@vm ~]# vzctl set 101 --cpulimit 10 –save

    Setting CPU limit: 10 Saved parameters for CT 101

    Resource calculation

    [root@vm /]# vzcalc -v 101

    Resource Current(%) Promised(%) Max(%)
    Low Mem 0.12 9.08 9.08
    Total RAM 0.35 n/a n/a
    Mem + Swap 0.12 7.86 n/a
    Alloc. Mem 0.16 9.82 18.97
    Num. Proc 0.04 n/a 2.93
    Memory 0.35 9.82 18.97

    Diskspace checking of the container
    [root@vm ~]# vzctl exec 101 df -h
    Filesystem Size Used Avail Use% Mounted on
    simfs 1.0G 104M 921M 11% /

    Taking backup of the containers

    download the utility form
    [root@vm ~]# vzdump 101
    INFO: starting backup for VPS 101 (/vz/private/101)
    WARN: online backup without suspend/snapshot
    WARN: this can lead to inconsistent data
    INFO: Creating archive '/vz/dump/vzdump-101.tar' (/vz/private/101)
    Total bytes written: 95262720 (91MiB, 68MiB/s)
    INFO: backup for VPS 101 finished successful (0.02 minutes)
    the dump loacation is
    [root@vm dump]# cd /vz/dump/
    [root@vm dump]# ls
    vzdump-101.log vzdump-101.tar

    Restoring the containers
    (dont try to restore on the same Ctid )
    [root@vm dump]# vzdump --restore /vz/dump/vzdump-101.tar 103
    INFO: extracting archive '/vz/dump/vzdump-101.tar'
    INFO: extracting configuration to '/etc/vz/conf/103.conf'
    INFO: restore successful
    [root@vm dump]# vzlist
    102 3 running My works - Powered by CO.CC
    [root@vm dump]# vzlist -a
    101 - stopped
    102 3 running My works - Powered by CO.CC
    103 - stopped

    Creating plans and managing allocation of resources via customized scripts
    This can be achieved by modifying the following scripts
    [root@vm ~]#cd /etc/sysconfig/vz-scripts

    [root@vm ~]#cp ve-vps.basic.conf-sample vps.basic.conf

    [root@vm ~]#cp ve-vps.light.conf-sample vps.light.conf
    After editing the file vps.basic.conf you can start creating containers

    [root@vm ~]#vzctl create 101 --ostemplate centos-4-i386-minimal --config vps.basic
    [root@vm ~]#vzctl set 101 --onboot yes --save
    The open vz documentation can be downloaded from the following location
    Last edited by davidanand; 02-04-2009 at 11:20 AM.
    David Anand
    -->Success is the list of failures ...!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts