pg_resetxlog.1
来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 1 代码 · 共 126 行
1
126 行
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "PG_RESETXLOG" "1" "2008-01-03" "Application" "PostgreSQL Server Applications".SH NAMEpg_resetxlog \- reset the write-ahead log and other control information of a PostgreSQL database cluster.SH SYNOPSIS.sp\fBpg_resetxlog\fR [ \fB-f\fR ] [ \fB-n\fR ] [ \fB-o\fIoid\fB \fR ] [ \fB-x \fIxid\fB \fR ] [ \fB-e \fIxid_epoch\fB \fR ] [ \fB-m \fImxid\fB \fR ] [ \fB-O \fImxoff\fB \fR ] [ \fB-l \fItimelineid\fB,\fIfileid\fB,\fIseg\fB \fR ] \fB\fIdatadir\fB\fR.SH "DESCRIPTION".PP\fBpg_resetxlog\fR clears the write-ahead log (WAL) andoptionally resets some other control information stored in the\fIpg_control\fR file. This function is sometimes neededif these files have become corrupted. It should be used only as alast resort, when the server will not start due to such corruption..PPAfter running this command, it should be possible to start the server,but bear in mind that the database may contain inconsistent data due topartially-committed transactions. You should immediately dump your data,run \fBinitdb\fR, and reload. After reload, check forinconsistencies and repair as needed..PPThis utility can only be run by the user who installed the server, becauseit requires read/write access to the data directory.For safety reasons, you must specify the data directory on the command line.\fBpg_resetxlog\fR does not use the environment variable\fBPGDATA\fR..PPIf \fBpg_resetxlog\fR complains that it cannot determinevalid data for \fIpg_control\fR, you can force it to proceed anywayby specifying the -f (force) switch. In this case plausiblevalues will be substituted for the missing data. Most of the fields can beexpected to match, but manual assistance may be needed for the next OID,next transaction ID and epoch, next multitransaction ID and offset,WAL starting address, and database locale fields.The first six of these can be set using the switches discussed below.\fBpg_resetxlog\fR's own environment is the source for itsguess at the locale fields; take care that \fBLANG\fR and so forthmatch the environment that \fBinitdb\fR was run in.If you are not able to determine correct values for all these fields,-f can still be used, butthe recovered database must be treated with even more suspicion thanusual: an immediate dump and reload is imperative. \fBDo not\fRexecute any data-modifying operations in the database before you dump;as any such action is likely to make the corruption worse..PPThe -o, -x, -e,-m, -O,and -lswitches allow the next OID, next transaction ID, next transaction ID'sepoch, next multitransaction ID, next multitransaction offset, and WALstarting address values to be set manually. These are only needed when\fBpg_resetxlog\fR is unable to determine appropriate valuesby reading \fIpg_control\fR. Safe values may be determined asfollows:.TP 0.2i\(buA safe value for the next transaction ID (-x)may be determined by looking for the numerically largestfile name in the directory \fIpg_clog\fR under the data directory,adding one,and then multiplying by 1048576. Note that the file names are inhexadecimal. It is usually easiest to specify the switch value inhexadecimal too. For example, if \fI0011\fR is the largest entryin \fIpg_clog\fR, -x 0x1200000 will work (fivetrailing zeroes provide the proper multiplier)..TP 0.2i\(buA safe value for the next multitransaction ID (-m)may be determined by looking for the numerically largestfile name in the directory \fIpg_multixact/offsets\fR under thedata directory, adding one, and then multiplying by 65536. As above,the file names are in hexadecimal, so the easiest way to do this is tospecify the switch value in hexadecimal and add four zeroes..TP 0.2i\(buA safe value for the next multitransaction offset (-O)may be determined by looking for the numerically largestfile name in the directory \fIpg_multixact/members\fR under thedata directory, adding one, and then multiplying by 65536. As above,the file names are in hexadecimal, so the easiest way to do this is tospecify the switch value in hexadecimal and add four zeroes..TP 0.2i\(buThe WAL starting address (-l) should belarger than any file name currently existing inthe directory \fIpg_xlog\fR under the data directory.These names are also in hexadecimal and have three parts. The firstpart is the ``timeline ID'' and should usually be kept the same.Do not choose a value larger than 255 (0xFF) for the thirdpart; instead increment the second part and reset the third part to 0.For example, if \fI00000001000000320000004A\fR is thelargest entry in \fIpg_xlog\fR, -l 0x1,0x32,0x4B willwork; but if the largest entry is\fI000000010000003A000000FF\fR, choose -l 0x1,0x3B,0x0or more..TP 0.2i\(buThere is no comparably easy way to determine a next OID that's beyondthe largest one in the database, but fortunately it is not critical toget the next-OID setting right..TP 0.2i\(buThe transaction ID epoch is not actually stored anywhere in the databaseexcept in the field that is set by \fBpg_resetxlog\fR,so any value will work so far as the database itself is concerned.You might need to adjust this value to ensure that replicationsystems such as \fBSlony-I\fR work correctly \(emif so, an appropriate value should be obtainable from the state ofthe downstream replicated database..PP.PPThe -n (no operation) switch instructs\fBpg_resetxlog\fR to print the values reconstructed from\fIpg_control\fR and then exit without modifying anything.This is mainly a debugging tool, but may be useful as a sanity checkbefore allowing \fBpg_resetxlog\fR to proceed for real..SH "NOTES".PPThis command must not be used when the server is running. \fBpg_resetxlog\fR will refuse to start up ifit finds a server lock file in the data directory. If theserver crashed then a lock file may have been leftbehind; in that case you can remove the lock file to allow\fBpg_resetxlog\fR to run. But before you doso, make doubly certain that there is no server process still alive.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?