OpenVZ operation commands

This note includes useful commands to adjust guest OS resources allocation at OpenVZ environment.

Monitor kmemsize usages

cat /proc/user_beancounters

Version: 2.5
    uid  resource           held    maxheld    barrier      limit    failcnt
    vm01: kmemsize         836919    1005343    2752512    2936012          0

May increase the barrier and limit

vzctl set vm01 --kmemsize [barrier in number]:[limit in number] --save
Validate config
vzcfgvalidate /etc/vz/conf/vm01.conf
Monitor Disk usage
vzquota stat vm01
resource          usage       softlimit      hardlimit    grace
1k-blocks         327664         1048576        1153434
    inodes          18857          200000         220000
Increase diskspace
vzctl set vm01 --diskspace 20G:25G --save
Increase double of inodes
vzctl set vm01 --diskinodes $(( 200000*2 )):$(( 220000*2 )) --save
Set CPU allocation
vzctl set vm01 --cpuunits 1000 --save
vzctl set vm02 --cpuunits 1000 --save
vzctl set vm03 --cpuunits 2000 --save
If a CPU intensive application is running on each guest OSs, then vm03 would be given 2 times as much cpu time of the other twos.
GuestOS will not be allocated more than 25 percent of the host CPU
vzctl set vm01 --cpulimit 25 --save

Comments