Friday, October 03, 2008

How to change postgresql data directory

How to change postgresql data directory.
  1. vim /etc/postgresql/8.2/main/postgresql.conf
  2. set data directory path to the new directory path
  3. Create new Server Certificate
    1. openssl req -new -text -out server.req
    2. openssl rsa -in privkey.pem -out server.key
    3. rm privkey.pem
    4. openssl req -x509 -in server.req -text -key server.key -out server.crt
    5. chmod og-rwx server.key
    6. chown postgres:postgres server.key
  4. Stop and Restart Postgresql server
References:
  1. http://developer.postgresql.org/pgdocs/postgres/ssl-tcp.html
  2. http://www.linuxquestions.org/questions/linux-server-73/change-postgresql-data-directory-649911/
  3. http://www.postgresql.org/docs/8.3/static/runtime-config-file-locations.html

5 comments:

Unknown said...

thanks

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by a blog administrator.
howaryoo said...

The procedure below worked for me on ubuntu 10.04 LTS. It has the same effect with the advantage that there is no need to modify the default configuration of postgres.


1) change dir to the default postgres data directory
cd /var/lib/postgresql/8.4

2) physically move the 'main' directory to the new location
sudo mv main /data/postgresql/8.4/

3) create a symlink in the default postgres data directory to the new location
ln -s /data/postgresql/8.4/main/ main

Japan Shah said...

yepp great easy short and sweet idea :) super coool !!!