微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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


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

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

[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文件因为权限开设太大而被其他非允许的用户访问。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐