OpenVz commands

Some of commonly used openvz commands

VZ Information To list all the running/stopped VPS in the node

vzlist -a

To list all the running VPS in the node

vzlist

To display the templates present in the server

vzpkgls

Creating a VPS To create a VPS with VEID 101 and ostemplate fedora-core-4 with vps.basic configuration

vzctl create 101 --ostemplate fedora-core-4 -.config vps.basic

Deleting a VPS To destroy a VPS with VEID 101

vzctl destroy 101

Configuring VPS (The changes are saved in /etc/vz/conf/<VEID>.conf) To automatically boot when a node is up

vzctl set 101 --onboot yes --save

To set hostname

vzctl set 101 --hostname test101.my.org --save

To add an IP address

vzctl set 101 --ipadd 10.0.186.1 --save

To delete an IP address

vzctl set 101 --ipdel 10.0.186.1 --save

To set the name servers

vzctl set 101 --nameserver 192.168.1.165 --save

To set the root password of VPS 101

vzctl set 101 --userpasswd root:password

To set shortname for VPS

vzctl set 101 --name test101 --save

Start/Stop/Restart VPS To start a VPS

vzctl start 101

To start a disabled VPS

vzctl start 101 --force

To stop a VPS

vzctl stop 101

To restart a VPS

vzctl restart 101

To know the status of a VPS

vzctl status 101

To get the details of the VPS like VEID, ClassID, number of processes inside each VPS and the IP addresses of VPS

cat /proc/vz/veinfo

To enter into a VPS 101

vzctl enter 101

To execute a command in VPS 101

vzctl exec 101 command --- replace command with the command you need to execute
vzctl exec 101 df -h

Managing Disk Quotas To assign disk quotas – First limit is soft limit, second limit is hard limit

vzctl set 101 --diskspace 10485760 --save  ==>> for setting 10GB
OR
vzctl set 101 --diskspace 1048576 --save   ==>> for setting 1GB

To assign disk inodes

vzctl set 101 --diskinodes 90000:91000 --save

To check the disk quota of a VPS

vzquota stat 101 -t

Managing CPU quota To display the available CPU power

vzcpucheck

To set the number of CPUs available to a VPS

vzctl set 101 --cpus 2 --save

To set the minimum and maximum CPU limits

vzctl set 101 --cpuunits nnnn --cpulimit nn --save 
(cpuunits is a an absolute number (fraction of power of the node) and cpulimit is taken as percentage)

Managing memory quota To display memory usage

vzmemcheck -v

To set kmem

vzctl set 101 --kmemsize 2211840:2359296 --save

To set privvmpages

vzctl set 101 --privvmpages 2G:2G --save

Other Commands To copy/clone a VPS

vzmlocal -C <source_VEID>:<desitnation_VEID>

To disable a VPS

vzctl set 101 --disabled yes

To enable a VPS

vzctl set 101 --disabled no

To suspend a VPS

vzctl suspend 101

To resume a VPS

vzctl resume 101

To run yum update on a VPS

vzyum 101 -y update

To install a package using yum on VPS

vzyum 101 -y install package

To install a package using rpm on VPS

vzrpm 101 -ivh package

 

Refer:http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf
Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: