May 31 2005
Installation of PostgreSQL 8.0.3
I was given the task of installing a PostgreSQL server at the office so we can test it an learn more about it.
I downloaded the sources and wrote this instructions for future reference.
This instructions can apply to redhat 7.3 , 8 or 9.
Right now I am using centos 3.4 for this install but I don’t see why this should not work on another system. This is a work in progress so things can change all the time. This is for personal reference and you are free to use this information if interested.
Installation of PostgreSQL 8.0.3
GNU make is required; other make programs will not work. GNU make is often installed under the name gmake; this document will always refer to it by that name. (On some systems GNU make is the default tool with the name make.) To test for GNU make enter
gmake –version
this is the version I have.
[user@mylinuxserver mmatrix]$ gmake –version
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
Built for i386-redhat-linux-gnu
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Report bugs to
Get the source
[mmatrix@mylinuxserver postgres]$ wget ftp://ftp.postgresql.org/pub/source/v8.0.3/postgresql-8.0.3.tar.gz
extract the source
[mmatrix@mylinuxserver postgres]$ tar -zxvf postgresql-8.0.3.tar.gz
I will configure the database install with these options.
./configure –prefix=/usr/local/pgsql –with-perl –with-openssl –with-libs=/usr/local/openssl
I ran the configure command but got this at the end.
checking zlib.h usability… yes
checking zlib.h presence… yes
checking for zlib.h… yes
checking openssl/ssl.h usability… no
checking openssl/ssl.h presence… no
checking for openssl/ssl.h… no
configure: error: header file
[mmatrix@mylinuxserver postgresql-8.0.3]$
which means I don’t have the Openssl libraries on the right path. Let’s install a new version of Openssl and put it on
/usr/local/openssl
go back to our source directory tree and download Openssl
[mmatrix@mylinuxserver postgres]$ wget http://www.openssl.org/source/openssl-0.9.7g.tar.gz
[mmatrix@mylinuxserver postgres]$ tar -zxvf openssl-0.9.7g.tar.gz
since openssl is already installed on this computer I will install it in a different directory
This will build and install OpenSSL in the default location, which is (for
historical reasons) /usr/local/ssl. If you want to install it anywhere else,
run config like this:
$ ./config –prefix=/usr/local –openssldir=/usr/local/openssl
so following the above instructions I used.
Configured for linux-pentium.
[mmatrix@mylinuxserver openssl-0.9.7g]$ ./config –prefix=/usr/local/openssl –openssldir=/usr/local/openssl –with-integer-datetimes
Configured for linux-pentium.
Now I ran
[mmatrix@mylinuxserver openssl-0.9.7g]$ make
then after compiling it is time to run make test
[mmatrix@mylinuxserver openssl-0.9.7g]$ make test
some tests were run and it seems everything went ok, Now it is time to install with make install
[root@mylinuxserver local]# make install
after some time everything was installed. I checked the /usr/local directory and there was an openssl directory
:)
everything is going ok. Now let’s continue with the posgresql installtion.
go back to my root source
[root@mylinuxserver mmatrix]# cd postgres/
Run configure one more time but make sure you add the path to openssl so it can find it this time.
Let’s cross our fingers.
./configure –prefix=/usr/local/pgsql –with-perl –with-openssl –with-krb5=/usr/kerberos –with-integer-datetimes
I still got this at the end
configure: error: header file
so I went into /usr/local/openssl and found it on /usr/local/openssl/include/openssl/ssh.h
so I will specify the path on the configure command again .
Still it did not work. So I read this export commands online let’s see if they work.
export CFLAGS=”-O2 -g -I/usr/local/openssl/openssl/include/openssl”
export CXXFLAGS=”$CFLAGS”
export LDFLAGS=”-L/usr/local/openssl/openssl/lib”
export CPP=”gcc -E -I/usr/local/openssl/openssl/include/openssl”
Then ran the configure and still now worked. Then I found something else
./configure –with-openssl –with-krb5=/usr/kerberos
so I will try specifying the kerberos path
./configure –prefix=/usr/local/pgsql –with-perl –with-openssl –with-krb5 –with-integer-datetimes
well it didn’t work again
speaking to the database administrator I found that we won’t need openssl so I will not configure it with that
command. I wanted to have openssl as an option just in case but it does not work for some reason.
[root@mylinuxserver postgresql-8.0.3]# ./configure –prefix=/usr/local/pgsql –with-perl –with-integer-datetimes
this was able to configure without any issues so let’s continue.
Build
To start the build, type
gmake
[root@mylinuxserver postgresql-8.0.3]# gmake
after some time I got
All of PostgreSQL successfully made. Ready to install.
Regression Tests
If you want to test the newly built server before you install it, you can run the regression tests at this point. The regression tests are a test suite to verify that PostgreSQL runs on your machine in the way the developers expected it to. Type
gmake check
The regression failed for some reason but I will continue with gmake install and create the database user to enable the installation of the db.
[root@mylinuxserver postgresql-8.0.3]# gmake install
[root@mylinuxserver root]# adduser postgres
[root@mylinuxserver root]# mkdir /usr/local/pgsql/data
[root@mylinuxserver root]# chown postgres /usr/local/pgsql/data
[root@mylinuxserver root]# su - postgres
[postgres@mylinuxserver postgres]$ /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 UNICODE.
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/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_shadow … ok
enabling unlimited row size for system tables … ok
initializing pg_depend … 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
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
Continue
[postgres@mylinuxserver postgres]$ /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
[postgres@mylinuxserver postgres]$ /usr/local/pgsql/bin/createdb test
CREATE DATABASE
/usr/local/pgsql/bin/psql test
then I am connected to the database.
I typed
test=# \q
to quit.
To reconnect to the database I typed
[mmatrix@mylinuxserver bin]$ ./psql -U postgres -d test
post setup
Shared Libraries
On some systems that have shared libraries (which most systems do) you need to tell your system how to find the newly installed shared libraries. The systems on which this is not necessary include BSD/OS, FreeBSD, HP-UX, IRIX, Linux, NetBSD, OpenBSD, Tru64 UNIX (formerly Digital UNIX), and Solaris.
For Linux
[root@mylinuxserver root]# ldconfig /usr/local/pgsql/lib
Environment Variables
If you installed into /usr/local/pgsql or some other location that is not searched for programs by default, you should add /usr/local/pgsql/bin (or whatever you set –bindir to in step 1) into your PATH. Strictly speaking, this is not necessary, but it will make the use of PostgreSQL much more convenient.
added the following to /etc/profile
PATH=/usr/local/pgsql/bin:$PATH
export PATH
and add the following for the manual pages.
To enable your system to find the man documentation, you need to add lines like the following to a shell start-up file unless you installed into a location that is searched by default.
MANPATH=/usr/local/pgsql/man:$MANPATH
export MANPATH
We would like a better way to stop and start the database so inside the /contrib/start-scripts
there is a linux startup script.
[root@mylinuxserver start-scripts]# cp linux /etc/init.d/pgsqld
[root@mylinuxserver start-scripts]# chmod 755 /etc/init.d/pgsqld
lets stop our existing server.
[root@mylinuxserver start-scripts]# /etc/init.d/pgsqld stop
Stopping PostgreSQL: postmaster stopped
ok
Now let’s start it again.
[root@mylinuxserver start-scripts]# /etc/init.d/pgsqld start
Starting PostgreSQL: ok
now let’s check if it is working
[root@mylinuxserver start-scripts]# /etc/init.d/pgsqld status
pg_ctl: postmaster is running (PID: 7632) /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
ok so now we need to find a better way to access the database without using psql. I like using webmin so I login
to my server webmin and reconfigure the path to point to my postgres installation.
I reconfigured the path and then I am able to see my tables and my users.
However I get this at the bottom of the webmin module
Warning: The Perl module DBD::Pg is not installed on your system, so Webmin will not be able to reliably access your PostgreSQL database. Click here to install it now.
so I will click there to install it.
After some time I got
Make and install of DBD::Pg successful.
Ok so after that I changed the password of the posgres user using the webmin interface.
Time to install the other requirements needed for our database. Stop the database server and install the other contribs
cd into the contrib sources directories
[root@mylinuxserver postgresql-8.0.3]# cd contrib
[root@mylinuxserver contrib]# cd tsearch2
I check the readme file
Tsearch2 - full text search extension for PostgreSQL
[10][Online version] of this document is available
This module is sponsored by Delta-Soft Ltd., Moscow, Russia.
Notice: This version is fully incompatible with old tsearch (V1),
which is considered as deprecated in upcoming 7.4 release and
obsoleted in 8.0.
The Tsearch2 contrib module contains an implementation of a new data
type tsvector - a searchable data type with indexed access. In a
nutshell, tsvector is a set of unique words along with their
positional information in the document, organized in a special
structure optimized for fast access and lookup. Actually, each word
entry, besides its position in the document, could have a weight
attribute, describing importance of this word (at a specific) position
in document. A set of bit-signatures of a fixed length, representing
tsvectors, are stored in a search tree (developed using PostgreSQL
GiST), which provides online update of full text index and fast query
lookup. The module provides indexed access methods, queries,
operations and supporting routines for the tsvector data type and easy
conversion of text data to tsvector. Table driven configuration allows
creation of custom configuration optimized for specific searches using
standard SQL commands.
[root@mylinuxserver tsearch2]# make
[root@mylinuxserver tsearch2]# make install
now install the other requirement.
go inside the contrib sources and cd into ltree
[root@mylinuxserver contrib]# cd ltree/
[root@mylinuxserver ltree]# more README.ltree
contrib/ltree module
ltree - is a PostgreSQL contrib module which contains implementation of data
types, indexed access methods and queries for data organized as a tree-like
structures.
This module will works for PostgreSQL version 7.3.
(version for 7.2 version is available from http://www.sai.msu.su/~megera/postgres/gist/ltree/ltree-7.2.tar.
gz)
then to install i followed the instructions at
INSTALLATION
cd contrib/ltree
make
make install
make installcheck
root@mylinuxserver ltree]$ make
root@mylinuxserver ltree]$ make install
postgres@mylinuxserver ltree]$ make installcheck
When I ran the last command I had to
become user postgres and got an error message.
[postgres@mylinuxserver ltree]$ make installcheck
make -C ../../src/test/regress pg_regress
/bin/sh: line 1: cd: .: No such file or directory
make[1]: Entering directory `/home/mmatrix/postgres/postgresql-8.0.3/src/test/regress’
make[1]: `pg_regress’ is up to date.
make[1]: Leaving directory `/home/mmatrix/postgres/postgresql-8.0.3/src/test/regress’
../../src/test/regress/pg_regress ltree
(using postmaster on Unix socket, default port)
============== dropping database “regression” ==============
could not change directory to “/home/mmatrix/postgres/postgresql-8.0.3/contrib/ltree”
DROP DATABASE
============== creating database “regression” ==============
could not change directory to “/home/mmatrix/postgres/postgresql-8.0.3/contrib/ltree”
CREATE DATABASE
could not change directory to “/home/mmatrix/postgres/postgresql-8.0.3/contrib/ltree”
============== dropping regression test user accounts ==============
============== installing PL/pgSQL ==============
could not change directory to “/home/mmatrix/postgres/postgresql-8.0.3/contrib/ltree”
============== running regression test queries ==============
mkdir: cannot create directory `./results’: Permission denied
make: *** [installcheck] Error 2
[postgres@mylinuxserver ltree]$
My guess is that I can’t create the database because I changed the password.
Warning:
I went to see if the password for user postgres had changed and it didn’t the password is still blank.
I will figure that later
#########################################################################################
Playing with your new database server .
create a new database
[mmatrix@mylinuxserver mmatrix]$ createdb -U postgres testdb
CREATE DATABASE
You can now start entering SQL commands at the psql prompt. If you are unfamiliar with psql, please see the Basic Psql chapter.
##################################################################################################
