2009年6月5日金曜日

How to install PostgreSQL on OpenSolaris 2009.06

Host environemt: OpenSolaris 2009.06 snv_111b X86
Background: PostgresSQL version 83 install (1) SUNWpostgr-83-server, and (2) SUNWpostgr-83-client

(1) login as root to install both packages
pkg install SUNWpostgr-83-server

DOWNLOAD PKGS FILES XFER (MB)
Completed 2/2 238/238 9.25/9.25

PHASE ACTIONS
Install Phase 555/555
PHASE ITEMS
Reading Existing Index 8/8
Indexing Packages 2/2

pkg install SUNWpostgr-83-client
DOWNLOAD PKGS FILES XFER (MB)
Completed 1/1 78/78 1.87/1.87

PHASE ACTIONS
Install Phase 141/141
PHASE ITEMS
Reading Existing Index 8/8
Indexing Packages 1/1

(2) verify package installtion
pkginfo | grep postg
system SUNWpostgr-83-client PostgreSQL client tools
system SUNWpostgr-83-libs PostgreSQL client libraries
system SUNWpostgr-83-server PostgreSQL database server
system SUNWpostgr-83-server-data-root PostgreSQL database server data directories and root components

ls /usr/postgres/8.3/
bin/ etc/ lib/ share/

(3) default user (postgres) environment modification; postgres user was created with default home in / (root) and with default shell of /usr/bin/pfksh.
As I would like set shell defaults for user postgres I will need to create a non-root home. I will create it in /export/home/postgres and then create /export/home/postgres/.profile as below;
cat .profile
PATH=/usr/postgres/8.3/bin:${PATH}
MANPATH=/usr/postgres/8.3/man:${MANPATH}
PGDATA=/var/postgres/data
export PATH MANPATH PGDATA

Then I set the default shell to /bin/bash.

(4) The next step is to decide on a directory to create the database and ensure that the permissions are set correctly.
mkdir /var/postgres/data
chown postgres:postgres /var/postgres/data

(5) Login as 'postgres' user to create a database cluster
pfexec su - postgres
-bash-3.2$ which initdb
/usr/postgres/8.3/bin/initdb
-bash-3.2$ initdb -D /var/postgres/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".

fixing permissions on existing directory /var/postgres/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ... 32MB/204800
creating configuration files ... ok
creating template1 database in /var/postgres/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

postgres -D /var/postgres/data
or
pg_ctl -D /var/postgres/data -l logfile start

################################################

(6) To start PostgresSQL
pg_ctl -D /var/postgres/data -l postmaster.log start

This will start and create /export/home/postgres/postmaster.log file.


(7) To connect the database called ¨postgres¨ running on a default port
psql postgres
Welcome to psql 8.3.7, 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

postgres=#


(8) To stop PostgresSQL
pg_ctl stop
waiting for server to shut down.... done
server stopped

cat /export/home/postgres/postmaster.log
LOG: database system was shut down at 2009-06-08 01:01:52 JST
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down

postgreSQL Integration with Solaris Service Management Facilty (SMF)
svcs -a | grep -i postgres
disabled 20:55:33 svc:/application/database/postgresql_83:default_32bit
disabled 20:55:33 svc:/application/database/postgresql_83:default_64bit
... more later

0 件のコメント:

コメントを投稿