How to install, configure from source and connect Postgresql on fedora 22

PostgreSQL is a free and open source software developed for general purpose and object-relational database management system. Developed for Postgresql version 4.2 at Berkeley Computer Science department, University of California, it was initially designed to run on UNIX-like platforms.  Postgresql is designed to be portable  on various platforms such as Mac OS X, Solaris, and Windows.

It’s a source code that can be obtained under PostgreSQL license, a liberal open source license. You are free to use, modify and distribute PostgreSQL in any form. unlike most RDMS, it is developed to run under minimum maintenance and attendance efforts because of its stability.

It is often used as a back-end for web and mobile applications. You can also use it for DB mirroring or replication. PostgreSQL, or ‘Postgres’ as it is nicknamed, adopts the ANSI/ISO SQL standards together, with the revisions.
Pre- Check

Step 1: Download postgreSQL source code

From the postgreSQL download site, choose the mirror site that is located in your country.

# wget http://wwwmaster.postgresql.org/redir/198/f/source/v8.3.7/postgresql-8.3.7.tar.gz

Step 2: Install postgreSQL

# tar xvfz postgresql-8.3.7.tar.gz
# cd postgresql-8.3.7
# ./configure
checking for sgmlspl... no
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking ./src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking ....
# make
make[3]: Leaving directory `/usr/save/postgresql-8.3.7/contrib/spi'
rm -rf ./testtablespace
# make install
make -C test/regress install
make[2]: Entering directory `/usr/save/postgresql-8.3.7/src/test/regress'
/bin/sh ../../../config/install-sh -c  pg_regress '/usr/local/pgsql/lib/pgxs/src/test/regress/pg_regress'
make[2]: Leaving directory `/usr/save/postgresql-8.3.7/src/test/regress'
make[1]: Leaving directory `/usr/save/postgresql-8.3.7/src'
make -C config install

PostgreSQL possible errors:

As you go along you may meet error messages  while performing postgreSQL installation.

# ./configure
checking for -lreadline... no
checking for -ledit... no

configure: error: readline library not found

check the config.log for details, to understand the package that is required or use –without-readline option during compilation to disable readline support.

PostgreSQL Installation Solution1:

Install the readline-devel and libtermcap-devel to solve the above issue.

# rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm readline-devel-5.1-1.1.i386.rpm
warning: libtermcap-devel-2.0.8-46.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:libtermcap-devel       ########################################### [ 50%]
   2:readline-devel         ########################################### [100%]

Step 3: Verify the postgreSQL directory structure

Check the bin, doc, include, lib, man and share directories if they really were copied to the default /usr/local/pgsql path .

# ls -l /usr/local/pgsql/
total 24
drwxr-xr-x 2 root root 4096 Apr  8 23:25 bin
drwxr-xr-x 3 root root 4096 Apr  8 23:25 doc
drwxr-xr-x 6 root root 4096 Apr  8 23:25 include
drwxr-xr-x 3 root root 4096 Apr  8 23:25 lib
drwxr-xr-x 4 root root 4096 Apr  8 23:25 man
drwxr-xr-x 5 root root 4096 Apr  8 23:25 share

Step 4: Create postgreSQL user account

# adduser postgres
# passwd postgres

Changing password for user postgres.

New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Step 5: Create postgreSQL data directory

Create and make postgres user as the owner use the main postgres directory.

# mkdir /usr/local/pgsql/data
# chown postgres:postgres /usr/local/pgsql/data
# ls -ld /usr/local/pgsql/data
drwxr-xr-x 2 postgres postgres 4096 Apr  8 23:26 /usr/local/pgsql/data

Step 6: Initialize postgreSQL data directory

Before you can start creating any postgreSQL database, the empty data directory created in the above step should be initialized using the initdb command as shown below.

# su – 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 UTF8.
The default text search configuration will be set to "english".
fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ... 32MB/204800
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... 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.

After successfully initializing,. You can now start the database server using:

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data

or

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

 

Advertisements
%d bloggers like this: