ORACLE DG Topic 4--Deploy DG Logical Backup Database

Before creating a logical standby database, you must first create a physical standby database. For how to create a physical standby database, please refer to the aforementioned article (ORACLE DG Topic 3-Hand-in-hand deployment of DG physical standby database ).

Reset the archiving parameters of the main library

Logical standby database is not the same as physical standby database. Logical standby database also generates logs during SQL application, that is, the online redo log of logical standby database. Therefore, logical standby database not only needs to archive the standby logs transferred from the main database. , You must also archive the online logs generated by the standby database.

Suppose log_archive_dest_1 specifies the archive path of the standby log, and log_archive_dest_3 specifies the archive path of the online log.

Although the main library does not need to configure two archive paths, in order to facilitate possible future role switching (switchover), it is generally recommended to do the corresponding configuration in the main library.

First, check the log_archive_dest_1 of the current main library:

SYS@JKKA> show parameter log_archive_dest_1

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string      location=/data/oradata/jkka/archivelog 
                                                 valid_for=(all_logfiles,all_roles)
                                                 db_unique_name=jkka

Need to modify the valid_for attribute to take effect only for online logs:

SQL> alter system set log_archive_dest_1='location=/data/oradata/jkka/archivelog valid_for=(online_logfiles,all_roles) db_unique_name=jkka';

System altered.

Then create a new standby archive directory on the OS, and the newly added log_archive_dest_3 points to it:

SQL> alter system set log_archive_dest_3='location=/odata/fast_recovery_area/T24APDB/archstandby VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=T24APDB';
System altered.

SQL> alter system set log_archive_dest_state_3=enable;
System altered.

Build the LogMiner dictionary in the main library

SQL> EXECUTE DBMS_LOGSTDBY.BUILD;
PL/SQL procedure successfully completed.

Stop the log application service on the physical standby database

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.

Convert physical standby database to logical standby database

SQL> ALTER DATABASE RECOVER TO LOGICAL STANDBY ADDBLG;
Database altered.

Note: The above ADDBLG is the db_name of the new logical standby database, which must be different from the db_name of the main database and the character length should not exceed 8 characters , which is different from the physical standby database.

After the above statement is executed successfully, the db_name of the standby database will be modified to the new name ADBLG, the standby database will be closed, and the mount state will be restarted to make it effective:

SQL> shutdown immediate
SQL> startup mount

Adjust logical standby database parameters

This step is similar to the first step, first check the current log_archive_dest_1 configuration:

 NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string      location=/data/oradata/jkka/archivelog 
                                                 valid_for=(all_logfiles,all_roles)
                                                 db_unique_name=jkka2

Need to modify the valid_for attribute to take effect only for online logs:

SQL> alter system set log_archive_dest_1='location=/data/oradata/jkka/archivelog valid_for=(online_logfiles,all_roles) db_unique_name=jkka2';
System altered.

log_archive_dest_2 remains unchanged:

NAME                                 TYPE        VALUE
----------------------------------- ----------- ------------------------------
log_archive_dest_2                   string      service=jkkapri ASYNC
                                                 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=jkka

Create a new standby archive directory on the OS, and the new log_archive_dest_3 points to it:

SQL> alter system set log_archive_dest_3='location=/data/oradata/jkka/archstandby VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=jkka2';
System altered.

SQL> alter system set log_archive_dest_state_3=enable;
System altered.

Open the logical standby database in resetlogs mode

SQL> alter database open resetlogs;
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

Possible errors:

  • Error when switching to logical backup

Solution: I don’t know what was reported wrong for the time being;

  • After switching the logical standby database, the standby database cannot be mounted or opened

Reason: The database name recorded in the control file: NAME is the original name T24APDB, which needs to be modified (nomount state). It is guessed that it is caused by the above switch

SQL> ALTER SYSTEM SET DB_NAME=ADDBLG scope=spfile;

Then restart the database (shutdown, startup)

reference

 This article refers to this article:

[Oracle] Data Guard Series (5)-Create a logical standby database

Guess you like

Origin blog.csdn.net/zhaogang1993/article/details/100975922