Postgresql

Postgres 備份失敗:pg_dump:無法 fsync 文件:錯誤的文件描述符

  • February 18, 2019

我在 Windows 10 上執行 Postgres 11,這應該是我在遷移到 Linux 之前的最後一次備份:

"C:\PostgreSQL\pg11\bin\pg_dump.exe" -U postgres -h localhost -p 5432 --verbose --jobs=4 --format=d --blobs --clean --create --if-exists --compress=0 --dbname="DATABASE_NAME" --file="P:\PG11_dump_20190217"

這是日誌的結尾:

...
pg_dump: dumping contents of table "schema.table"
pg_dump: finished item 255955 TABLE DATA table
pg_dump: finished item 255956 TABLE DATA table
pg_dump: pg_dump: dumping contents of table "schema.table"
dumping contents of table "schema.table"
pg_dump: finished item 255953 TABLE DATA table
pg_dump: finished item 255952 TABLE DATA table
pg_dump: could not fsync file "P:\PG11_dump_20190217/291267.dat": Bad file descriptor
pg_dump: could not fsync file "P:\PG11_dump_20190217/293909.dat": Bad file descriptor
pg_dump: could not fsync file "P:\PG11_dump_20190217/294060.dat": Bad file descriptor
pg_dump: could not fsync file "P:\PG11_dump_20190217/295715.dat": Bad file descriptor
pg_dump: could not fsync file "P:\PG11_dump_20190217/296142.dat": Bad file descriptor

我搜尋了pg_dump: could not fsync file: Bad file descriptor錯誤,但找不到任何幫助。

也許很重要:數據庫大約 3.6 TB,我正在使用 PostGIS 擴展。

**問題:**如何防止或解決此錯誤?

**附加問題:**我可以進行文件級備份並將data文件夾從 Windows 複製到 linux,給定相同的 Postgres 版本並且兩台伺服器都停止了嗎?

問題:如何防止或解決此錯誤?

fsync確保數據物理寫入磁碟,以便在備份後幾秒鐘發生崩潰或失去或斷電時,未刷新的記憶體緩衝區中不會失去任何數據。不幸的是,它似乎不適用於您的情況。您可以添加--no-sync以避免此步驟,儘管顯示的錯誤可能是無害的,因為它們肯定不會影響備份的內容。如果您擔心跳過同步,也可以將同步用作外部程序。

附加問題:如果 Postgres 版本相同並且兩台伺服器都停止,我可以進行文件級備份並將數據文件夾從 windows 複製到 linux 嗎?

不可以。數據文件通常不可移植,尤其是不能跨完全不同的作業系統。

引用自:https://dba.stackexchange.com/questions/230002