PostgreSQL QuickStart
From GangusInternetWiki
Contents |
Introduction
Sun ships official packages (.pkg files) with two versions of PostgreSQL with Solaris 10. All you need to do once they are installed on your Virtual Server is initialize the database cluster, and then enable the service in SMF.
Which version?
In general, unless you have a specific reason to use an 8.0.x version (legacy application, existing environment, etc.), we recommend that you use the 8.2.x version. PostgreSQL 8.2 has a number of performance enhancements, and has proven to be quite stable.
PostgreSQL 8.2
Install / Verify packages
You very likely already have the required packages (SUNWpostgr-82-*) installed on your Virtual Server.
Verify this by using the pkginfo command: 1. $ pkginfo | grep SUNWpostgr-82
You should see the following packages:
- system SUNWpostgr-82-client PostgreSQL 8.2 client tools
- system SUNWpostgr-82-contrib PostgreSQL 8.2 community contributed tools not part of core product
- system SUNWpostgr-82-devel PostgreSQL 8.2 development tools and header files
- system SUNWpostgr-82-docs PostgreSQL 8.2 documentation and man pages
- system SUNWpostgr-82-jdbc JDBC 3 driver for PostgreSQL 8.2
- system SUNWpostgr-82-libs PostgreSQL 8.2 client libraries
- system SUNWpostgr-82-pl PostgreSQL 8.2 additional Perl, Python & TCL server procedural languages
- system SUNWpostgr-82-server PostgreSQL 8.2 database server
- system SUNWpostgr-82-server-data-root PostgreSQL 8.2 database server data directories and root components
- system SUNWpostgr-82-tcl Tcl binding library for PostgreSQL 8.2
If you don't have these packages, you will need to download and install the .pkg files for them before continuing.
Setup DB Cluster
2. Become root:
$ su -
3. Use su to become the postgres user.
# su - postgres
4. Initialize the DB Cluster with initdb:
$ /usr/postgres/8.2/bin/initdb -D /var/postgres/8.2/data
Enable PostgreSQL with SMF
5. Exit from the postgres user shell, back to root:
$ exit
6. Enable PostgreSQL using svcadm:
# /usr/sbin/svcadm enable postgresql:version_82
7. Verify PostgreSQL is running:
# svcs | grep postgresql
PostgreSQL 8.1
Install / Verify packages
You very likely need to install these packages (SUNWpostgr-*) before continuing.
Check to see if you have the required packages installed using the pkginfo command: 1. $ pkginfo | grep SUNWpostgr-
You should see the following packages:
- system SUNWpostgr-client PostgreSQL 8.1 client tools
- system SUNWpostgr-contrib PostgreSQL 8.1 community contributed tools not part of core product
- system SUNWpostgr-devel PostgreSQL 8.1 development tools and header files
- system SUNWpostgr-docs PostgreSQL 8.1 documentation and man pages
- system SUNWpostgr-jdbc JDBC 3 driver for PostgreSQL 8.1
- system SUNWpostgr-libs PostgreSQL 8.1 client libraries
- system SUNWpostgr-pl PostgreSQL 8.1 additional Perl, Python & TCL server procedural languages
- system SUNWpostgr-server PostgreSQL 8.1 database server
- system SUNWpostgr-server-data-root PostgreSQL 8.1 database server data directories and root components
- system SUNWpostgr-tcl Tcl binding library for PostgreSQL 8.1
If you don't have these packages, you will need to download and install the .pkg files for them before continuing.
Setup DB Cluster
2. Become root:
$ su -
3. Set the correct permissions on the data folder:
# chown postgres:postgres /var/lib/pgsql/data
4. Use su to become the postgres user.
# su - postgres
5. Initialize the DB Cluster with initdb:
$ /usr/bin/initdb -D /var/lib/pgsql/data
Enable PostgreSQL with SMF
6. Exit from the postgres user shell, back to root:
$ exit
7. Enable PostgreSQL using svcadm:
# /usr/sbin/svcadm enable postgresql:version_81
8. Verify PostgreSQL is running:
# svcs | grep postgresql
Notes and Further Reading
Path Gotchas
The 8.2 version uses /usr/postgres/8.2/bin as the location for psql, initdb, etc. The 8.1 version is in /usr/bin.
More Information
See Sun's PostgreSQL howto for more information.
