Intro  Base  More  Read  Use  Last 30  60  90  All Articles  RSS


Intro

Base

More

Read

Use

Last:
30


60

90

All
Days
spacerspacer

Installing PostgreSQL   Print


One extremely useful program is a database. There are a variety of database systems out there, but PostgreSQL is my favorite for a hardy open source database that isn't just for a web backend. Now, PostgreSQL can take advantage of readline, which allows some editing on the database client command line. Grab PostgreSQL from here, extract, and create a directory to install it:

# tar -xjf postgresql-8.1.4.tar.bz2
# cd postgresql-8.1.4
# mkdir /opt/pgsql

Now, if you make a version and then change your mind where you want to install it, you will get an error like this:

creating system views ... ok
loading pg_description ... ok
creating conversions ... FATAL:  could not access file "$libdir/ascii_and_mic": 
No such file or directory
child process exited with exit code 1
initdb: removing contents of data directory "data"

Do a "make clean", or better yet, start over with a re-extracted source tree and compile again if you change the location. Let's configure, compile, and install:

# ./configure --prefix=/opt/pgsql --enable-thread-safety 
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... no
checking whether NLS is wanted... no
checking for default port number... 5432
.
.
.
config.status: linking ./src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking ./src/makefiles/Makefile.linux to src/Makefile.port
# 
# make && make install
make -C doc all
make[1]: Entering directory `/usr/src/postgresql-8.1.4/doc'
gzip -d -c man.tar.gz | /bin/tar xf -
for file in man1/*.1; do \
  mv $file $file.bak && \
.
.
.
config/mkinstalldirs
make[1]: Leaving directory `/usr/src/postgresql-8.1.4/config'
PostgreSQL installation complete.
#

Add a user, create a data directory, set permissions, and make sure that the home directory for the user is correct:

# useradd postgres
# mkdir /opt/pgsql/data 
# chown postgres /opt/pgsql/data
# vi /etc/passwd
postgres:x:1001:100::/opt/pgsql: 

Make sure the library path is in ld.so.conf, and run ldconfig:

# vi /etc/ld.so.conf
/opt/pgsql/lib 
bash-2.05a# ldconfig

Become postgres and initialize the database:

# su - postgres
$ ls
bin  data  doc  include  lib  man  share
$ pwd
/opt/pgsql
$ 
$ bin/initdb -D 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 C.

fixing permissions on existing directory data ... ok
creating directory data/global ... ok
creating directory data/pg_xlog ... ok
.
.
.
Success. You can now start the database server using:

    bin/postmaster -D data
or
    bin/pg_ctl -D data -l logfile start

$

Start the database:

$ bin/postmaster -D data
LOG:  database system was shut down at 2006-06-21 14:57:13 PDT
LOG:  checkpoint record is at 0/33A6AC
LOG:  redo record is at 0/33A6AC; undo record is at 0/0; shutdown TRUE
LOG:  next transaction ID: 565; next OID: 10794
LOG:  next MultiXactId: 1; next MultiXactOffset: 0
LOG:  database system is ready
LOG:  transaction ID wrap limit is 2147484146, limited by database "postgres"
 

~~~
Please read our Terms of Use
The Mountain Climbing Journal filesystem has borrowed heavily from various pieces of Linux From Scratch.

Copyright 2006-2008 NoNIC.org

Created by:
MCJ
MCJ CMS