Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 69138

Summary: Postgresql init script unable to let postmaster use alternative data storage locations
Product: Gentoo Linux Reporter: Kilian Hagemann <hagemann1>
Component: Current packagesAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: RESOLVED DUPLICATE    
Severity: normal CC: esigra
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Kilian Hagemann 2004-10-27 07:18:50 UTC
I tried for hours to try to get postgresql to use alternative file system locations for storage (see http://www.postgresql.org/docs/7.4/static/manage-ag-alternate-locs.html) using the standard 7.4.5-r2 ebuild.

The key is to define an environment variable, say, PGDATA2 for secondary storage. This must be defined in the server environment upon startup, and neither global nor user-specific env-vars work here due to the way the init script calls "pg_ctl start".

Reproducible: Always
Steps to Reproduce:
1. Follow instructions on above link, using the init-script for starting/stopping the server.
Actual Results:  
I had no success creating a new database in the new location because of the 
issues having the env-var defined when the server starts up. 

Expected Results:  
the init script should have some kind of mechanism for specifying alternative 
storage locations and making sure that gets passed on to the server 

After hours of experimenting I found a relatively elegant solution: 
Change the pg_ctl start line in the postgresql init script from 
 
su - $PGUSER -c "/usr/bin/pg_ctl start -D '$PGDATA' -s -l '$PGLOG' -o 
'$PGOPTS'" 
 
to  
 
su - $PGUSER -c "$PGDATA_ALT /usr/bin/pg_ctl start -D '$PGDATA' -s -l '$PGLOG' 
-o '$PGOPTS'" 
 
Also define PGDATA_ALT in /etc/conf.d/postgresql to be empty by default or as a 
sequence of locations, such as 
PGDATA_ALT="PGDATA2=/home/me/dbase1 PGDATA3=/home/you/dbase2" 
 
For each PGDATAx (or whatever you wanna call these vars) one could then issue 
"initlocation PGDATAx" (assuming the permissions have been fixed) followed by a  
"createdb -D PGDATAx mydbase_x"
Comment 1 Daniel Webert 2004-10-27 07:44:07 UTC

*** This bug has been marked as a duplicate of 69139 ***