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.
Stop applications
Stop applications that are using the database.
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".
Recover the failed disk
Replace the disk, and then recover the volume configuration information.
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.
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.
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.
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.
> 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
Start the instance
Start the instance.
Refer to "2.1.2 Using Server Commands" for information on how to start an instance.
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:
Performing recovery while the instance is active
Stopping the instance before performing recovery
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:
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)
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.
Recover the failed disk
Replace the disk, and then recover the volume configuration information.
Create a backup data storage destination
Create a backup data storage destination.
$ 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.
Resume output of archive logs
Return the archive_command setting to its original value, and reload the configuration file.
Resume transaction log mirroring
Execute the pgx_resume_wal_multiplexing SQL function.
SELECT pgx_resume_wal_multiplexing()
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.
> pgx_dmpall -D /database/inst1
Stop applications
Stop applications that are using the database.
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".
Recover the failed disk
Replace the disk, and then recover the volume configuration information.
Create a backup data storage destination
Create a backup data storage destination.
# mkdir /backup/inst1 # chown fsepuser:fsepuser /backup/inst1 # chmod 700 /backup/inst1
Refer to "3.2.2 Using Server Commands" for details.
Start the instance
Start the instance. Refer to "2.1.2 Using Server Commands" for information on how to start an instance.
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.
> pgx_dmpall -D /database/inst1
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.