Tuesday, December 09, 2008

OpenSolaris 2008.11 and PostgreSQL 8.3


The second supported version of OpenSolaris called OpenSolaris 2008.11 is now officially launched. With the release, I guess now PostgreSQL 8.3 is now "officially" supported on OpenSolaris too (though you could have used it prior  anyway with the development releases of OpenSolaris after the initial OpenSolaris 2008.05 was released).


 Anyway let's quickly look at some tips and how-to which I think could be useful to improve the experience of PostgreSQL 8.3 with OpenSolaris 2008.11.  One way to take a quick drive of OpenSolaris 2008.11 is to also try out the new VirtualBox 2.0.6 and install OpenSolaris 2008.11 in a VM. (Note: If you do plan to access the VM from other systems then use Host Interface instead of NAT to make it easy to access it from outside.)


PostgreSQL 8.3 is not already installed once you install OpenSolaris 2008.11 from the LiveCD. This gives an opportunity for a tweak that I would highly recommend. By default OpenSolaris 2008.11 does not have option for separate ZFS dataset for /var (like Solaris 10 10/08 - U6 does). I would certainly like my PostgreSQL database to be on a separate dataset that I can control PostgreSQL snapshots  independently. Since I know the default PostgreSQL database path for PostgreSQL 8.3 on OpenSolaris is /var/postgres/8.3 I generally create a separate dataset as follows before I use pkg script to install PostgreSQL 8.3


# zfs create -o mountpoint=/var/postgres rpool/postgres


Now I am ready to install the various packages of PostgreSQL 8.3


# pkg install SUNWpostgr-83-server


# pkg install SUNWpostgr-83-client SUNWpostgr-jdbc SUNWpostgr-83-contrib


# pkg install SUNWpostgr-83-docs  SUNWpostgr-83-devel


# pkg install SUNWpostgr-83-tcl SUNWpostgr-83-pl


Now to install PGAdmin3 as follows:


# pkg install SUNWpgadmin3


Even pgbouncer is available in the repository


# pkg install SUNWpgbouncer-pg83


Now that all binaries are installed, let's look on how to get started. Generally the best way to start and stop PostgreSQL 8.3 server is via the svcadm command of OpenSolaris. The SMF manifest for PostgreSQL 8.3 is installed with SUNWpostgr-83-server, however the import of the script does not happen till the next reboot. We can always work that around by doing a quick manual update as follows:


# svccfg import /var/svc/manifest/application/database/postgresql_83.xml


This creates two entries one for 32-bit server instance and one for 64-bit server instance.


# svcs -a |grep postgres
disabled        1:14:44 svc:/application/database/postgresql_83:default_64bit
disabled        1:14:45 svc:/application/database/postgresql_83:default_32bit


Depending on your server/choice you can start the corresponding server. Or 32-bit instance may be just easier to select if there are doubts.


# svcadm enable postgresql_83:default_32bit


# svcs -a |grep postgres
disabled        1:14:44 svc:/application/database/postgresql_83:default_64bit
online          2:12:37 svc:/application/database/postgresql_83:default_32bit


# zfs list rpool/postgres
NAME             USED  AVAIL  REFER  MOUNTPOINT
rpool/postgres  30.4M  11.8G  30.4M  /var/postgres


The client psql is still not in the default path. The path /usr/postgres/8.3/bin should be in your search PATH. (or if you are using 64-bit add /usr/postgres/8.3/bin/64).

# /usr/postgres/8.3/bin/psql -U postgres postgres
Welcome to psql 8.3.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=#





For people who are using PostgreSQL 8.2 on OpenSolaris 2008.05 already, there is a way to get to PostgreSQL 8.3. First you have to update your OpenSolaris 2008.05 to OpenSolaris 2008.11 image using


# pkg image-update


Then install PostgreSQL 8.3 binaries as above and also install an additional package


# pkg install SUNWpostgr-upgrade


If there are more question feel free to leave a comment.








Post a Comment