When I load up the postgres server (v9.0.1) i get a panic that prevents it from starting:
当我加载postgres服务器(v9.0.1)时,我感到恐慌,无法启动:
PANIC: could not locate a valid checkpoint record
慌乱:无法找到有效的检查点记录
How can I fix this?
我该怎么解决这个问题呢?
5 个解决方案
#1
59
It's looking for a checkpoint record in the transaction log that probably doesn't exist or is corrupted. You can determine if this is the case by running:
它在事务日志中查找一个检查点记录,该记录可能不存在或已损坏。您可以通过以下操作来确定这种情况:
# Postgres < 10.0
pg_resetxlog DATADIR
# Postgres >= 10.0
pg_resetwal DATADIR
If the transaction log is corrupt, you'll see a message like:
如果事务日志损坏,您将看到如下消息:
The database server was not shut down cleanly. Resetting the transaction log might cause data to be lost. If you want to proceed anyway, use -f to force reset.
数据库服务器没有被彻底关闭。重新设置事务日志可能会导致数据丢失。如果你想继续,使用-f强制复位。
You can then follow the instructions and run with -f
to force the update:
然后,您可以按照说明运行-f命令强制更新:
# Postgres < 10.0
pg_resetxlog -f DATADIR
# Postgres >= 10.0
pg_resetwal -f DATADIR
That should reset the transaction log, however it could leave your database in an indeterminate state as explained in the PostgreSQL documentation on pg_resetxlog
:
这应该会重置事务日志,但它可能使数据库处于不确定状态,如pg_resetxlog的PostgreSQL文档中所述:
If pg_resetxlog complains that it cannot determine valid data for pg_control, you can force it to proceed anyway by specifying the
-f
(force) switch. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting address fields. These fields can be set using the switches discussed below. If you are not able to determine correct values for all these fields,-f
can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and reload is imperative. Do not execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.如果pg_resetxlog抱怨它不能为pg_control确定有效数据,您可以通过指定-f (force)开关来强制它继续。在这种情况下,似是而非的值将被替换为丢失的数据。大多数字段可以被期望匹配,但是对于下一个OID、下一个事务ID和epoch、下一个多事务ID和偏移量以及WAL - start address字段可能需要人工辅助。可以使用下面讨论的开关设置这些字段。如果您不能为所有这些字段确定正确的值,仍然可以使用-f,但是恢复的数据库必须比通常更加怀疑:立即转储和重新加载是必需的。在转储之前不要在数据库中执行任何数据修改操作,因为任何此类操作都可能导致更严重的损坏。
#2
10
I'm running 9.1.7 and i find ran the following successfully:
我运行的是9.1.7,我发现运行如下成功:
/usr/lib/postgresql/9.1/bin/pg_resetxlog -f /var/lib/postgresql/9.1/main
Your final argument to the pg_resetxlog
command should be the location on disk where postgres stores your database data.
pg_resetxlog命令的最后一个参数应该是postgres存储数据库数据的磁盘上的位置。
#3
6
As indicated here pg_resetxlog should not be run. The answers that refer to this is bad advice. Assuming the error occured in a context of copy/replication instance, the link provides a more succinct way of doing copy/replication with pg_basebackup
如这里所示,不应该运行pg_resetxlog。与此相关的答案是糟糕的建议。假设错误发生在复制/复制实例的上下文中,该链接提供了使用pg_basebackup进行复制/复制的更简洁的方法
#4
3
Do you do continuous archiving? If you are backing up at the time, you may find it more prudent to remove backup_label. pg_resetxlog
is a severe thing.
你们做连续归档吗?如果您正在备份,您可能会发现删除backup_label更谨慎。pg_resetxlog是一个严重的问题。
#5
1
just like the log saying : could not locate a valid checkpoint record.Postgres can't find a properly WAL under the $PGDATA/pg_xlog/ directory. Try to use pg_resetxlog
就像日志说的那样:无法找到有效的检查点记录。Postgres无法在$PGDATA/pg_xlog/目录下找到正确的WAL。尝试使用pg_resetxlog
#1
59
It's looking for a checkpoint record in the transaction log that probably doesn't exist or is corrupted. You can determine if this is the case by running:
它在事务日志中查找一个检查点记录,该记录可能不存在或已损坏。您可以通过以下操作来确定这种情况:
# Postgres < 10.0
pg_resetxlog DATADIR
# Postgres >= 10.0
pg_resetwal DATADIR
If the transaction log is corrupt, you'll see a message like:
如果事务日志损坏,您将看到如下消息:
The database server was not shut down cleanly. Resetting the transaction log might cause data to be lost. If you want to proceed anyway, use -f to force reset.
数据库服务器没有被彻底关闭。重新设置事务日志可能会导致数据丢失。如果你想继续,使用-f强制复位。
You can then follow the instructions and run with -f
to force the update:
然后,您可以按照说明运行-f命令强制更新:
# Postgres < 10.0
pg_resetxlog -f DATADIR
# Postgres >= 10.0
pg_resetwal -f DATADIR
That should reset the transaction log, however it could leave your database in an indeterminate state as explained in the PostgreSQL documentation on pg_resetxlog
:
这应该会重置事务日志,但它可能使数据库处于不确定状态,如pg_resetxlog的PostgreSQL文档中所述:
If pg_resetxlog complains that it cannot determine valid data for pg_control, you can force it to proceed anyway by specifying the
-f
(force) switch. In this case plausible values will be substituted for the missing data. Most of the fields can be expected to match, but manual assistance might be needed for the next OID, next transaction ID and epoch, next multitransaction ID and offset, and WAL starting address fields. These fields can be set using the switches discussed below. If you are not able to determine correct values for all these fields,-f
can still be used, but the recovered database must be treated with even more suspicion than usual: an immediate dump and reload is imperative. Do not execute any data-modifying operations in the database before you dump, as any such action is likely to make the corruption worse.如果pg_resetxlog抱怨它不能为pg_control确定有效数据,您可以通过指定-f (force)开关来强制它继续。在这种情况下,似是而非的值将被替换为丢失的数据。大多数字段可以被期望匹配,但是对于下一个OID、下一个事务ID和epoch、下一个多事务ID和偏移量以及WAL - start address字段可能需要人工辅助。可以使用下面讨论的开关设置这些字段。如果您不能为所有这些字段确定正确的值,仍然可以使用-f,但是恢复的数据库必须比通常更加怀疑:立即转储和重新加载是必需的。在转储之前不要在数据库中执行任何数据修改操作,因为任何此类操作都可能导致更严重的损坏。
#2
10
I'm running 9.1.7 and i find ran the following successfully:
我运行的是9.1.7,我发现运行如下成功:
/usr/lib/postgresql/9.1/bin/pg_resetxlog -f /var/lib/postgresql/9.1/main
Your final argument to the pg_resetxlog
command should be the location on disk where postgres stores your database data.
pg_resetxlog命令的最后一个参数应该是postgres存储数据库数据的磁盘上的位置。
#3
6
As indicated here pg_resetxlog should not be run. The answers that refer to this is bad advice. Assuming the error occured in a context of copy/replication instance, the link provides a more succinct way of doing copy/replication with pg_basebackup
如这里所示,不应该运行pg_resetxlog。与此相关的答案是糟糕的建议。假设错误发生在复制/复制实例的上下文中,该链接提供了使用pg_basebackup进行复制/复制的更简洁的方法
#4
3
Do you do continuous archiving? If you are backing up at the time, you may find it more prudent to remove backup_label. pg_resetxlog
is a severe thing.
你们做连续归档吗?如果您正在备份,您可能会发现删除backup_label更谨慎。pg_resetxlog是一个严重的问题。
#5
1
just like the log saying : could not locate a valid checkpoint record.Postgres can't find a properly WAL under the $PGDATA/pg_xlog/ directory. Try to use pg_resetxlog
就像日志说的那样:无法找到有效的检查点记录。Postgres无法在$PGDATA/pg_xlog/目录下找到正确的WAL。尝试使用pg_resetxlog