Running PostgreSQL in Solaris Zones
Sometimes the terms 'Zones' and 'Containers' are used interchangeably. A Solaris Container is generally defined as the combination of a Solaris Zone and Resource Management facility. For more info, check out the Zones Community on OpenSolaris.org.
Setting up Solaris Zones to run PostgreSQL is quite simple, but before delving into the specifics, there are several options to consider:
- Install PostgreSQL in the global zone and run different PostgreSQL instances in different sparse root zones. The PostgreSQL binary will be shared by all zones, but not the data. This method will simplify PostgreSQL upgrade as all zones will automatically see the same binary.
- Install PostgreSQL in a whole root zone so different zones will have their own binary. In this approach, you can run different versions of PostgreSQL in different zones.
- A combination of 1 & 2. Install PostgreSQL in the global zone, create some sparse root zones to run some instances of PostgreSQL using the shared binary, and create some whole root zones to run their own copy of PostgreSQL.
The above scenarios apply only if Solaris packages are used. If you build your own PostgreSQL binary, you can still run different versions even in sparse root zones by just placing the binaries in different locations in the non-global zone's local filesystem.
Running PostgreSQL in Multi-Zones Environment
The combination of Solaris Zones and Resource Management are very powerful and can be used effectively, especially in a hosting environment, because it offers both virtualization and resource control that allows a single machine to be shared by many users securely and with very flexible resource provisioning based on users needs. Joyent is a good example of a hosting company that sell their hosting services by giving each customer a Solaris Container. From the customer's perspective, it's as if the user has a machine to himself, but in reality, he only has a slice of the system.
In this kind of hosting environment, it is quite simple to setup PostgreSQL such that every customer can run his own instance of the PostgreSQL database in the Zone assigned to him and use the shared PostgreSQL binaries installed in the shared global filesystem.
This blog entry has a step by step example demonstrating the first approach, with PostgreSQL binary installed in the global zone and using a sparse root zone to run PostgreSQL. By default, the installed PostgreSQL binary is shared with all zones.