與 vagrant 一起使用時無法啟動 postgresql

與 vagrant 一起使用時無法啟動 postgresql

嘗試在 Vagrant 管理的 Virtualbox VM 上啟動 postgresql 時出現下列錯誤:

LOG:  could not link file "pg_xlog/xlogtemp.29" to "pg_xlog/000000010000000000000001" (initialization of log file): Operation not permitted
FATAL:  could not open file "pg_xlog/000000010000000000000001": No such file or directory

````

答案1

當postgresql的資料目錄位於Vagrant共用資料夾中(/vagrant例如),而Vagrant主機是Windows時,就會發生這種情況。在這種情況下,無法以 UNIX 方式設定權限。

將該資料夾移至另一個位置(例如 vagrant 使用者的主目錄),postgresql 將啟動。

解決方案發現於:https://gitlab.com/gitlab-org/gitlab-development-kit/issues/20

答案2

其根本原因是 vboxsf 不支援檔案系統連結(無論是硬連結還是符號連結)。您可以透過在 VirtualBox 來賓中安裝主機資料夾並嘗試執行以下操作來重現問題: ln /path/to/mounted/share/existingfile.txt /some/path/link-to-file.txt

例如(將 /var/data 安裝為 vboxsf 共用) jim@a55a005fc5a5:/~ ln /var/data/foo.txt ~/data/link-to-foo ln: failed to create hard link ‘/users/jim/data/link-to-foo’ => ‘/var/data/foo.txt’: Operation not permitted

virtualbox.org 上有很多相關的門票(第818章,第10085章)但考慮到他們已經回到了 7 年前,可能還需要一段時間才能修復!

相關內容