有時遇到table 壞軌,要救回資料可以照以下方式來作
reindex db發生error:
database "prod" failed: ERROR: invalid page header in block 6066 of relation base/16384/25370
依照數字可以找出database跟object
select oid,* from pg_database where oid::varchar='16384';
select oid,* from pg_class where oid::varchar='16384';
修復方法:reindex database 或 table
整個DB reindex:
reindexdb -U postgres -a
單一table Reindex:
psql -U postgres -c "reindex table customers"
ps.若是reindex時還是有大量的error,則在postgresql.conf裏最後一行加上zero_damaged_pages = on,並重啟postgresql database
zero_damaged_pages 說明:(8.0以後的postgresql支援)
Detection of a damaged page header normally causes PostgreSQL to report an error, aborting the current command. Setting zero_damaged_pages to true causes the system to instead report a warning, zero out the damaged page, and continue processing. This behavior will destroy data, namely all the rows on the damaged page. But it allows you to get past the error and retriev
沒有留言:
張貼留言