5

postgresql无法启动问题

 2 years ago
source link: https://www.hi-roy.com/posts/postgresql%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%E9%97%AE%E9%A2%98/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

postgresql无法启动问题

2015-05-27

今天升级系统后,发现postgresql无法启动了,报错/etc/ssl/private/ssl-cert-snakeoil.key: Permission denied

一看就是权限问题,首先看这个文件是什么权限:

# ls -al /etc/ssl/private/ssl-cert-snakeoil.key   
-rw-r----- 1 root ssl-cert 1704 Jul 22  2014 /etc/ssl/private/ssl-cert-snakeoil.key

既然说是权限问题,那么看看postgres用户在不在ssl-cert组中:

# groups postgres
postgres : postgres ssl-cert

组用户是有可读权限的啊?怎么报错呢?那么把权限改成666试试:

# chmod 666 ssl-cert-snakeoil.key

结果报错信息变成了

2015-05-27 09:16:30 HKT FATAL:  private key file "server.key" has group or world access
2015-05-27 09:16:30 HKT DETAIL:  File must be owned by the database user or root, must have no write permission for "group", and must have no permissions for "other".

简单说就是这个文件拥有者必须是数据库用户或root,而且组用户没有写权限,其他用户无权访问。

那么就只能先把权限改回640,并且把用户修改成postgres了:

# chmod 640 ssl-cert-snakeoil.key
# chown postgres ssl-cert-snakeoil.key

再起动服务,保错信息变成:

FATAL: could not open file "/etc/ssl/certs/ssl-cert-snakeoil.pem": Permission denied

同理把pem文件拥有者变成postgres即可,之后就可以成功启动服务了。

Roy avatar
About Roy
野生程序猿,略懂Python,略懂Golang,略懂云计算,略懂大数据,略懂拳击游泳钓鱼,略懂钢琴吉他摄影。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK