Monday, November 19, 2007

Starting PostgreSQL as a service in Solaris Express

I just needed to do this, so I thought I'd document the fairly steps to set up PostgreSQL as a service in Solaris Express Developer Edition version 9/07

PostgreSQL is already installed in Solaris Express, and it's set up as a service, but it is disabled by default. Once you have this set up, then PostgreSQL will always be up and running, even after reboots.
  1. Log in as the postgres user, which is pre-created as part of the install of SXDE. I didn't know what the password was, so I had to log in as root first, then change the password using passwd postgres.
  2. Fix the PATH environment variable so that /usr/postgres/8.2/bin is at the front. The default Postgres commands in /usr/bin are for version 8.1 of PostgreSQL
  3. Make sure the directory /var/postgres/8.2/data exists; if not, create it
  4. Initialize your database using the command initdb /var/postgres/8.2/data
  5. Log out of the postgres user
  6. Make sure your default user has rights to manage services. Go to Administration->Users and Groups, select your user, and choose Properties, then select the User Privileges tab, and make sure either System Administrator or Service Management is enabled.
  7. Enable the service using svcadm enable postgresql:version_82
  8. Run svcs -x. If it shows postgresql, there was a problem, and it will tell you where the log file is to see what went wrong. Run svcs | grep postgres and it should show it as enabled.
  9. Create a user in Postgres that matches your current user, so you can log in to the database as that user by running createuser userid. Alternately you can run createuser postgres and log in to the database as postgres.
  10. Verify you can log in to the Postgres server by running the psql command.

1 comment:

slamarr said...

Thank you! I wanted to get postgres up and running as a service on my openSolaris box; you saved me hours of digging around.