ilreme's blog
Published 2007. 8. 7. 17:48
Starting PostgreSQL for the First Time OS

Once you have successfully installed Solaris 10 6/06 (or separate PostgreSQL packages for earlier Solaris 10 releases), there are a few steps that you will need to perform before you can start the database.

  1. Create a Solaris OS user and group that will be used to administer PostgreSQL. If you choose to use an existing user, skip this step and proceed to Step 2.
    Note: PostgreSQL cannot be run as root user.

    For example, to create a user called "postgres" and assign it to a "postgres" group, execute the following commands as root. Make sure the directory /export/home exists:
    # groupadd postgres 
    # useradd -c 'PostgreSQL user' -d /export/home/postgres 
    -g postgres -m -s /bin/bash postgres
  2. The next step is to decide on a directory to create the database and ensure that the permissions are set correctly. The default location is /var/lib/pgsql/data, but it can be placed anywhere. In fact, in a production environment, you should place it in its own filesystem partition, with consideration for space and growth, performance and availability.

    To use the default directory with the Solaris user called "postgres", execute the following commands to set the ownership and permissions:
    # chown postgres /var/lib/pgsql/data 
    # chmod 700 /var/lib/pgsql/data
    
  3. You are now ready to create a database cluster. Login as "postgres" or another user you've selected to run the database and execute the initdb command.

    To create a database cluster in /var/lib/pgsql/data, execute the following command:
    $ initdb -D /var/lib/pgsql/data
    
  4. PostgreSQL is now ready to be started using the following command:
    $ pg_ctl -D /var/lib/pgsql/data -l postmaster.log start
    
  5. You can now test the running database.

    To connect to a database called "postgres" running on a default port, execute the following command:
    $ psql postgres
    

To configure the database, modify the postgresql.conf file in the database cluster directory used in step 3. For tuning tips on Solaris, visit http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp.