Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 5fea23694c765462b86d6ddf74461eab > files > 24

postgresql9.6-docs-9.6.22-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pg_resetxlog</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.6.22 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="PostgreSQL Server Applications"
HREF="reference-server.html"><LINK
REL="PREVIOUS"
TITLE="pg_ctl"
HREF="app-pg-ctl.html"><LINK
REL="NEXT"
TITLE="pg_rewind"
HREF="app-pgrewind.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2021-05-18T09:16:10"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="4"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.6.22 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="pg_ctl"
HREF="app-pg-ctl.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="reference-server.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="pg_rewind"
HREF="app-pgrewind.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="APP-PGRESETXLOG"
></A
><SPAN
CLASS="APPLICATION"
>pg_resetxlog</SPAN
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN103430"
></A
><H2
>Name</H2
>pg_resetxlog&nbsp;--&nbsp;reset the write-ahead log and other control information of a <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> database cluster</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN103434"
></A
><H2
>Synopsis</H2
><P
><TT
CLASS="COMMAND"
>pg_resetxlog</TT
> [<TT
CLASS="OPTION"
>-f</TT
>] [<TT
CLASS="OPTION"
>-n</TT
>] [<TT
CLASS="REPLACEABLE"
><I
>option</I
></TT
>...] {[<TT
CLASS="OPTION"
>-D</TT
>] <TT
CLASS="REPLACEABLE"
><I
>datadir</I
></TT
>}</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="R1-APP-PGRESETXLOG-1"
></A
><H2
>Description</H2
><P
>   <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> clears the write-ahead log (WAL) and
   optionally resets some other control information stored in the
   <TT
CLASS="FILENAME"
>pg_control</TT
> file.  This function is sometimes needed
   if these files have become corrupted.  It should be used only as a
   last resort, when the server will not start due to such corruption.
  </P
><P
>   After running this command, it should be possible to start the server,
   but bear in mind that the database might contain inconsistent data due to
   partially-committed transactions.  You should immediately dump your data,
   run <TT
CLASS="COMMAND"
>initdb</TT
>, and reload.  After reload, check for
   inconsistencies and repair as needed.
  </P
><P
>   This utility can only be run by the user who installed the server, because
   it requires read/write access to the data directory.
   For safety reasons, you must specify the data directory on the command line.
   <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> does not use the environment variable
   <TT
CLASS="ENVAR"
>PGDATA</TT
>.
  </P
><P
>   If <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> complains that it cannot determine
   valid data for <TT
CLASS="FILENAME"
>pg_control</TT
>, you can force it to proceed anyway
   by specifying the <TT
CLASS="OPTION"
>-f</TT
> (force) option.  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 options
   discussed below. If you are not able to determine correct values for all
   these fields, <TT
CLASS="OPTION"
>-f</TT
> can still be used, but
   the recovered database must be treated with even more suspicion than
   usual: an immediate dump and reload is imperative.  <SPAN
CLASS="emphasis"
><I
CLASS="EMPHASIS"
>Do not</I
></SPAN
>
   execute any data-modifying operations in the database before you dump,
   as any such action is likely to make the corruption worse.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN103463"
></A
><H2
>Options</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="OPTION"
>-f</TT
></DT
><DD
><P
>      Force <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> to proceed even if it cannot determine
      valid data for <TT
CLASS="FILENAME"
>pg_control</TT
>, as explained above.
     </P
></DD
><DT
><TT
CLASS="OPTION"
>-n</TT
></DT
><DD
><P
>      The <TT
CLASS="OPTION"
>-n</TT
> (no operation) option instructs
      <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> to print the values reconstructed from
      <TT
CLASS="FILENAME"
>pg_control</TT
> and values about to be changed, and then exit
      without modifying anything. This is mainly a debugging tool, but can be
      useful as a sanity check before allowing <TT
CLASS="COMMAND"
>pg_resetxlog</TT
>
      to proceed for real.
     </P
></DD
><DT
><TT
CLASS="OPTION"
>-V</TT
><BR><TT
CLASS="OPTION"
>--version</TT
></DT
><DD
><P
>Display version information, then exit.</P
></DD
><DT
><TT
CLASS="OPTION"
>-?</TT
><BR><TT
CLASS="OPTION"
>--help</TT
></DT
><DD
><P
>Show help, then exit.</P
></DD
></DL
></DIV
><P
>   The following options are only needed when
   <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> is unable to determine appropriate values
   by reading <TT
CLASS="FILENAME"
>pg_control</TT
>.  Safe values can be determined as
   described below.  For values that take numeric arguments, hexadecimal
   values can be specified by using the prefix <TT
CLASS="LITERAL"
>0x</TT
>.
  </P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="OPTION"
>-c</TT
> <TT
CLASS="REPLACEABLE"
><I
>xid</I
></TT
>,<TT
CLASS="REPLACEABLE"
><I
>xid</I
></TT
></DT
><DD
><P
>      Manually set the oldest and newest transaction IDs for which the commit
      time can be retrieved.
     </P
><P
>      A safe value for the oldest transaction ID for which the commit time can
      be retrieved (first part) can be determined by looking
      for the numerically smallest file name in the directory
      <TT
CLASS="FILENAME"
>pg_commit_ts</TT
> under the data directory.  Conversely, a safe
      value for the newest transaction ID for which the commit time can be
      retrieved (second part) can be determined by looking for the numerically
      greatest file name in the same directory.  The file names are in
      hexadecimal.
     </P
></DD
><DT
><TT
CLASS="OPTION"
>-e</TT
> <TT
CLASS="REPLACEABLE"
><I
>xid_epoch</I
></TT
></DT
><DD
><P
>      Manually set the next transaction ID's epoch.
     </P
><P
>      The transaction ID epoch is not actually stored anywhere in the database
      except in the field that is set by <TT
CLASS="COMMAND"
>pg_resetxlog</TT
>,
      so any value will work so far as the database itself is concerned.
      You might need to adjust this value to ensure that replication
      systems such as <SPAN
CLASS="APPLICATION"
>Slony-I</SPAN
> and
      <SPAN
CLASS="APPLICATION"
>Skytools</SPAN
> work correctly &mdash;
      if so, an appropriate value should be obtainable from the state of
      the downstream replicated database.
     </P
></DD
><DT
><TT
CLASS="OPTION"
>-l</TT
> <TT
CLASS="REPLACEABLE"
><I
>xlogfile</I
></TT
></DT
><DD
><P
>      Manually set the WAL starting address.
     </P
><P
>      The WAL starting address should be
      larger than any WAL segment file name currently existing in
      the directory <TT
CLASS="FILENAME"
>pg_xlog</TT
> under the data directory.
      These names are also in hexadecimal and have three parts.  The first
      part is the <SPAN
CLASS="QUOTE"
>"timeline ID"</SPAN
> and should usually be kept the same.
      For example, if <TT
CLASS="FILENAME"
>00000001000000320000004A</TT
> is the
      largest entry in <TT
CLASS="FILENAME"
>pg_xlog</TT
>, use <TT
CLASS="LITERAL"
>-l 00000001000000320000004B</TT
> or higher.
     </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>       <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> itself looks at the files in
       <TT
CLASS="FILENAME"
>pg_xlog</TT
> and chooses a default <TT
CLASS="OPTION"
>-l</TT
> setting
       beyond the last existing file name.  Therefore, manual adjustment of
       <TT
CLASS="OPTION"
>-l</TT
> should only be needed if you are aware of WAL segment
       files that are not currently present in <TT
CLASS="FILENAME"
>pg_xlog</TT
>, such as
       entries in an offline archive; or if the contents of
       <TT
CLASS="FILENAME"
>pg_xlog</TT
> have been lost entirely.
      </P
></BLOCKQUOTE
></DIV
></DD
><DT
><TT
CLASS="OPTION"
>-m</TT
> <TT
CLASS="REPLACEABLE"
><I
>mxid</I
></TT
>,<TT
CLASS="REPLACEABLE"
><I
>mxid</I
></TT
></DT
><DD
><P
>      Manually set the next and oldest multitransaction ID.
     </P
><P
>      A safe value for the next multitransaction ID (first part) can be
      determined by looking for the numerically largest file name in the
      directory <TT
CLASS="FILENAME"
>pg_multixact/offsets</TT
> under the data directory,
      adding one, and then multiplying by 65536 (0x10000).  Conversely, a safe
      value for the oldest multitransaction ID (second part of
      <TT
CLASS="OPTION"
>-m</TT
>) can be determined by looking for the numerically smallest
      file name in the same directory and multiplying by 65536.  The file
      names are in hexadecimal, so the easiest way to do this is to specify
      the option value in hexadecimal and append four zeroes.
     </P
></DD
><DT
><TT
CLASS="OPTION"
>-o</TT
> <TT
CLASS="REPLACEABLE"
><I
>oid</I
></TT
></DT
><DD
><P
>      Manually set the next OID.
     </P
><P
>      There is no comparably easy way to determine a next OID that's beyond
      the largest one in the database, but fortunately it is not critical to
      get the next-OID setting right.
     </P
></DD
><DT
><TT
CLASS="OPTION"
>-O</TT
> <TT
CLASS="REPLACEABLE"
><I
>mxoff</I
></TT
></DT
><DD
><P
>      Manually set the next multitransaction offset.
     </P
><P
>      A safe value can be determined by looking for the numerically largest
      file name in the directory <TT
CLASS="FILENAME"
>pg_multixact/members</TT
> under the
      data directory, adding one, and then multiplying by 52352 (0xCC80).
      The file names are in hexadecimal.  There is no simple recipe such as
      the ones for other options of appending zeroes.
     </P
></DD
><DT
><TT
CLASS="OPTION"
>-x</TT
> <TT
CLASS="REPLACEABLE"
><I
>xid</I
></TT
></DT
><DD
><P
>      Manually set the next transaction ID.
     </P
><P
>      A safe value can be determined by looking for the numerically largest
      file name in the directory <TT
CLASS="FILENAME"
>pg_clog</TT
> under the data directory,
      adding one,
      and then multiplying by 1048576 (0x100000).  Note that the file names are in
      hexadecimal.  It is usually easiest to specify the option value in
      hexadecimal too. For example, if <TT
CLASS="FILENAME"
>0011</TT
> is the largest entry
      in <TT
CLASS="FILENAME"
>pg_clog</TT
>, <TT
CLASS="LITERAL"
>-x 0x1200000</TT
> will work (five
      trailing zeroes provide the proper multiplier).
     </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN103576"
></A
><H2
>Notes</H2
><P
>   This command must not be used when the server is
   running.  <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> will refuse to start up if
   it finds a server lock file in the data directory.  If the
   server crashed then a lock file might have been left
   behind; in that case you can remove the lock file to allow
   <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> to run.  But before you do
   so, make doubly certain that there is no server process still alive.
  </P
><P
>   <TT
CLASS="COMMAND"
>pg_resetxlog</TT
> works only with servers of the same
   major version.
  </P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN103583"
></A
><H2
>See Also</H2
><A
HREF="app-pgcontroldata.html"
><SPAN
CLASS="APPLICATION"
>pg_controldata</SPAN
></A
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-pg-ctl.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pgrewind.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><SPAN
CLASS="APPLICATION"
>pg_ctl</SPAN
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference-server.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><SPAN
CLASS="APPLICATION"
>pg_rewind</SPAN
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>