Creating VPS and Managing them with OpenVZ Commands

OpenVZ is a world leader running VPSs and used by most of the Data Centers to run on servers.

For those who dont know what OpenVZ is

OpenVZ (Open Virtuozzo) is an operating system-level virtualization technology based on the Linux kernel and operating system. OpenVZ allows a physical server to run multiple isolated operating system instances, known as containers, Virtual Private Servers (VPSs), or Virtual Environments (VEs). Each container is a separate entity, and behaves largely as a physical server would.

How to use OpenVZ

Mostly OpenVZ is used with command line rather than graphical tools which is a third party thing. OpenVZ commands are really less in number but you can do whatever you need to create a container that holds a OS that is isolated from surroundings.

Here are some commands that help you to run OpenVZ

List of general commands and usage OpenVZ

Its easy use OpenVZ to create a new container of VPS. Bellow is the listing of all of OpenVZ general commands and usage. For trying out, You must have OpenVZ installed on your server host node and access to it.

Creating a new VPS

// Create new VPS with ID 101 with the template centos-5.2-default

    vzctl create 101 –ostemplate centos-5.2-default

// Add IP or assign an IP a.b.c.d to the VPS 101

    vzctl set 101 –ipadd a.b.c.d –save

// Remove an IP a.b.c.d from VPS 101

    vzctl set 101 –ipdel a.b.c.d –save

// Add a nameserver a.b.c.d to VPS 101

    vzctl set 101 –nameserver a.b.c.d –save

// Set password 123456 for the 101 VPS

    vzctl set 101 –userpasswd root:123456

// Set the VPS to start on server reboot

    vzctl set 101 –onboot yes –save

// Allocate diskspace to the VPS 101 10G:11G means Softquota:Hardquota

    vzctl set 101 –diskspace 10G:11G –save

// Add IP a.b.c.d to the VPS 101 and set the nameservers a.b.c.d to VPS 101

    vzctl set 101 –ipadd a.b.c.d –nameserver a.b.c.d –save

Controling a VPS

// Start the VPS 101

    vzctl start 101

// Stop 101 VPS

    vzctl stop 101

// Restart 101 VPS

    vzctl restart 101

// Enter into 101 VPS

    vzctl enter 101

// Display the list of active VPS.s

    vzlist

// Display the list of all VPS.s

    vzlist -a

// Destroy the VPS (Before thsis, VPS should be stopped)
    vzctl destroy 101

// Show resources usage on VPS

    vzcalc -v 101

// Execute commands against the VPS (in this case .df -m.)

    vzctl exec 101 df -m

// Run yum update on VPS

    vzyum 101 -y update

// Install package using yum on VPS

    vzyum 101 -y install package

// Install package using rpm on VPS

    vzrpm 101 -ivh package

Templates
OpenVZ uses OS templates to load to a container. Templates are snapshots of an OS that can be deployed to a container in less than a minute and can boot in no time.

The templates are located under /vz/template/cache

When creating a new VPS you have to use the full template name eg. if the archived template name is “centos-4-i386-default-4.7-20082227.tar.gz” the template name you will have to use is “centos-4-i386-default-4.7-20082227?
If you need more templates you can download them from: http://wiki.openvz.org/Download/template/precreated
Configuration Files
The configuration files for every VPS is located under /etc/vz/conf/VPSID.conf

This file can be modified to suit your needs for every VPS but a VPS restart will be needed. Based on /etc/vz/conf/VPSID.conf basic config files for VPS can be created and saved somewhere on the server and can be used when creating new VPS’s to automatic allocate this settings on new VPS’s.

To create a VPS using a saved config file use this command:

    vzctl create 101 –ostemplate centos-5-i386-default –config vps.basic

Reference
 http://wiki.openvz.org  | http://en.wikipedia.org/wiki/OpenVZ






Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.