Oracle Blog

Blog for robertlor

Wednesday Jan 16, 2008

Many people today use virtualization technology to consolidate applications to fewer and more powerful systems to improve system utilization, save datacenter space and power. One way to achieve this on Solaris is through Zones . Combined with Solaris Resource Management , a Solaris Zone provides a virtualized environment where resources such as CPU and memory can be controlled.

To demonstrate how this works, I will show a simple example of how to run PostgreSQL in Solaris Zone and adjust CPU cap as appropriate for this application. You can also restrict other resources such as memory or number of processes in a zone, but this example only covers CPU capping.

1) Create a new zone. Here is a script you can use to automate the zone creation. Save it to a file called create_zone.sh, and run it like this ./create_zone.sh pgzone /zones
By default, this script assign the zone 20% of a CPU. You can adjust this number(ncpus) as necessary.

4) In the global zone, using another terminal window, run the following command to see cpu usage for each zone. Note the zone that Postgres is running should cap to around 20% if you have a single CPU system.

# prstat -Z

5) You can dynamically adjust the amount of CPU assigned to the zone using the prctl command. In another terminal window, run:

# prctl -n zone.cpu-cap -i zone

So in a nutshell, that's how you can use Solaris Zones and Resource Management to improve system utilization in a virtualization environment. As I mention in the beggining,
you can also cap other resouources as well which make the combination of Solaris Zones and resource management very powerful.