Tuesday, October 25, 2011

Configure UUID Data Type in Postgresql

2 comments

The uuid-ossp module provides functions to generate universally unique identifiers (UUIDs) using one of several standard algorithms. For details,
http://www.postgresql.org/docs/8.3/static/datatype-uuid.html

I had to configure UUID in a Postgresql 8.3 database server which was running on Centos5.  I build everything from source.

Download ossp-uuid lib file:

wget ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz

Install ossp-uuid:

tar -zxvf uuid-1.6.2.tar.gz
cd uuid-1.6.2
./configure
make
make install

Install Postgresql 8.3:

tar -zxvf postgresql-8.3.1.tar.gz
cd postgresql-8.3.1
LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include ./configure --with-ossp-uuid
make
make install

Install Postgresql-contrib modules:

cd contrib
make
make install

Link library files :

vi /etc/ld.so.conf.d/postgres-lib.conf
/usr/local/lib
/usr/local/postgres/lib
:x

ldconfig


Create uuid functions in Postrgesql:

su - postgres
psql -d template1
template1=#\i /usr/local/pgsql/share/contrib/uuid-ossp.sql
...
template1=#select uuid_generate_v1();
           uuid_generate_v1        
--------------------------------------
 ae8747a6-ff8b-11e0-9bcb-00163e05751f
(1 row)

So, uuid type is working.
Continue reading →

Labels