I am trying to configure a Postgresql 9.3 server on Centos 7 (installation via yum) inside a custom directory, which in my case is an encrypted partition (/ custom_container / database) that mounts at startup. For some reason, Postgresql does not behave as it should in the manual, and makes a mistake when starting the service.
Note. He doesnβt want to accept the PGDATA environment variable that I set, and at startup
su - postgres -c '/usr/pgsql-9.3/bin/initdb'
(given that the PGDATA directory belongs to postgres: postgres), the cluster is initialized inside the default directory / var / lib / pgsql / 9.3 / data / The only way to change this is to use
su - postgres -c '/usr/pgsql-9.3/bin/initdb --pgdata=$PGDATA'
Initializes the directory inside the custom container that I use. This is something I could not understand, as the docs say that the PGDATA variable is taken by default.
Problem: at startup
service postgresql-9.3 start
I get an error with a log
postgresql-9.3.service - PostgreSQL 9.3 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-9.3.service; disabled) Active: failed (Result: exit-code) since Mon 2014-11-10 15:24:15 CET; 1s ago Process: 2785 ExecStartPre=/usr/pgsql-9.3/bin/postgresql93-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE) Nov 10 15:24:15 CentOS-70-64-minimal systemd[1]: Starting PostgreSQL 9.3 database server... Nov 10 15:24:15 CentOS-70-64-minimal postgresql93-check-db-dir[2785]: "/var/lib/pgsql/9.3/data/" is missing or empty. Nov 10 15:24:15 CentOS-70-64-minimal postgresql93-check-db-dir[2785]: Use "/usr/pgsql-9.3/bin/postgresql93-setup initdb" to initialize t...ster. Nov 10 15:24:15 CentOS-70-64-minimal postgresql93-check-db-dir[2785]: See %{_pkgdocdir}/README.rpm-dist for more information. Nov 10 15:24:15 CentOS-70-64-minimal systemd[1]: postgresql-9.3.service: control process exited, code=exited status=1 Nov 10 15:24:15 CentOS-70-64-minimal systemd[1]: Failed to start PostgreSQL 9.3 database server. Nov 10 15:24:15 CentOS-70-64-minimal systemd[1]: Unit postgresql-9.3.service entered failed state.
This means that Postgresql, even if the cluster is initialized in the new $ PGDATA directory (/ custom_container / database), is still looking for the cluster in / var / lib / pgsql / 9.3 / data /
Has anyone experienced this behavior of Postgresql before? Maybe I forgot some configuration options or the problem arose from the Postgresql installation?
Thank you in advance!