10 June 2016

How to change Solaris Zones configurations online

I assume you are aware that Solaris Zones are one of the most valuable features of Solaris since years. In this post I focus on the "Live Zone Reconfiguration" feature available since
Solaris 11.2 for Solaris Zones and since Solaris 11.3 for Kernel Zones. CPU pools, filesystems, network and disk configurations can be changed while Solaris Zones are running.

1. Limit CPU usage of a Solaris Zone using dedicated-cpu

By default Solaris Zones share the CPUs with the global and all other local Zones.
Our sample Zone currently uses 16 virtual CPUs.

# zlogin v0131 psrinfo | wc -l

16


We can now assign 4 dedicated virtual CPUs to be used by this Zone only.

# zonecfg -z v0131 -r "add dedicated-cpu; set ncpus=4; end"

zone 'v0131': Checking: Adding dedicated-cpu

zone 'v0131': Applying the changes

# zlogin v0131 psrinfo | wc -l

4
The “zonecfg -r” changes the configuration of the running Zone only.
Make sure to run the command once again to make the configuration persistent for the next Zone reboot.

# zonecfg -z v0131 "add dedicated-cpu; set ncpus=4; end"


2. Create and mount an additional ZFS filesystem

# zfs create v0131_data/myapp

# zonecfg -z v0131 -r "add fs; set type=zfs; set dir=/myapp; set special=v0131_data/myapp; end"

zone 'v0131': Checking: Mounting fs dir=/myapp

zone 'v0131': Applying the changes


# zlogin v0131 mount | grep myapp

/myapp on /myapp read/write/setuid/devices/rstchown/nonbmand/exec/xattr/atime/zone=v0131/nozonemod/sharezone=4/dev=d50045 on Fri Jun 10 11:56:19 2016


And make it persistent

# zonecfg -z v0131 "add fs; set type=zfs; set dir=/myapp; set special=v0131_data/myapp; end"

Adding network interfaces and disk devices are similar to the samples above.

No comments: