本文介绍了Postgres 服务的 Centos 7 环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我遇到了使用自定义 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.

这篇关于Postgres 服务的 Centos 7 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-18 18:07