View Source

h1. Administering PostgreSQL on Solaris

h2. Upgrading From Older Version Of PostgreSQL

h2. Managing PostgreSQL Services on Solaris

h3. PostgreSQL and SMF integration

PostgreSQL has been integrated with [SMF|http://opensolaris.org/os/community/smf/] in [Solaris Express Developer Edition (SXDE)|http://developers.sun.com/sxde/]and [Solaris 10 8/07 or later|http://www.sun.com/software/solaris/index.jsp]. If you are using Solaris 10 11/06 or earlier and want to SMF enable PostgreSQL, see refer to this [How-to Guide| http://www.sun.com/software/solaris/howtoguides/postgresqlhowto.jsp#2]

As of Solaris 10 8/07 and SXDE 1/08, Postgres 8.1 and 8.2 are shipped with the operating system, and there are two corresponding SMF services called postgresql:version_81 and postgresql:version_82 respectively. These services can be configured to use any directories for executables and data, but by default these properties are set to:

* Postgres 8.1:
** Executable = /usr/bin
** Data = /var/lib/pgsql/data

* Postgres 8.2
** Executable = /usr/postgres/8.2/bin
** Data = /var/postgres/8.2/data

For instructions on how to change the above properties, refer to the next section.

h3. Running/Configuring PostgreSQL using SMF Commands

PostgreSQL can easily be started using the SMF command after Solaris is installed. By default, the services are disabled. To see the current service status, run _svcs postgresql_ from the command prompt.

To start Postgres, follow the steps below:

*PostgreSQL 8.1:*
# As root, make sure the default data directory is owned by the user postgres and su to postgres:
\\ # _chown postgres:postgres /var/lib/pgsql/data_
\\ # _su - postgres_
# Create PostgreSQL DB cluster:
$ _/usr/bin/initdb -D /var/lib/pgsql/data_
# As root, use the SMF's svcadm command to start PostgreSQL:
\\# _/usr/sbin/svcadm enable postgresql:version_81_

*PostgreSQL 8.2:*
# As root, su to postgres:
\\ # _su - postgres_
# Create PostgreSQL DB cluster:
$ _/usr/postgres/8.2/bin/initdb -D /var/postgres/8.2/data_
# As root, use the SMF's svcadm command to start PostgreSQL:
\\ # _/usr/sbin/svcadm enable postgresql:version_82_

The binaries for PostgreSQL 8.1 and 8.2 are located in /usr/bin and /usr/postgres/8.2/bin, respectively. To use 8.2, make sure to add /usr/postgres/8.2/bin to PATH.

It is possible to run both PostgreSQL 8.1 and 8.2 servers at the same time as long as the port numbers are different.

The data directory used above are the defaults, but you can put the database anywhere. To change the SMF property for data directory, do the followings:

# Display the current properties
\\ # _svcprop -p postgresql version_82_
# Change the value of the data property
\\ # _svccfg -s postgresql:version_82 setprop postgresql/data="/pgdata"_
\\ # _svcadm refresh postgresql:version_82_
# Check to make the new value is correct
\\ # _svcprop -p postgresql version_82_

To change the property for the Postgres executables, you can follow the same steps above except use the postgresql/bin property name instead.

See postgres_82 man page (e.g. run "man postgres_82" from the command prompt) for more information.\\

h3. Running PostgreSQL in Solaris Containers

A Solaris Container is the combination of a Solaris Zone and Resource Management facility. Sometimes the terms 'Container' and 'Zone' are used interchangeably. For more info, check out the [Zones Community| http://opensolaris.org/os/community/zones/] on OpenSolaris.org.

Setting up Solaris Container to run Postgres 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 Postgres binary, you can still run different versions even in sparse root zones by just placing the binary in the private filesystem.

This [blog entry| http://blogs.sun.com/robertlor/entry/virtualization_and_resource_management_in] 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 Postgres. By default, the installed Postgres binary is shared with all zones.



The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact