Top
Enterprise Postgres 16 Operation Guide

17.1.2 Using Server Command

Recover the database cluster by following the appropriate recovery procedure below for the disk where the failure occurred.

If failure occurred on the data storage disk or the transaction log storage directory

Follow the procedure below to recover the data storage disk or the transaction log storage directory.

  1. Stop applications

    Stop applications that are using the database.

  2. Stop the instance

    Stop the instance, refer to "2.1.2 Using Server Commands" for details.

    If the instance fails to stop, refer to "17.11 Actions in Response to Failure to Stop an Instance".

  3. Recover the failed disk

    Replace the disk, and then recover the volume configuration information.

  4. Create a storage destination directory

    • If failure occurred on the data storage disk
      Create a data storage destination directory. If a tablespace was defined, also create a directory for it.

    • If failure occurred on the translation log storage disk
      Create a transaction log storage destination directory.

    Example

    To create a data storage destination directory:

    $ mkdir /database/inst1
    $ chown fsepuser:fsepuser /database/inst1
    $ chmod 700 /database/inst1

    See

    Refer to "Preparing Directories to Deploy Resources" under "Setup" in the Installation and Setup Guide for Server for information on how to create a storage directory.

  5. Recover the keystore, and enable automatic opening of the keystore

    When the data in the database has been encrypted, restore the keystore to its state at the time of the database backup. Configure automatic opening of the keystore as necessary.

  6. Recover the database cluster

    Recover the database cluster using the backup data.

    Specify the following in the pgx_rcvall command:

    • Specify the data storage location in the -D option. If the -D option is omitted, the value of the PGDATA environment variable is used by default.

    • Specify the backup data storage location in the -B option.

    Example
    > pgx_rcvall -D /database/inst1 -B /backup/inst1

    Note

    If recovery fails, remove the cause of the error in accordance with the displayed error message and then re-execute the pgx_rcvall command.

    If the message "pgx_rcvall: an error occurred during recovery" is displayed, then the log recorded when recovery was executed is output after this message. The cause of the error is output in around the last fifteen lines of the log, so remove the cause of the error in accordance with the message and then re-execute the pgx_rcvall command.

    The following message displayed during recovery is output as part of normal operation of pgx_rcvall command (therefore the user does not need not be concerned).

    FATAL: the database system is starting up
  7. Start the instance

    Start the instance.

    Refer to "2.1.2 Using Server Commands" for information on how to start an instance.

  8. Resume applications

    Resume applications that are using the database.

If failure occurred on the backup data storage disk

The procedure for recovering the backup data storage disk is described below.

There are two methods of taking action:

The following table shows the different steps to be performed depending on whether you stop the instance.

No

Step

Instance stopped

No

Yes

1

Confirm that transaction log mirroring has stopped

Y

N

2

Stop output of archive logs

Y

N

3

Stop applications

N

Y

4

Stop the instance

N

Y

5

Recover the failed disk

Y

Y

6

Create a backup data storage destination directory

Y

Y

7

Resume output of archive logs

Y

N

8

Resume transaction log mirroring

Y

N

9

Start the instance

N

Y

10

Run backup

Y

Y

11

Resume applications

N

Y

Y: Required
N: Not required

The procedure is as follows:

If an instance has not been stopped
  1. Confirm that transaction log mirroring has stopped

    Use the following SQL function to confirm that transaction log mirroring has stopped.

     postgres=# SELECT pgx_is_wal_multiplexing_paused();
     pgx_is_wal_multiplexing_paused
    -------------------
     t
    (1 row)

    If transaction log mirroring has not stopped, then stop it using the following SQL function.

    postgres=# SELECT pgx_pause_wal_multiplexing();
    LOG:  multiplexing of transaction log files has been stopped
    pgx_pause_wal_multiplexing
    ----------------------------
    
    (1 row)
  2. Stop output of archive logs

    Transaction logs may accumulate during replacement of backup storage disk, and if the data storage disk or the transaction log storage disk becomes full, there is a risk that operations may not be able to continue.

    To prevent this, use the following methods to stop output of archive logs.

    • Changing archive_command

      Specify a command that will surely complete normally, such as "echo skipped archiving WAL file %f" or "/bin/true", so that archive logs will be regarded as having been output.

      If you specify echo, a message is output to the server log, so it may be used as a reference when you conduct investigations.

    • Reload the configuration file

      Execute the pg_ctl reload command or the pg_reload_conf SQL function to reload the configuration file.

    If you simply want to stop output of errors without the risk that operations will not be able to continue, specify an empty string (") in archive_command and reload the configuration file.

  3. Recover the failed disk

    Replace the disk, and then recover the volume configuration information.

  4. Create a backup data storage destination

    Create a backup data storage destination.

    Example
    $ mkdir /database/inst1
    $ chown fsepuser:fsepuser /database/inst1
    $ chmod 700 /database/inst1

    Refer to "3.2.2 Using Server Commands" for information on how to create a backup data storage destination.

  5. Resume output of archive logs

    Return the archive_command setting to its original value, and reload the configuration file.

  6. Resume transaction log mirroring

    Execute the pgx_resume_wal_multiplexing SQL function.

    Example
    SELECT pgx_resume_wal_multiplexing()
  7. Run backup

    Use the pgx_dmpall command to back up the database cluster.

    Specify the following value in the pgx_dmpall command:

    • Specify the data storage destination in the -D option. If the -D option is omitted, the value of the PGDATA environment variable is used by default.

    Example
    > pgx_dmpall -D /database/inst1

If an instance has been stopped
  1. Stop applications

    Stop applications that are using the database.

  2. Stop the instance

    Stop the instance. Refer to "2.1.2 Using Server Commands" for details.

    If the instance fails to stop, refer to "17.11 Actions in Response to Failure to Stop an Instance".

  3. Recover the failed disk

    Replace the disk, and then recover the volume configuration information.

  4. Create a backup data storage destination

    Create a backup data storage destination.

    Example
    # mkdir /backup/inst1
    # chown fsepuser:fsepuser /backup/inst1
    # chmod 700 /backup/inst1

    Refer to "3.2.2 Using Server Commands" for details.

  5. Start the instance

    Start the instance. Refer to "2.1.2 Using Server Commands" for information on how to start an instance.

  6. Run backup

    Use the pgx_dmpall command to back up the database cluster.

    Specify the following value in the pgx_dmpall command:

    • Specify the data storage destination in the -D option. If the -D option is omitted, the value of the PGDATA environment variable is used by default.

    Example
    > pgx_dmpall -D /database/inst1
  7. Resume applications

    Resume applications that are using the database.

See

  • Refer to "pgx_rcvall" and "pgx_dmpall" in the Reference for information on the pgx_rcvall command and pgx_dmpall command.

  • Refer to "Write Ahead Log" under "Server Administration" in the PostgreSQL Documentation for information on archive_command.

  • Refer to "B.1 WAL Mirroring Control Functions" for information on pgx_resume_wal_multiplexing.