PostgreSQL数据文件权限不对导致开机启动失败

上午开发告知机子重启后DB连接不了了,登进去一开,确实,进程啥的都没有起来。


手工启动:
[postgres@develop ~]$ pg_start
server starting
[postgres@develop ~]$ps -ef|grep postgres

发现还是没起来,查看日志,里面有如此报错信息:

[postgres@develop ~]$ tail -f pg_log
FATAL:  data directory "/home/postgres/data" has wrong ownership
HINT:  The server must be started by the user that owns the data directory.
FATAL:  data directory "/home/postgres/data" has wrong ownership
HINT:  The server must be started by the user that owns the data directory.
FATAL:  data directory "/home/postgres/data" has wrong ownership
HINT:  The server must be started by the user that owns the data directory.
FATAL:  data directory "/home/postgres/data" has group or world access
DETAIL:  Permissions should be u=rwx (0700).

信息给得很详细,postgresql的数据文件权限被改了,起码现在不是0700(只有用户权限)。返回去一看, 现在果然是777权限了。而且用户的所属也被改了,改成其他用户了。
[postgres@develop ~]$ ll /home/postgres
drwxrwxrwx 14 tomcat ddd     4096 10-29 09:41 data

改回去:
[postgres@develop ~]$chown -R postgres:postgres  /home/postgres/data
[postgres@develop ~]$chmod 0700 /home/postgres/data

查看:
drwx------ 14 postgres postgres     4096 10-29 09:41 data


再启动
[postgres@develop ~]$ pg_start
server starting

正常了。后来了解到是开发的一个误操作,改其他文件的权限的时候把DB文件的用户组权限也改了  

总结:
默认情况下,PostgreSQL启动时,启动DB用户必须拥有数据文件的所属权限(user权限),且权限不能过大,否则就会报上述错误。其实这是一个安全的保护措施,防止DB文件因为权限开设太大而被其他非允许的用户访问。

转载于:https://my.oschina.net/Kenyon/blog/85809

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值