Welcome to Machine Unix

Search Below

Installing PostgreSQL 9.0 on Solaris 10 Update 9

So with the release of Solaris 10 Update 9, I got excited couple weeks ago. I was waiting for this release for a while and I started playing around a little bit for the first time today because of my hectic schedule. It just so happens that a new release of Postgresql 9.0 is released today and I decided to give it a try to install on Solaris 10 U9. The previous versions of Solaris 10 included several versions of Postgres and you would be able to see all the smf services related to it:

root@solu9# svcs -a | grep postgres
disabled 21:06:33 svc:/application/database/postgresql_83:default_32bit
disabled 21:06:33 svc:/application/database/postgresql:version_81
disabled 21:06:33 svc:/application/database/postgresql_83:default_64bit
disabled 21:06:33 svc:/application/database/postgresql:version_82
disabled 21:06:33 svc:/application/database/postgresql:version_82_64bit

Since Postgres 9.0 is just released today, there is no SMF service yet on Solaris 10 update 9. So I decided to give it a spin with a little smf hacking. Basically what I want to do is to install the 64 bit database server but also let SMF to manage it. The first thing I did was to get the 64 bit package from here, then unpack it.

root@solu9# bunzip2 < postgresql-9.0.0-S10.i386-64.tar.bz2 | tar xpf –
root@solu9# ls -alrth
drwxr-xr-x 2 postgres postgres 2 Sep 20 21:58 postgres
root@solu9# cd /usr/postgres/
root@solu9# mv /root/Downloads/postgres/9.0-pgdg/ .

Just for convenience, I renamed 9.0-pgdg to 9.0 so that the file system would have 9.0 listed with the previous installations:

root@solu9# mv 9.0-pgdg 9.0
root@solu9# ls
8.2 8.3 9.0 jdbc upgrade

Great, so now the directory is in place, it is time to go over SMF and create a new 64 bit Postgresql 9.0 SMF from an existing one. I exported one of the 64 bit SMF into an xml file.

root@solu9# svccfg export postgresql_83 >> postgres.xml

So right now, the file looks like this, but I am going to edit it to look like this. After that, we import the service and we make some adjustments on some of the directories:

root@solu9# svccfg import postgres.xml
root@solau9# svccfg validate postgres.xml
root@solu9# cd /var/postgres/
root@solu9# mkdir -p 9.0/backups
root@solu9# mkdir -p 9.0/data_64
root@solu9# cd 9.0
root@solu9# chown -R postgres:postgres .
root@solu9# cp /lib/svc/method/postgres_83 /lib/svc/method/postgres_90

In the method file, postgres_90, change all the occurences of postgres_83 to postgres_90. We are almost ready, but we need to get the database ready:

root@solu9# chown postgres /var/lib/pgsql/data
root@solu9# chmod 700 /var/lib/pgsql/data
root@solu9# su – postgres
postgres@solu9# initdb -D /var/lib/pgsql/data

Now that the database is initialized and ready, we need to get our newly created SMF online as root:

root@solu9# svcs -a | grep postgres
disabled 21:06:33 svc:/application/database/postgresql_83:default_32bit
disabled 21:06:33 svc:/application/database/postgresql:version_81
disabled 21:06:33 svc:/application/database/postgresql_83:default_64bit
disabled 21:06:33 svc:/application/database/postgresql:version_82
disabled 21:06:33 svc:/application/database/postgresql:version_82_64bit
disabled 22:20:28 svc:/application/database/postgresql_90:default_64bit
root@solu9# svcadm enable svc:/application/database/postgresql_90:default_64bit
root@solu9# svcs -a | grep postgresql_90
online 22:20:28 svc:/application/database/postgresql_90:default_64bit

So our service is now online, let’s login as the user postgres and see if we can connect to it:

root@solu9# su – postgres
postgres@solu9# psql postgres
Welcome to psql 8.1.19 (server 9.0.0), 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

WARNING: You are connected to a server with major version 9.0,
but your psql client is major version 8.1. Some backslash commands,
such as d, might not work properly.

postgres=#

Now I am able to connect my database. I am sure that later versions of Solaris will include the new Postgres 9.0 with proper SMF, but I just wanted to give it a quick spin. I have not tested this thoroughly but everything should work. I might add some updates for my testing later on. For now, enjoy !