What are the steps to move an existing data directory in Postgres9?

Experts,

            I have an existing database located on /loc/data. I want to move the data directory to it's own partition. What are the steps to accomplish this task? I have tried numerous configurations such as stopping the db, moving the db to /data then exporting PGDATA to /data. The server will not connect thorugh PGADMIN.
How do I get PGADMIN to see the PGDATA files? What are all of the config files if any that need to  be changed? Do I need to run initdb? I did try this and recieved an error that there was data in the directory. Do I need to initdb then move the data over?

Please advise, Missymadi
missymadiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lcohanDatabase AnalystCommented:
You could add new tablespace by using CREATE TABLESPACE new_tablespace
http://www.postgresql.org/docs/9.0/static/sql-createtablespace.html

Then ALTER TABLE table_name SET TABLESPACE TABLESPACE new_tablespace to move it to the new tablespace:

http://www.postgresql.org/docs/9.0/static/sql-altertable.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
missymadiAuthor Commented:
That's not quite what I'm asking for....I need to move my /loc/data postgres directory to a partioned /data drive. I have tried several suggestions (i.e. moveing data to partioned drive, using export  PGDATA=/data/DATA restart server.....not working
0
MrNedCommented:
That should be enough. Are you overriding it in postgresql.conf data_directory parameter? What exactly does it say when it fails to start? Does it write to the pg_log at all?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

missymadiAuthor Commented:
Here is what I tried to do:

su abc
pg_ctl stop
exit
su (to root)
mv /opt/co/DATA/* /data
exit
su abc
pg_ctl start

PGADMIN connection refused. There is nothing in the log!!
I don't know where else to look to solve this.
Thanks, Missymadi
0
MrNedCommented:
- Does PGDATA env variable refer to /data
- have you tried pg_ctl start -D /data
0
missymadiAuthor Commented:
I decided to use a symbolic link. The problem was that we had custom scripts that were running and pointing to the old directory. So I did the following:

ln -s /data //opt/co/DATA

working now!
Thanks for your help!
0
missymadiAuthor Commented:
i gave the experts credit for helping me. I think initially the problem was a permissions issue. Then I found that I could do a symlink that was less complicated. The database restarted after many tests.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.