Sunday, May 20, 2012

PostgreSQL installed from source on Debian Linux

I tried to install PostgreSQL from the source code.

I found that I needed to install other supporting libraries as well.

I got the stable version here, or here. Below was the process:

tar xvfz postgresql-9.1.3.tar.gz
cd postgresql-9.1.3

./configure


configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)


configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.


I installed bison, flex and readline using Synaptic Package Manager.





Then, I typed:

make

I saw:
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fpic -L../../src/port -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags  -shared -o dummy_seclabel.so dummy_seclabel.o
rm dummy_seclabel.o
make[3]: Leaving directory `/home/user/Downloads/postgresql-9.1.3/contrib/dummy_seclabel'
cp ../../../contrib/dummy_seclabel/dummy_seclabel.so dummy_seclabel.so
make[2]: Leaving directory `/home/user/Downloads/postgresql-9.1.3/src/test/regress'
make[1]: Leaving directory `/home/user/Downloads/postgresql-9.1.3/src'
make -C config all
make[1]: Entering directory `/home/user/Downloads/postgresql-9.1.3/config'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/user/Downloads/postgresql-9.1.3/config'
All of PostgreSQL successfully made. Ready to install.

I typed:

checkinstall


I saw:

**********************************************************************

 Done. The new package has been installed and saved to

 /path/To/File/postgresql-9.1.3_9.1.3-1_i386.deb

 You can remove it from your system anytime using:

      dpkg -r postgresql-9.1.3

**********************************************************************

Then, I typed the brown lines and saw the green ones.

adduser postgres
mkdir /usr/local/pgsql/data

ls -ld /usr/local/pgsql/data
drwxr-sr-x 2 postgres postgres 4096 May 19 21:10 /usr/local/pgsql/data

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 ... 24MB
...


/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &

cat logfile
LOG:  database system was shut down at 2012-05-19 21:12:17 PDT
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started


I just created a database below:
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
psql (9.1.3)
Type "help" for help.

test=#




Thanks to this page, I got these methods.

No comments: