最近我遇到了使用自定义 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 环境变量
发布评论