CentOS 5
Sponsored Link

Operations
  This is the example of operating OpenVZ. There are many commands for it and I introduce some of them that we often need to.

[1] Start/Stop/Rstart VPS ( ID is 101 )
[root@ns ~]#
vzctl start 101
# start VPS

Starting VE ...
VE is mounted
Adding IP address(es): 192.168.0.18
Setting CPU units: 1000
Set hostname: www.server-linux.info
File resolv.conf was modified
VE start in progress...
[root@ns ~]#
vzctl stop 101
# stop VPS

Stopping VE ...
VE was stopped
VE is unmounted
[root@ns ~]#
vzctl restart 101
# restart VPS

Restarting VE
Stopping VE ...
VE was stopped
VE is unmounted
Starting VE ...
VE is mounted
Adding IP address(es): 192.168.0.106
Setting CPU units: 1000
Set hostname: www.server-linux.info
File resolv.conf was modified
VE start in progress...
[2] Switch console to VPS ( ID is 101 )
[root@ns ~]#
vzctl enter 101
# switch to 101

entered into VE 101
[root@www /]#
[root@www /]#
exit
# back to HostOS


exited from VE 101
[root@ns ~]#
[3] Display list of VPS ( display all if input the command with -a option )
[root@ns ~]#
vzlist
# show list

 
VEID
NPROC
STATUS
IP_ADDR
HOSTNAME

 
101
2
running
192.168.0.18
www.server-linux.info

[root@ns ~]#
vzlist -a
# show list all

 
VEID
NPROC
STATUS
IP_ADDR
HOSTNAME

 
101
2
running
192.168.0.18
www.server-linux.info

 
102
-
stopped
192.168.0.19
mail.server-linux.info
[4] Remove VPS ( ID is 101 )
[root@ns ~]#
vzctl stop 101
# stop first

Stopping VE ...
VE was stopped
VE is unmounted
[root@ns ~]#
vzctl destroy 101
# remove

Destroying VE private area: /vz/private/101
VE private area was destroyed
[5] Display resources of VPS ( ID is 101 )
[root@ns ~]#
vzcalc -v 101
# show resources

Resource
Current(%)
Promised(%)
Max(%)

Low Mem
0.04
1.24
1.24

Total RAM
0.03
n/a
n/a

Mem + Swap
0.01
0.26
n/a

Alloc. Mem
0.01
0.26
1.99

Num. Proc
0.00
n/a
0.10

-----------------------------------------------------------
Memory
0.04
1.24
1.99
[6] Ececute a command to VPS ( ID is 101 ). (it's possible to execute it in VPS with normal command )
[root@ns ~]#
vzctl exec 101 df -m
# execute df on 101

Filesystem
1M-blocks
Used
Available
Use%

simfs
1024
149
876
15%
[7] Install or Update with yum to VPS ( IS is 101 ). (it's possible to execute it in VPS with normal command )
# execute update on 101

[root@ns ~]#
vzyum 101 -y update


# install package with yum on 101

[root@ns ~]#
vzyum 101 -y install package


# install package with rpm on 101

[root@ns ~]#
vzrpm 101 -Uvh package
Matched Content