Centos 7 environment variables for Postgres

I recently had a problem starting the postgresql service using a custom PGDATA path. He tried to look into the default data directory (/var/lib/pgsql/9.3/data/), which was not initialized and therefore caused these errors. It seems that the problem is that the Centos 7 service starter breaks all environment variables, including PGDATA.

An interesting topic on this subject.

Is there any way to configure

service postgresql-9.3 start 

use user environment variables? Are there configuration files for services where these variables should be defined?

Thank you in advance!

+4
source share
2 answers

Ok, I have a solution that worked for me.

 nano /etc/systemd/system/postgresql-9.3.service 

with content copied from / usr / lib / systemd / system / postgresql -9.3.service and the PGDATA variable. Then

 systemctl daemon-reload 

And then I started the service normally, and it worked fine. The trick made changes to this service configuration file.

+5
source

Thanks for the above answer, we just ran into this change today. You can also save the default settings and only override the PGDATA variable by putting the following in / etc / systemd / system / postgresql -9.3.service:

 # Include the default config: .include /lib/systemd/system/postgresql-9.3.service [Service] Environment=PGDATA=<your path here>/pgsql/9.3/data 

This eliminates the need to reintegrate the changes in / usr / lib / systemd / system / postgresql -9.3.service back into the local copy.

+11
source

Source: https://habr.com/ru/post/977987/


All Articles