Обсуждение: BUG #12801: data_directory postgresql.conf setting is not honored on Centos 6.6
BUG #12801: data_directory postgresql.conf setting is not honored on Centos 6.6
От
kyle.sletmoe@elementaltechnologies.com
Дата:
The following bug has been logged on the website: Bug reference: 12801 Logged by: Kyle Sletmoe Email address: kyle.sletmoe@elementaltechnologies.com PostgreSQL version: 9.3.6 Operating system: Centos 6.6 Description: According to http://www.postgresql.org/docs/9.3/static/runtime-config-file-locations.html, I should be able to put my configuration files (postgresql.conf, pg_hba.conf, pg_ident.conf) in a different directory than my data directory, as long as I set the PGDATA environment variable to the directory that contains postgresql.conf and then set the data_directory variable in postgresql.conf to point to the directory that actually contains the postgres data. To configure this, I did a fresh install of PostgreSQL 9.3.6 on a Centos 6.5 (x64) machine, following the instructions here: https://wiki.postgresql.org/wiki/YUM_Installation. I created a directory for the data ('/data/pgsql/data') and one for configuration ('/data/pgsql/config'). I then ran `su postgres -c '/usr/pgsql-9.3/bin/initdb -D /data/pgsql/data'`, and then moved the .conf files out of /data/pgsql/data into /data/pgsql/config. I then modified postgresql.conf, setting "data_directory = '/data/pgsql/data'", "pg_file = '/data/pgsql/config/pg_hba.conf'", and "ident_file = '/data/pgsql/config/pg_ident.conf'". Lastly, I updated /etc/sysconfig/pgsql/postgresql-9.3 to include "export PGDATA=/data/pgsql/config". When I ran `sudo service postgresql-9.3 start`, I got this error message: '/data/pgsql/config is missing. Use "service postgresql-9.3 initdb" to initialize the cluster first.'. I looked at the postgres init script ('/etc/init.d/postgresql-9.3') and noticed this message will be emitted if this bash statement results in false: "if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]". $PGDATA in this context is config directory like we set above in the /etc/sysconfig/pgsql/postgresql-9.3 file. The init script needs to check the value of data_directory in postgresql.conf in order to see if the data in the data directory is valid.