Personal tools
You are here: Home Downloads Tutorials Python Postgres DataBase
nrcfoss logo aukbc cdac iit mumbai iit madras ow2 iosn flosscc
india.gov.in
 

Postgres DataBase

Definitely about Postgres, which packages, how to install, How to Use the Pgsql etc..

Check for PostgreSQL website  for   latest  releases..

 

 

 

Once you have connected to a PostgreSQL FTP mirror, you will see the stable releases located within a directory beginning with v followed by a version (such as vX.Y.Z/). There should also be a symbolic link to the most recent stable release’s directory called latest/.

Within this sub-directory is a list of package files. The complete PostgreSQL installation package is named postgresql-[version].tar.gz and should be the largest file in the list. The following sub-packages are also made available for download, and may be installed in any combination (though at least base is required):

 

 

postgresql-base-[version].tar.gz

                          The base package contains source code to build and run  PostgreSQL.

 

 

postgresql-docs-[version].tar.gz

The docs package contains the PostgreSQL documentation in HTML format. man pages also installed  if you install this pkg.

 

 

postgresql-opt[version].tar.gz

   The optional package contains  several extensions to postgres, such as C++, perl,Tcl, python,JDBC ,ODBC.

 

 postgresql-test[version].tar.gz

  The test package contains the regression test suit.

 

 

Installation   basic  steps

 

i) Create a UNIX account to own and manage PostgreSQL database files

 

  typically   its named as  "postgres"  but  you can say  "X" (This user will be the PostgreSQL root or super user)

 

As  a root  user in  any  NIX  environment( I mean   OS)

do the following

 

STEP 1

 

# useradd  postgres (  if  you a  normal user $ su -  -c  "useradd  postgres"

 

 

Installing  the package  from  tar file..

 

STEP 2

 

~/your_database_dir # tar  -zxvf   postgresql-x.y.z.tar.gz

 

STEP3

 

 #chown  -R postgres:postgres    postgresql-x.y.z

 

this give  the  postgres   user  the ownership  of the folder

 

then  as   postgres   user  do  the compilation and  installation.

 

postgres@localhost~/postgresql-x.y.z$ ./configure   

 

(--enable-odbc  --enable-multibyte   --with-maxbackends=NUMBER(32 default)

--with-pgport=NUMBER(5432)

--with-python

--with-perl  

--enable-odbc     refer  ./configure    --help  for  what this all)

 

 

STEP4  :  Compile  the   source by  make command

 

#make  (some case  gmake)

(compilation  goes  time   may vary  from 10 to 60 miutes)

 

All of PostgreSQL is successfully made.  Ready to install.

 

if  this message  ready for  installation , its  a successful compilation

 

STEP5:  perform  regression test  optional   ( but good practice)

# make check

STEP 6:   Install  the compiled libraries, binaries and data files.

# make install

 

# chown -R postgres:postgres  /usr/local/pgsql    make sure  that postgres  user  owns the  PostgreSQL installation directories.

 

Note:   $ su -c   any_command    ( Linux  command tip)

Using the su -c command lets you save a step by only logging you in as the root user for the duration of the command’s execution.

 

 

Optionals:

 

 Installing Perl and Python modules manually

$ su -c "make -C ~/interfaces/python install"

 

$ su -c "gmake -C ~/interfaces/python install"

 

 

 

$ su -c "gmake -C src/interfaces/perl install"

 

 

 

 

You may also want to install the header files for PostgreSQL. This is important, because the default installation will only install the header files for client application development. If you are going to be using some of PostgreSQL's advanced functionality, such as user-defined functions or developing applications in C that use the libpq library, you will need this functionality.

 

 

 

 

$ su -c "gmake install-all-headers"

 

 

 

Set the  PATH  variable  in the   /etc/profile   file :   Its a linux   trick  to get the env.

 

PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
export PATH MANPATH

 

thats it..

 

 

Depending on how your system handles shared libraries, you may need to inform the operating system of where your PostgreSQL shared libraries are located. Systems such as Linux, FreeBSD, NetBSD, OpenBSD, Irix, HP/UX, and Solaris will most likely not need to do this.

 

 

 

In a default installation, shared libraries will be located in /usr/local/pgsql/lib (this may be different, depending on whether you changed it with the --prefix configuration option). One of the most common ways to accomplish this is to set the LD_LIBRARY_PATH environment variable to /usr/local/pgsql/lib.

 

Setting LD_LIBRARY_PATH in a bash shell
$ LD_LIBRARY_PATH=/usr/local/pgsql/lib
$ export LD_LIBRARY_PATH
 Setting LD_LIBRARY_PATH in csh and tcsh
$ setenv LD_LIBRARY_PATH /usr/local/pgsql/lib

 

 

 

Initializing and Starting PostgreSQL

 


As   postgres   user 


$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

 

-D  option specifies where the data will be stored ... the location here is /usr/local/pgsql/data    make sure this   location  is owned  by  user  postgres....

 

You may get out put  if success

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
This database system will be initialized with username "postgres."
This user will own all the data files and must also own the server process.


......
.....
Vacuuming database.
Copying template1 to template0.

 

 

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

 

first  comman  start the postmaster in thr foreground

 

we prefer  second  one  ,   becoz  it s in  the  background.

 

 

NOTE:   The pg_ctl

application can be used to start and stop the PostgreSQL server.   Refer   for more on this command.

 

 

Configuring the PostgreSQL SysV Script

The SysV script will allow the graceful control of the PostgreSQL database through the use of the SysV runlevel system. The SysV script can be used for starting, stopping, and status-checking of PostgreSQL. It is known to work with most Red Hat based versions of Linux, including Mandrake; however, it should work with other SysV systems (e.g., UnixWare, Solaris, etc.) with little modification. The script is named linux. To use it, you will first need to copy the linux script to your init.d directory. You may require root access to do this.

 

First, change to the directory where you unpacked the PostgreSQL source. In our case, the path to that directory is /~/postgresql-x.y.z/. Then, issue a cp command to copy the script from contrib/start-scripts into the init.d directory.  how to do this on a Linux system.

 Copying the linux script

$ cd /usr/local/src/postgresql-7.1.3/
$ su -c "cp contrib/start-scripts/linux /etc/rc.d/init.d/postgresql"

 

 

Making the linux script executable
$ su -c "chmod a+x /etc/rc.d/init.d/postgresql"

 

 

 

 

 

There are no additional requirements to use the SysV script with Red Hat, if you do not intend on using it to start PostgreSQL automatically (i.e., if you wish to use the script manually). However, if you do wish for the script to startup PostgreSQL automatically when the machine boots up (or changes runlevels), you will need to have the chkconfig program installed. If chkconfig is installed, you will also need to add the following two lines, including the hash (#) symbol, at the beginning of the /etc/rc.d/init.d/postgresql file:

# chkconfig: 345 85 15
# description: PostgreSQL RDBMS

These example numbers should work on your system; however, it is good to know what role they perform. The first group of numbers (345) represent which runlevels PostgreSQL should be started at. The example shown would start PostgreSQL at runlevels 3, 4, and 5. The second group of numbers (85) represent the order in which PostgreSQL should be started within that runlevel, relative to other programs. You should probably keep the second number high, to indicate that it should be started later in the runlevel. The third number (15) represents the order in which PostgreSQL should be shutdown. It is a good idea to keep this number low, representing a shutdown order that is inverse from the startup order. As previously mentioned, the script should work on your system with the numbers provided, but you can change them if it is necessary.

Once these two lines have been added to the script, you can use the commands shown in  Linux distributions to start the PostgreSQL database. Be sure to execute these as the root user.

 Starting PostgreSQL with the SysV script
$ service postgresql start
Starting PostgreSQL: ok
$ service postgresql stop
Stopping PostgreSQL: ok
Document Actions