Thursday, January 18, 2007

Log Instalasi PostgreSQL

Posting ini adalah kelanjutan dari posting sebelumnya (Log Instalasi Apache). Pemisahan log ini dalam rangka untuk memudahkan pembacaan.
Sebagai panduan instalasi postgresql, saya selain menggunakan dokumen dari http://mapserver.gis.umn.edu/docs tetapi juga dari buku berjudul "Database Server PostgreSQL" karangan Dr. Richardus Eko Indrajit dan Andhi Lala Adam.

Source postgresql bisa diperoleh dari ftp://ftp9.id.postgresql.org/postgresql/

1. Source postgresql telah diletakkan di /usr/local/package_install_frsource
[root@localhost httpd-2.2.3]# cd ..

2. Ekstrak source postgresql
[root@localhost package_install_frsource]# tar -xvzf postgresql-8.1.4.tar.gz
.
.
postgresql-8.1.4/doc/src/FAQ/FAQ_japanese.html
postgresql-8.1.4/doc/src/FAQ/FAQ_polish.html
postgresql-8.1.4/doc/src/FAQ/FAQ_russian.html
postgresql-8.1.4/doc/src/FAQ/FAQ_turkish.html
postgresql-8.1.4/doc/src/FAQ/README
postgresql-8.1.4/doc/src/FAQ/TODO.html
[root@localhost package_install_frsource]#

3. Konfigurasi postgresql dengan sebelumnya pindah ke folder postgresql
[root@localhost package_install_frsource]# cd postgresql-8.1.4
[root@localhost postgresql-8.1.4]# LDFLAGS=-lstdc++ ./configure \
> --prefix=/usr/local/pgsql \
> --with-perl \
> --with-phyton \
> --with-krb5 \
> --with-openssl
.
.
checking for collateindex.pl... /usr/bin/collateindex.pl
checking for sgmlspl... sgmlspl
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: linking ./src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking ./src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking ./src/backend/port/sysv_sema.c to src/backend/port/pg_sema.c
config.status: linking ./src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking ./src/backend/port/dynloader/linux.h to src/include/dynloader.h
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

4. Compiling
[root@localhost postgresql-8.1.4]# make
.
.
rm -f libplperl.so
ln -s libplperl.so.0.0 libplperl.so
make[3]: Leaving directory `/usr/local/package_install_frsource/postgresql-8.1.4/src/pl/plperl'
make[2]: Leaving directory `/usr/local/package_install_frsource/postgresql-8.1.4/src/pl'
make -C makefiles all
make[2]: Entering directory `/usr/local/package_install_frsource/postgresql-8.1.4/src/makefiles'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/package_install_frsource/postgresql-8.1.4/src/makefiles'
make -C utils all
make[2]: Entering directory `/usr/local/package_install_frsource/postgresql-8.1.4/src/utils'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/package_install_frsource/postgresql-8.1.4/src/utils'
make[1]: Leaving directory `/usr/local/package_install_frsource/postgresql-8.1.4/src'
make -C config all
make[1]: Entering directory `/usr/local/package_install_frsource/postgresql-8.1.4/config'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/local/package_install_frsource/postgresql-8.1.4/config'
All of PostgreSQL successfully made. Ready to install.

5. Installing
[root@localhost postgresql-8.1.4]# make install
.
.
/bin/sh ../config/install-sh -c -m 755 ./mkinstalldirs /usr/local/pgsql/lib/pgxs/config/mkinstalldirs
make[1]: Leaving directory `/usr/local/package_install_frsource/postgresql-8.1.4/config'
PostgreSQL installation complete.
[root@localhost postgresql-8.1.4]#

6. Menambahkan user postgres (pemilik default postgresql)
[root@localhost postgresql-8.1.4]# /usr/sbin/adduser postgres
[root@localhost postgresql-8.1.4]# mkdir /usr/local/pgsql/data
[root@localhost postgresql-8.1.4]# chown postgres /usr/local/pgsql/data/

7. Inisialisasi postgresql
[root@localhost postgresql-8.1.4]# su - postgres
[postgres@localhost ~]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/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.

fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating directory /usr/local/pgsql/data/global ... ok
creating directory /usr/local/pgsql/data/pg_xlog ... ok
creating directory /usr/local/pgsql/data/pg_xlog/archive_status ... ok
creating directory /usr/local/pgsql/data/pg_clog ... ok
creating directory /usr/local/pgsql/data/pg_subtrans ... ok
creating directory /usr/local/pgsql/data/pg_twophase ... ok
creating directory /usr/local/pgsql/data/pg_multixact/members ... ok
creating directory /usr/local/pgsql/data/pg_multixact/offsets ... ok
creating directory /usr/local/pgsql/data/base ... ok
creating directory /usr/local/pgsql/data/base/1 ... ok
creating directory /usr/local/pgsql/data/pg_tblspc ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... 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:

/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
or
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

[postgres@localhost ~]$

8. Testing
[postgres@localhost ~]$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data/ -l /usr/local/pgsql/data/logfile start
postmaster starting
[postgres@localhost ~]$ /usr/local/pgsql/bin/createdb test
CREATE DATABASE

9. Membuat user postgresql
[postgres@localhost ~]$ /usr/local/pgsql/bin/psql test
Welcome to psql 8.1.4, 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=# create user usertest createdb createuser password='usertest';
ERROR: syntax error at or near "=" at character 50
LINE 1: create user usertest createdb createuser password='usertest'...
^
test=# create user usertest createdb createuser password 'usertest';
CREATE ROLE
test=# \q
[postgres@localhost ~]$
[postgres@localhost ~]$exit

10. Otomatisasi postgresql, sehingga ketika restart dapat secara otomatis 'running'
[root@localhost postgresql-8.1.4]# vi contrib/start-scripts/linux
===
note: perintah di atas hanya untuk mengecek isi contrib/start-scripts/linux
===

[root@localhost postgresql-8.1.4]# cp contrib/start-scripts/linux /etc/init.d/postgresql
[root@localhost postgresql-8.1.4]# vi /etc/init.d/postgresql
==
note: perintah di atas setelah 'cp..' hanya untuk mengecek hasil copy
==

[root@localhost postgresql-8.1.4]# ll /etc/init.d | grep postgresql
[root@localhost postgresql-8.1.4]# ll /etc/init.d/ | grep postgresql
-rw-r--r-- 1 root root 2572 Dec 30 14:13 postgresql
[root@localhost postgresql-8.1.4]# chmod 700 /etc/init.d/postgresql
[root@localhost postgresql-8.1.4]# ll /etc/init.d/ | grep postgresql
-rwx------ 1 root root 2572 Dec 30 14:13 postgresql
[root@localhost postgresql-8.1.4]# /sbin/chkconfig --add postgresql
[root@localhost postgresql-8.1.4]# chkconfig --list | grep postgresql
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost postgresql-8.1.4]# chkconfig postgresql on

11. Test hasil otomatisasi postgresql
[root@localhost postgresql-8.1.4]# service postgresql restart
Restarting PostgreSQL: postmaster stopped
ok
[root@localhost postgresql-8.1.4]# su postgres
[postgres@localhost postgresql-8.1.4]$ /usr/local/pgsql/bin/psql test
Welcome to psql 8.1.4, 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=# \q
[postgres@localhost postgresql-8.1.4]$
[postgres@localhost postgresql-8.1.4]$ exit
exit

No comments: