PostgreSQL12通过 pg_resetwal 误删恢复
1、pg_resetwal
pg_resetwal 主要的工作的目的是为了在系统数据损坏的时候,通过pg_resetwal来重新标志日志的位
置,让系统可以重启运行并且重置pg_control文件等
注意点:
1、这个是整个库进行了回滚,回滚到指定的事务LSN 号的位置,所以生产环境不会使用这个方法
进行恢复。
2、pg_resetwal恢复之后,WAL日志整体被清理,原有的日志(单机)会被归并,原有的日志都
没有了。
3、truncate无法进行恢复,因为truncate之后表对应的物理文件发生改变,回滚之后会报错
ERROR: could not open file "base/13593/24761": No such file or directory ,且这样回滚之
后,就只能通过备份恢复数据库了。
1.1、pg_resetwal 语法解析
[postgres@smzq-dsj2 bin]$ pg_resetwal --help
pg_resetwal resets the PostgreSQL write-ahead log.
Usage:
pg_resetwal [OPTION]... DATADIR
Options:
-c, --commit-timestamp-ids=XID,XID
set oldest and newest transactions bearing
commit timestamp (zero means no change)
[-D, --pgdata=]DATADIR data directory
-e, --epoch=XIDEPOCH set next transaction ID epoch
-f, --force force update to be done
-l, --next-wal-file=WALFILE set minimum starting location for new WAL
-m, --multixact-ids=MXID,MXID set next and oldest multitransaction ID
-n, --dry-run no update, just show what would be done
-o, --next-oid=OID set next OID
-O, --multixact-offset=OFFSET set next multitransaction offset
-u, --oldest-transaction-id=XID set oldest transaction ID
-V, --version output version information, then exit
-x, --next-transaction-id=XID set next transaction ID
--wal-segsize=SIZE size of WAL segments, in megabytes
-?, --help show this help, then exit
Report bugs to <pgsql-bugs@lists.postgresql.org>.
评论