Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 69139 - Postgresql init script unable to let postmaster use alternative data storage locations
Summary: Postgresql init script unable to let postmaster use alternative data storage ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal
Assignee: PgSQL Bugs
URL:
Whiteboard:
Keywords:
: 69138 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-10-27 07:18 UTC by Kilian Hagemann
Modified: 2007-09-22 23:23 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch as described for the init script (postgresql_init.patch,394 bytes, patch)
2004-10-27 07:38 UTC, Kilian Hagemann
Details | Diff
Patch as described for the conf file (postgresql_conf.patch,716 bytes, patch)
2004-10-27 07:41 UTC, Kilian Hagemann
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kilian Hagemann 2004-10-27 07:18:54 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 Kilian Hagemann 2004-10-27 07:38:40 UTC
Created attachment 42691 [details, diff]
Patch as described for the init script
Comment 2 Kilian Hagemann 2004-10-27 07:41:05 UTC
Created attachment 42692 [details, diff]
Patch as described for the conf file
Comment 3 Daniel Webert 2004-10-27 07:44:07 UTC
*** Bug 69138 has been marked as a duplicate of this bug. ***
Comment 4 Tiziano Müller (RETIRED) gentoo-dev 2006-11-11 04:15:26 UTC
Don't know how much sense it makes to fix this with postgres 8.0 and 8.1 in the tree (which use tablespaces for this kind of tricks), but it's fixed.