Installing PostgreSQL on Solaris SPARC / x86 - PgFoundry

disturbedoctopusΔιαχείριση Δεδομένων

27 Νοε 2012 (πριν από 4 χρόνια και 6 μήνες)

229 εμφανίσεις

Installing PostgreSQL on Solaris
SPARC / x86
version 1.0
Written by
Robert Lor, Sun Microsystems,
Rob Stephens, Sun Microsystems,

Last updated: Thu January 22, 2005
This documentation provides informal discussion and details for installing and getting

started with the PostgreSQL Database Server on Solaris SPARC/x86. The Solaris

packages are ready-to-install binary files for Solaris distributions. Please note that this

article is written for 8.1 and above.
The format and some of its content was derived from the PostgreSQL Linux installation guide by Devrim

GUNDUZ and Lamar Owen, available at
General Information
The packages referenced in the following documentation are provided by Sun

Microsystems Inc. and provide support for the following platforms:

Solaris 10 or later on SPARC, x86, and x64
Further information on these packages can be found at
The following email aliases are being provided for discussions, updates and anything

related to this project and its distribution. These aliases are open to all and we

encourage your feedback.

Project Announcements

Project Discussions and Feedback

Obtaining the Packages
The packages provided in this release are currently in Beta. We encourage your

feedback and any comments you may have. The beta packages can be downloaded

The official package release will be available from the PostgreSQL FTP site and all of its

mirrors once the project is out of Beta. For your convenience, you may try using the

PostgreSQL's FTP site web interface. There it will suggest a suitable download. The URL

The official release will also be made available via a bittorrent client. For details, please

Which Solaris packages for what purpose?
Sun Microsystems ships the following Solaris packages:
The SUNWpostgr-libs package provides the essential shared libraries for any

PostgreSQL client program or interface. You will need to install this package to

use any other PostgreSQL package or any clients that need to connect to a

PostgreSQL server.
If you want to manipulate a PostgreSQL database on a local or remote

PostgreSQL server, you need this package. You also need to install this

package if you're installing the SUNWpostgr-server package.
The SUNWpostgr-contrib package contains contributed packages that are

included in the PostgreSQL distribution.
The SUNWpostgr-devel package contains the header files and libraries needed

to compile C or C++ applications which will directly interact with a

PostgreSQL database management server and the ecpg Embedded C Postgres

preprocessor. You need to install this package if you want to develop

applications which will interact with a PostgreSQL server.

The SUNWpostgr-docs package includes the SGML source for the

documentation as well as the documentation in PDF format and some extra

documentation. Install this package if you want to help with the PostgreSQL

documentation project, or if you want to generate printed documentation.
The SUNWpostgr-server package includes the programs needed to create and

run a PostgreSQL server, which will in turn allow you to create and maintain

PostgreSQL databases. You should install SUNWpostgr-server if you want to

create and maintain your own PostgreSQL databases and/or your own

PostgreSQL server. You also need to install the SUNWpostgr package and its

The SUNWpostgr-server-data package creates the default data directories and

may contain demo database.
The SUNWpostgr-tcl package contains the Pgtcl client library and its

The SUNWpostgr
jdbc package includes the .jar files needed for Java programs

to access a PostgreSQL database.
The SUNWpostgr-pl package contains the the PL/Perl, and PL/Python

procedural languages for the backend. PL/Pgsql is part of the core server

Which Packages Should I Use?
To quickly get PostgreSQL up and running, you can install a subset of the packages

available. See the table above for further information. Here are a couple of scenarios:

If you only want to run a Postgres server, install SUNWpostgr-libs, SUNWpostgr,

SUNWpostgr-server-data, and SUNWpostgr-server.

If you only want to run the Postgres client, install SUNWpostgr-libs and

If a package depends on other package(s), you will need to install these dependencies

first. You will be notified of these dependencies during install.
These Solaris packages do not support any sort of upgrading process other than that

documented in the regular documentation. That is, you must dump, upgrade, initdb,

and restore your data. You must remove the old server package, install the new

package and restore the data from dump.
Package File Locations
To be in compliance with Solaris OS, the PostgreSQL Solaris packages install files in

various locations which are different than the default locations found in PostgreSQL

documentation. According to the standard PostgreSQL documentation, PostgreSQL is

installed under the directory /usr/local/pgsql, with executables, source, and data

existing in various subdirectories.
Different distributions have different recommended file locations. In particular, the

documentation directory can be /usr/doc, /usr/doc/packages, /usr/share/doc,

/usr/share/doc/packages, or some other similar path. The Solaris locations are listed

Backup area
Procedural Languages


Other shared data
The above list references the Solaris OS file system structure. These locations may

change for other distributions. It is recommended that you follow these guidelines to

ensure the system functions properly.
Installing and Upgrading PostgreSQL

Solaris Packages
Solaris packages are installed using the
command. This command transfers

the contents of a software package from the distribution medium or directory and

installs it onto a system.
This section provides basic installation instructions for installing your package in order

to verify that it installs correctly.
Download packages, unzip and untar them.
Add the software package to the system.
pkgadd -d
device- name
pkg- abbrev
device- name
Specifies the location of the package. Note that 
device- name
can be a full
directory path name or the identifiers for a tape, floppy disk, or removable disk.
pkg- abbrev
Is the name of one or more packages (separated by spaces) to be added. 
 If omitted, 
installs all available packages.
For example, the following command will install SUNWpostgr-libs package from the

current directory.
# pkgadd -d . SUNWpostgr-libs
Installing Solaris Patches
Installations on Solaris 10 Update 1 or earlier, will require that you install Python patch

121606-01 before using PL/Python procedural language.
Patch Installation Instructions:
Refer to the man pages for instructions on using 'patchadd' and 'patchrm' scripts

provided with Solaris. Any other special or non-generic installation instructions should

be described below as special instructions. The following example installs a patch to a

standalone machine:
example# patchadd /var/spool/patch/104945-02
The following example removes a patch from a standalone system:
example# patchrm 104945-02
For additional examples please see the appropriate man pages.
Special Install Instructions:
NOTE 1: If you encounter patchadd or patchrm problems (refer
Bugid 6224767), such as "wordlist too large" messages
while installing this patch, you may need to install
the following patch:
119254-02 (or newer) Install and Patch Utilities Patch
The Python patch can be downloaded from
To install the patch follow the following steps:
Download the patch, unzip and untar it into any directory (e.g. /var/tmp).
Add the patch to the system. You must have root privileges to add a patch.
The above command will take a few minutes, so be patience.
After the patch is installed successfully, you can proceed to install PL/Python.
Removing Solaris Packages
It is recommended that you execute a full database dump (and possibly a filesystem

level backup) before removing Solaris packages.
Because the

command updates

information in the software products database
it is important when you remove a

package to use the
command, even though you might be tempted to use the

command instead. For example, you could use the
command to remove a binary

executable file, but that is not the same as using
to remove the software

package that includes that binary executable. Using the
command to remove a

package’s files will corrupt the software products database. (If you really only want to

remove one file, you can use the
command, which will update the software

product database correctly.
1. Log in to the system as superuser.
2. Remove an installed package.

pkg- list
Is the name of one or more packages (separated by spaces). If omitted, 
removes all
available packages.
3. Verify that the package has successfully been removed, use the

pkginfo | egrep
pkg- abbrev
is installed, the 
command returns a line of information about it.
returns the system prompt.
NOTE: You should stop all server processes before removing packages.
Starting PostgreSQL for the First Time
Once you have successfully installed the packages, there are a few steps that you will

need to perform before you can start the database.
Create a Solaris OS user that will be used to administer PostgreSQL. If you

choose to use an existing user, skip this step on proceed with Step 2. (you

cannot run PostgreSQL as “root” user)
For example, to create a user called “postgres”, execute the following

command (you must have root privileges):
# useradd -c 'PostgreSQL user' -d /export/home/postgres -m -s /bin/bash

The next step is to ensure that the user administering the database has write

permissions to the PostgreSQL data directory. The default location for this

directory is /var/lib/pgsql/data. This can be accomplished in several ways. It is

recommended that you set the ownership of the PostgreSQL data directory to

the user you have determined will administer the database and set it with read,

write, and execute permissions.
For example, to set ownership and permissions for a user called “postgres”,

execute the following commands:

# chown postgres /var/lib/pgsql/data
# chmod +rwx /var/lib/pgsql/data
You are now ready to create the database cluster. Login as the user you have

just created or have previously determined will administer the database and

execute the following command.
For example, to create a database cluster in /var/lib/pgsql/data (default data

$ initdb -D /var/lib/pgsql/data/mydata
Note: If you need to create multiple database clusters in /var/lib/pgsql/data, you

can put the database clusters in different directories under /var/lib/pgsql/data

similar to the example above.
PostgreSQL is now ready to be started.
For example:
$ pg_ctl -D /var/lib/pgsql/data -l logfile start
Further information on creating and administering PostgresSQL can be found at
How Do I Perform a Major Upgrade?
Currently, PostgreSQL Solaris package does not provide a data upgrade feature among

major releases (or clearly, upgrades that require an initdb.) This work in under

progress. In order to upgrade to a major version, you should follow the following steps:

Take a full dump using pg_dumpall.

Check the backups. Do it again, if needed.

Now, stop the database server

Test the backup on another server. This is good for catching any possible


You might want to take a file system-level backup also. We strongly

recommend it.

Remove all PostgreSQL packages

Remove database cluster

Install new Solaris packages

Start the database server

Edit config files, if needed.

Reload the data to the new server
You're done!
Rebuilding from Source Package
Instructions for rebuilding Solaris packages from source may be provided in the future.
Contrib Files
The contents of the contrib tree are packaged into the SUNWpostgr-contrib package

and are processed with make and make install. There is documentation in

/usr/share/doc/postgresql-contrib-VERSION for these modules. Most of the modules are

in /usr/lib/pgsql for loadable modules, and binaries are in /usr/bin. In the future these

files may be split out, depending upon function and dependencies.
More Information
You can get more information at
Please help make this packaging better --let us know if you find problems, or better

ways of doing things. You can reach us by e-mail at solarispackages