Centos 7环境变量用于Postgres服务 [英] Centos 7 environment variables for Postgres service
问题描述
最近我有一个问题,使用自定义PGDATA路径启动一个postgresql服务。它试图查找未初始化的默认数据目录(/var/lib/pgsql/9.3/data/),因此触发了这些错误。看来问题是Centos 7上的服务启动器会删除所有环境变量,包括PGDATA。
Recently I had the problem of starting a postgresql service with custom PGDATA path. It tried to look in the default data directory (/var/lib/pgsql/9.3/data/) which was not initialized and therefore triggered these errors. It appears the problem is that the service starter on Centos 7 strips all the environment variables, including PGDATA.
配置
service postgresql-9.3 start
以使用自定义环境变量?是否有必须定义这些变量的服务的配置文件?
to use custom environment variables? Are there configuration files for services where these variables have to be defined?
提前感谢!
推荐答案
好,我有一个适合我的解决方案。
OK, I got a solution that worked for me.
nano /etc/systemd/system/postgresql-9.3.service
,内容从/ usr / lib / systemd / system /postgresql-9.3.service和PGDATA变量已更改。然后
with the contents copied over from /usr/lib/systemd/system/postgresql-9.3.service and PGDATA variable changed. Then
systemctl daemon-reload
然后我开始正常的服务,它工作正常。诀窍是更改此服务配置文件。
And then I started the service normally and it worked fine. The trick was making changes to this service configuration file.
这篇关于Centos 7环境变量用于Postgres服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!