Académique Documents
Professionnel Documents
Culture Documents
As you know, system resources like CPU,MEMORY,SWAP can be limited to Solaris local zones using capping.We do the resource capping by just using "zonecfg" command. But the changes are instantaneous ? No. You need to reboot the local zone in a order to take the settings effect.Here we will see how to make the changes instantaneous. But instantaneous
is not permanent.You need to update zonecfg to make persist across the local zone reboot. Here we are going to see how to modify the physical memory,SWAP,CPU & locked memory on the fly while zone is running. These changes are immediate effect.
We can see the capped memory value using zonecfg command as well,but there shouldn't be any memory value modification on the system after the zone boot.
# zonecfg -z sol1 info zonename: sol1 zonepath: /export/zone/sollz1 brand: native autoboot: false bootargs:
pool: limitpriv: scheduling-class: ip-type: shared hostid: inherit-pkg-dir: dir: /lib inherit-pkg-dir: dir: /platform inherit-pkg-dir: dir: /sbin inherit-pkg-dir: dir: /usr capped-cpu: [ncpus: 1.00] capped-memory: physical: 100M
As per the above command output ,capped memory has been set as 100M for local zone "sol1" . Now we will see how to modify that value on fly.
# rcapadm -z sol1 -m 200M # rcapstat -z 1 1 id zone 2 sol1 # rcapstat -z 1 1 id zone 2 sol1 nproc 31 vm 146M rss 97M cap 200M at avgat 110M 0K pg avgpg 73M 0K nproc 31 vm 146M rss 97M cap 100M at avgat 110M 0K pg avgpg 73M 0K
After executing rcapadm command ,system takes few seconds to take effect. So please be patient.Now you can see system memory capping has been changed from 100M to 200M.
Zones-Dynamic swap:
To check the currently capped swap space,
# /bin/prctl -n zone.max-swap `pgrep -z sol1 init` process: 1901: /sbin/init NAME RECIPIENT zone.max-swap PRIVILEGE system VALUE 16.0EB FLAG max ACTION deny
As per the above ,there is no restriction has been set for swap. To set the swap to specific value,
sol1 init`
Oops.We got an error while setting new swap value for zone. let us check the usage of prctl.
usage: Report resource control values and actions: prctl [-P] [-t [basic | privileged | system] [-n name] [-i process | task | project | zone] id ... -P space delimited output -t privilege level of rctl values to get -n name of resource control values to get -i idtype of operand list Manipulate resource control values: prctl [-t [basic | privileged | system] -n name [-srx] [-v value] [-p pid ] [-e | -d action] [-i process | task | project | zone] id ... -t privilege level of rctl value to set/replace/delete/modify -n name of resource control to set/replace/delete/modify
-s set new resource control value -r replace first rctl value of matching privilege -x delete first rctl value of matching privilege, value, and recipient pid -v value of rctl to set/replace/delete/modify -p recipient pid of rctl to set/replace/delete/modify -e enable action of first rctl value of matching privilege, value, and recipient pid -d disable action of first rctl value of matching privilege, value, and recipient pid -i idtype of operand list
"-r" option is used to replace the existing value.We suppose to use "-s" option to set new value. Let us try this as well.
sol1 init`
prctl: failed to create resource control zone.max-swap for pid 1901: Invalid argument bash-3.00#
After a lot of research, I got the workaround for this issue.prctl command will work only if you have already configured swap,locked memory and capped-cpu respectively for each type of resource. In my zone setup , i don;t have pre-configured swap.That's why i was getting error while modifying it and unable to set new value as well. So the bottom line is , if you have existing capped values for swap,locked memory & cpu ,you can modify it.Otherwise you can't modify these values are in fly.
# zonecfg -z sol1 zonecfg:sol1> select capped-memory zonecfg:sol1:capped-memory> info capped-memory: physical: 100M zonecfg:sol1:capped-memory> set swap=100m
zonecfg:sol1:capped-memory> set locked=10M zonecfg:sol1:capped-memory> info capped-memory: physical: 100M [swap: 100M] [locked: 10M] zonecfg:sol1:capped-memory> end zonecfg:sol1> verify zonecfg:sol1> commit zonecfg:sol1> exit # zoneadm -z sol1 reboot
sol1 init`
# /bin/prctl -n zone.max-swap `pgrep -z sol1 init` process: 7652: /sbin/init NAME PRIVILEGE RECIPIENT zone.max-swap privileged system 16.0EB max deny 150MB deny VALUE FLAG ACTION
zone.max-locked-memory privileged system # prctl -n zone.max-locked-memory -r -v 20M `pgrep -z sol1 init` # /bin/prctl -n zone.max-locked-memory `pgrep -z sol1 init` process: 7652: /sbin/init NAME PRIVILEGE RECIPIENT zone.max-locked-memory privileged system bash-3.00# 16.0EB max deny 20.0MB deny VALUE FLAG ACTION 16.0EB max deny 10.0MB deny
Zones:Dynamic CPU:
We can modify the number of CPU's using prctl command if capped-cpu is already configured on local zones.
# /bin/prctl -n zone.cpu-cap process: 9383: /sbin/init NAME PRIVILEGE RECIPIENT zone.cpu-cap privileged system 4.29G 100 VALUE
FLAG
ACTION
inf
deny deny
Existing value is showing as 100 . In zonecfg we have assigned "ncpus=1" . Which means zone sol1 can use 100% CPU time from one processor. Let us set 200, so that zone sol1 can use 100% time of two CPU's.
# prctl -n zone.cpu-cap -v 200 -r -i zone sol1 # /bin/prctl -n zone.cpu-cap process: 9383: /sbin/init NAME PRIVILEGE RECIPIENT zone.cpu-cap privileged system # 4.29G inf deny 200 deny VALUE FLAG ACTION `pgrep -z sol1 init`
This has been done.Now zone "sol1" can use 2 CPU's completely. Note:Solaris 10 5/08: The zone.cpu-cap resource control sets an absolute limit on the amount of CPU resources that can be consumed by a zone. A value of 100 means 100 percent of one CPU as the project.cpu-cap setting. A value of 125 is 125 percent, because 100 percent corresponds to one full CPU on the system when using CPU caps.Refer:http://docs.oracle.com/cd/E19455-01/8171592/z.config.ov-13/index.html