You are here: TWiki > Guides Web > SoftwareInstallations > InstallPostgreSQL r4 - 04 Mar 2006 - 04:59 - JesseSuen


Start of topic | Skip to actions

Installing PostgreSQL? 8.1.3 on Solaris 10

There are no official Solaris binaries provided on the PostgreSQL? website. To install it, you can either compile the source yourself, or find bundles online. This guide installs PostgreSQL? using the pkg-get utility. This process is easier than compiling the source yourself.

Create the postgres user

# mkdir /export/home
# chmod go+rx /home/
# mkdir /export/home/postgres
# useradd -d /export/home/postgres postgres
# chown postgres /export/home/postgres
# passwd postgres
New Password:
Re-enter new Password:
passwd: password successfully changed for postgres

Install PostgreSQL? bundle

# pkg-get -p postgres
  • pkg-get will install PostgreSQL? in /opt/csw/postgresql/. After it installs, take some time to look at the README: /opt/csw/postgresql/share/doc/README-CSW.txt
  • The installer automatically creates a startup script at /etc/init.d/cswpostgres and /etc/rc3.d/S10cswpostgres (symlink to the former script). According to the README, "you should always use this script to start or stop the server, otherwise you may find that you are running the wrong binaries (64-bit instead of 32-bit)."
  • By default, the script will use settings from the /opt/csw/etc/postgresql.conf file. If you want to customize your server settings (such as choosing a different data directory), you need to create this file. A sample template is provided at /opt/csw/etc/postgresql.conf.csw.

Initializing and Starting the database

  • The default data directory is at /opt/csw/var/pgdata. You can change this location by customizing your postgresql.conf file.
# cp /opt/csw/etc/postgresql.conf.csw /opt/csw/etc/postgresql.conf
# vi /opt/csw/etc/postgresql.conf
  • Here I will change the data directory to be under the postgres user's home directory. I also want to allow TCP connections so i will uncomment SERVEROPT variable:
PGDATA=/export/home/postgres/data
SERVEROPTS="-o -i"
  • Next we must create the data directory:
# su postgres
$ mkdir /export/home/postgres/data
$ exit
# /etc/init.d/cswpostgres init
Creating PostgreSQL data directory at /export/home/postgres/data...
Initialising PostgreSQL database...

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.
  • If you enabled the SERVEROPT in your postgresql.conf, you can now modify pg_hba.conf in your data directory.

  • Start the database using the startup script:
# /etc/init.d/cswpostgres start
Starting PostgreSQL...
postmaster starting

Verifying your installation

  • As the postgres user:
$ export PATH=$PATH:/opt/csw/postgresql/bin
$ createuser -P test_user
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE
$ createdb -O test_user -E UNICODE test_db
CREATE DATABASE
$ psql test_db
Welcome to psql 8.1.3, 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

test_db=# create table test_table (x int, y text);
CREATE TABLE
test_db=# insert into test_table values (1, 'one');
INSERT 0 1
test_db=# insert into test_table values (2, 'two');
INSERT 0 1
test_db=# select * from test_table;
 x |  y
---+-----
 1 | one
 2 | two
(2 rows)

test_db=# \q
$ psql -U test_user test_db
Welcome to psql 8.1.3, 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

test_db=>\q
$ dropdb test_db
DROP DATABASE
$ dropuser test_user
DROP ROLE

References

-- JesseSuen - 02 Mar 2006

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
Guides.InstallPostgreSQL moved from Guides.SolarisPostgreSQL on 04 Mar 2006 - 04:58 by JesseSuen - put it back
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback