Saturday, October 12, 2013

Important openVZ Commands

  • VZ Information To list all the running/stopped VPS in the node
vzlist -a

  • List all the running VPS in the node it will show only running VPS.
vzlist


  • Display the templates present in the server
vzpkgls


  • Creating a VPS To create a VPS with VEID 1212 and OStemplate centos-cpanel with vps.basic configuration
vzctl create 1212 --ostemplate centos-cpanel -.config vps.basic


  • Deleting a VPS To destroy a VPS with VEID 1212
vzctl destroy 1212


  • Configuring VPS (The changes are saved in /etc/vz/conf/<VEID>.conf) To automatically boot when a node is up
vzctl set 1212 --onboot yes --save


  • Set hostname
vzctl set 1212 --hostname test1212.my.org --save


  • Add an IP address
vzctl set 1212 --ipadd 192.123.192.2 --save


  • Delete an IP address
vzctl set 1212 --ipdel 192.123.192.2 --save


  • Set the name servers
vzctl set 1212 --nameserver 192.122.12.1 --save


  • Set the root password of VPS 1212
vzctl set 1212 --userpasswd root:password


  • Set shortname for VPS
vzctl set 1212 --name test1212 --save


  • Start/Stop/Restart VPS To start a VPS
vzctl start 1212
vzctl stop 1212
vzctl restart 1212


  • Start a disabled VPS
vzctl start 1212 --force


  • Stop a VPS
vzctl stop 1212


  • Restart a VPS
vzctl restart 1212


  • Check the status of a VPS
vzctl status 1212

  • Disable a VPS
vzctl set 1212 --disabled yes


  • Enable a VPS
vzctl set 1212 --disabled no


  • Suspend a VPS
vzctl suspend 1212


  • Resume a VPS
vzctl resume 1212

  • Run yum update on a VPS
vzyum 1212 -y update


  • Install a package using yum on VPS
vzyum 1212 -y install package


  • Install a package using rpm on VPS
vzrpm 1212 -ivh package


  • 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


  • Enter into a VPS 1212
vzctl enter 1212


  • Execute a command in VPS from the hardware node 1212
vzctl exec 1212 command
vzctl exec 1212 df -h


  • Managing Disk Quotas To assign disk quotas – First limit is soft limit, second limit is hard limit
vzctl set 1212 --diskspace 10485760 --save  --> for setting 10GB
OR
vzctl set 1212 --diskspace 1048576 --save   --> for setting 1GB


  • Assign disk inodes
vzctl set 1212 --diskinodes 90000:91000 --save


  • Check the disk quota of a VPS
vzquota stat 1212 -t


  • Managing CPU quota To display the available CPU power
vzcpucheck


  • Set the number of CPUs available to a VPS
vzctl set 1212 --cpus 2 --save


  • Set the minimum and maximum CPU limits
vzctl set 1212 --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


  • Set kmem
vzctl set 1212 --kmemsize 2211840:2359296 --save


  • Set privvmpages
vzctl set 1212 --privvmpages 2G:2G --save


*Note 1212 is the container or vps id.

No comments:

Post a Comment

Do Write about the Blog and Welcome to the world where open source is every thing :-)