# =========================================================
# Header details
#
# Copyright ........: Frank Schulte (fschulte\@hightek.com)
# Module/method ....: ./sourceforge.net/doc/install-sourceforge.html
# Version ..........: 00001
# CVS ..............: $Id: index.html,v 1.1.1.1 2001/07/18 01:50:41 fschulte Exp $
# Analyst ..........: FS
# Developers .......: FS  - Frank Schulte (fschulte\@hightek.com)
# Description ......: Postgres Installation Documentation
#
#  LastAmended Name
#  ----------- -------------------------------------------------------------
#
# History ..........:
#
# Vers.     Date    SSR   By  Reason
# ----- ----------- ---- ---- ------------------------------
# 00001 19.12.2000  n/a  FS   Begin Documentation of installation process
# 00002 21.02.2001  n/a  FS   Move changelog into a seperate file.
# =========================================================
0. Changelog: here

# the postgres database administrator
POSTGRES_ADMIN_USER=postgres
POSTGRES_ADMIN_GROUP=daemon

export POSTGRES_ADMIN_USER POSTGRES_ADMIN_GROUP

1. Get the Source

You can go with the latest release or with hte latest CVS Version. We describe both.

1.1. PostgreSQL (7.1.x)

http://www.postgresql.org/devel-corner/docs/postgres/anoncvs.htm

cd ${BASE_SOURCES}/sourceforge.net-binaries-needed-software

mkdir postgresql-7.1.x-cvs
cd postgresql-7.1.x-cvs

# get cvs module pgsql from postgresql:
cvs -d :pserver:anoncvs@postgresql.org:/home/projects/pgsql/cvsroot login
enter 'postgresql' as password when prompted

cvs -z3 -d :pserver:anoncvs@postgresql.org:/home/projects/pgsql/cvsroot co -P pgsql

cd pgsql
 

1.2. PostgreSQL (7.1.2)

su -
<root-password>

cd ${BASE_SOURCES}/sourceforge.net-binaries-needed-software

ftp://ftp.de.postgresql.org/pub/latest/postgresql-7.1.2.tar.gz

tar -xzf postgresql-7.1.2.tar.gz

cd postgresql-7.1.2

2. Preparations

su -
<root-password>

# user/group setup for postgres should be done by running make setup. If not do this steps.

# test if unix group "daemon" exist
grep daemon /etc/group

# if not create it
groupadd daemon

# delete user postgres in case the Linux distribution has this user defined but postgresql is not installed
userdel -r postgres

# create missing path
mkdir -p ${PKG}/postgres

# create user postgres
useradd-g daemon -c "Postgres Database Administrator Account" -m -d ${PKG}/postgres/pgsql postgres

passwd postgres
<postgres-password>

exit

3. Installation
 
 

PATH=/home/system/pkg/sourceforge.net/perl/bin:/home/system/pkg/sourceforge.net/python/2.0/bin:${PATH} ./configure --prefix=${PKG}/postgres/7.1.2 --localstatedir=${VAR} --with-perl --enable-odbc --with-tcl --with-python

gmake
gmake check # => fails, I do not know why !

gmake install

# Add line at end of file
# ${PKG}/postgres/7.1beta1/lib
vi /etc/ld.so.conf
/sbin/ldconfig

# Initialize the ORDBMS
su - postgres
mkdir data
${PKG}/postgres/7.1beta1/bin/initdb -D ${PKG}/postgres/pgsql/data

# You then get the Output:
#Success. You can now start the database server using:
#
#       ${PKG}/postgres/7.1beta1/bin/postmaster -D ${PKG}/postgres/pgsql/data
#or
#        ${PKG}/postgres/7.1beta1/bin/pg_ctl -D ${PKG}/postgres/pgsql/data start

# Start PostgreSQL Server instance
${PKG}/postgres/7.1beta1/bin/pg_ctl -D ${PKG}/postgres/pgsql/data start

# Create test Database and test create table, insert table and select table
${PKG}/postgres/7.1beta1/bin/createdb test
${PKG}/postgres/7.1beta1/bin/psql test

create table test ( first_field int, last_field varchar(20) );
insert into test values ( 10, 'test' );
select * from test;

# Create sourgeforge_net Database
${PKG}/postgres/7.1beta1/bin/createdb sourceforge_net

# Add Startupscript to System startup services

# Edit file ${BASE_SOURCES}/sf-genericinst/etc/init.d/postgres-7.1beta1-suse-7.0 for the SuSe 7.0 Distribution.
# Change the three path variables for H (postmaster), LOGFILE and DATADIR and then install the file under /etc/init.d.
# For Suse you have to install it under /sbin/init.d. We reccommend to add a symbolic link to match the
# path like solaris or RedHat.
#
# You can also set POSTGRES_LOGFILE, POSTGRES_DATADIR, POSTGRES_OPTIONS in /etc/rc.config on SuSe 7.0
# to set the needed environment.
#
# To start the postgres service on Startup do this:
#
# First add link to make SuSe 7.0 more like RedHat ot Solaris
#

cd /etc
ln -s /sbin/ini.d init.d

cd ${BASE_SOURCES}/sf-genericinst/etc/init.d
vi postgres-7.1beta1-suse-7.0

su
<root-password>

cp postgres-7.1beta1-suse-7.0 /etc/init.d/postgres

cd /etc/init.d/rc2.d
ln -s ../postgres S20postgres
ln -s ../postgres K10postgres

cd /etc/init.d/rc3.d
ln -s ../postgres S20postgres
ln -s ../postgres K10postgres

# create log dir for sourceforge.net
mkdir -p ${VAR}/log

# Add or set START_POSTGRES="yes" to /etc/rc.config file for SuSe 7.0 Linux Distribution
#  to activate the start of PostgreSQL on startup.

# Test to start the Database
/etc/init.d/postgres stop
/etc/init.d/postgres start
/etc/init.d/postgres status

cat /home/system/var/sourceforege.net/log/postgres

# Test connection:

su - postgres
<postgres-password>

${PKG}/postgres/7.1beta1/bin/psql test
select * from test;
=>     10   test
\q

# Now the Database should be up and running.

4.1.1. Installing perl5 Pg interface

If not done automatically you can do this:

cd ${BASE_SOURCES}/sourceforge.net-binaries-needed-software
cd postgres-7.1beta1-cvs/pgsql/src/interfaces/perl5

PATH=${PKG}/perl/bin:${PATH} gmake clean
PATH=${PKG}/perl/bin:${PATH} gmake
PATH=${PKG}/perl/bin:${PATH} gmake install

4.1.1.1 Verify perl5 Pg interface

Not implemented yet.

4.1.2. Installing perl DBI DBD::Pg interface

POSTGRES_INCLUDE=${PKG}/postgres/7.1beta1/include
POSTGRES_LIB=${PKG}/postgres/7.1beta1/lib

export POSTGRES_INCLUDE POSTGRES_LIB

# Now create a user that is capable of testing the DBD module.
# FOR SECURITY REASONS THIS SHOULD NOT BE THE root USER !!!

su - postgres
<postgres-password>

${PKG}/postgres/7.1beta1/bin/createuser <normaluser>

Q: Shall the new user be allowed to create databases? (y/n) y <return>
Q: Shall the new user be allowed to create more new users? (y/n) y <return>

exit

# Begin installation of DBD::Pg

su -
<root-password>

${PKG}/perl/bin/perl -MCPAN -e shell

cpan> m /Pg/

We choose

cpan> install Bundle::DBI

# Here we got error with the DBD::Proxy and DBI::ProxyServer modules.
# But we don't want to use DBD::Proxy so we ignore this errors.

cpan> install DBD::Pg

# Here we got error that the test for DBD::Pg is failing.
# Because of this we test and install the DBD::Pg module by hand

cpan> q

su - normaluser
<normaluser-password>

cd ${PKG}/perl/.cpan/build/DBD-Pg-0.95

make test

# This should do fine without errors

exit

su -
<root-passsword>

cd ${PKG}/perl/.cpan/build/DBD-Pg-0.95

make install

exit

su - normaluser
<normaluser-password>

${PKG}/perl/bin/perl ${PKG}/perl/.cpan/build/DBD-Pg-0.95/test.pl

# This should also give no error.

# If so we have a working DBD::Pg module !!!
 

4.1.2.1. Verify the Perl DBI DBD::Pg connection

su - normaluser
<normaluser-password>

# This user should have the permission to connect to the Pg Database (see 4.1.2. Installing Perl DBI DBD::Pg Module)

cd sf-genericinst

./scripts/test.db.pg.perl.dbi.dbd.pg.pl.sh
 

4.1.3. Installing Python interface

If not done automatically you can do this:

cd ${BASE_SOURCES}/sourceforge.net-binaries-needed-software
cd postgres-7.1beta1-cvs/pgsql/src/interfaces/python

PATH=${PKG}/python/bin:${PATH} gmake clean
PATH=${PKG}/python/bin:${PATH} gmake
PATH=${PKG}/python/bin:${PATH} gmake install

4.1.3.1. Verify the Python DB connection

su - normaluser
<normaluser-password>

# This user should have the permission to connect to the Pg Database (see 4.1.2. Installing Perl DBI DBD::Pg Module)

cd sf-genericinst

./scripts/test.db.pg.py.sh