This article covers most commonly used OpenVZ commands that can be useful for system administrator who are using OpenVZ:
1. To list running VPSs on the node:
[Command ]# vzlist
Code:
[B]Example:[/B] # vzlist CTID NPROC STATUS IP_ADDR HOSTNAME 101 112 running xx.xx.xx.xx server1.24x7.com 102 54 running xx.xx.xx.xx server2.24x7.com
[Command ]# vzlist -a
Code:
[B]Example:[/B] # vzlist -a CTID NPROC STATUS IP_ADDR HOSTNAME CTID NPROC STATUS IP_ADDR HOSTNAME 101 112 running xx.xx.xx.xx server1.24x7.com 102 54 running xx.xx.xx.xx server2.24x7.com 103 - stopped xx.xx.xx.xx server3.24x7.com
[Command ]# vzctl start CTID
Code:
[B]Example:[/B] # vzctl start 110
[Command ]# vzctl stop CTID
Code:
[B]Example:[/B] # vzctl stop 110
[Command ]# vzctl status CTID
Code:
[B]Example:[/B] # vzctl status 110 CTID 116 exist unmounted down
[Command ]# vzctl restart CTID
Code:
[B]Example:[/B] # vzctl restart 110 Logging into a container
[Command ]# vzctl enter CTID
Code:
[B]Example:[/B] # vzctl enter 106 entered into CT 106 Suspend and delete a container
[Command ]# vzctl destroy CTID
9. To suspending a container:
[Command ]# vzctl suspend CTID
10. To set hostname for a Server:
[Command ]# vzctl set CTID --hostname New_hostname --save
11. To add new IP to VPS:
[Command ]# vzctl set CTID --ipadd xx.xx.xx.xx --save
12. To delete IP from the VPS
[Command ]# vzctl set CTID --ipdel xx.xx.xx.xx --save
13. To reset root password of the VPS:
[Command ]# vzctl set CTID --userpasswd root:new_password --save
14. To add nameserver IP to VPS:
[Command ]# vzctl set CTID --nameserver xx.xx.xx.xx --save
15. To executes command inside container from the node:
[Command ]# vzctl exec CTID command
Code:
[B]Example:[/B] # vzctl exec 101 df -h Filesystem Size Used Avail Use% Mounted on /dev/simfs 130G 89G 27G 78% / none 8.0G 4.0K 8.0G 1% /dev none 8.0G 0 8.0G 0% /dev/shm
[Command ]# vzcalc -v CTID
Code:
[B]Example:[/B] # vzcalc -v 101 Resource Current(%) Promised(%) Max(%) Low Mem 1.32 343754532205.77 343754532205.77 Total RAM 16.50 n/a n/a Mem + Swap 5.61 75011961258353.81 n/a Alloc. Mem 28.13 75011961258353.81 75011961258353.81 Num. Proc 0.08 n/a 3607713474246657.00 -------------------------------------------- Memory 28.13 75011961258353.81 3607713474246657.00
[Command ]# vzctl set CTID --capacity sys_timen --save
I hope this has been informative for you and I would like to thank you for reading it.