PostgreSQL數據文件權限不對致使開機啓動失敗

上午開發告知機子重啓後DB鏈接不了了,登進去一開,確實,進程啥的都沒有起來。


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

發現仍是沒起來,查看日誌,裏面有如此報錯信息: sql

[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文件由於權限開設太大而被其餘非容許的用戶訪問。 tomcat

相關文章
相關標籤/搜索