Link to home
Start Free TrialLog in
Avatar of missymadi
missymadi

asked on

How do I configure Postgres9 to have the database on it's own partition in Linux?

Experts,

        I have a requirement of installing Postgres 9 database on it's own partition in RHEL5.  What are the steps to have DATA on it's own partition?

       I already installed Postgres, do I need to uninstall and reconfigure the software?

 In building the VM, I did designate two hard drives and two ethernet .

Thanks, Missymadi
Avatar of Alex Matzinger
Alex Matzinger
Flag of United States of America image

You should be able to do this by setting the PGDATA environment variable to the partition you want data to be on, and then re initialzing the database.
export PGDATA =</partition/DATA folder>

initdb

pg_ctl start

Open in new window


All done as the postgres user.
Sorry, no space inbetween the PGDATA and = sign
export PGDATA=</partition/DATA folder>

Open in new window

Avatar of missymadi
missymadi

ASKER

I'm new to Linux. Could you point me in the right direction of how to find the hard drive names and a command to find out the size of each. I'm guessing the lesser size of the two is where you would assign the pgdata to?

Thanks, Missymadi
The command is df.  

To get a more readable outpt use df -H which will output the resutls into k or M or G depending on the size of the drive. (h = human readable)  ... (you can do the same thing with ls -lh to see the real size of files as well)
This is strange. I tried to su postgres and the system is telling me that postgres does not exist?? How did this happen? How can I resolve this?
Check to make sure that the postgres directories are still on the machine.  If they are then try recreting the postgres user with root:
su - root
useradd -p <PASSWORD> postgres

Open in new window

I added postgres back. How could that have happened? We do have custom scripts but I would'nt think that they would want postgres to be disabled or deleted?

Anyway - we do have custom scripts. It looks like our data is captured in a directory
opt/co/DATA   which contains directories, base, global, pg_clog, pg_log, pg_multixact  etc. Is this the DATA directory that I want to point to the separate partition? I did a find on PGDATA and did not find anything.

Thanks, Missymadi
ASKER CERTIFIED SOLUTION
Avatar of data_n_poker
data_n_poker

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial