Oracle Dataguard 19c Configuration
Implementing a disaster recovery solution for Oracle databases involves setting up Oracle 19c Dataguard with PDB, which ensures data protection and availability. Dataguard provides real-time data protection, automatic failover, and the ability to create standby databases for the primary database. In a Dataguard configuration, a PDB within a CDB can be configured as either a primary or standby database, offering protection and failover at the PDB level. This approach allows for more precise disaster recovery and enhances flexibility in deploying and managing Oracle databases.
To set up Oracle 19c Dataguard with PDB, the following steps need to be followed:
- Ensure that two Machines are prepared with Linux Operating System with a minimum of 50 GB disk space and 8 GB RAM.
- Install the Oracle 19c binaries on both machines.
- Create a Database with PDB on the Primary machine.
After the two machines with sufficient disk space and RAM have been set up, and a Database with PDB has been successfully created, the next step is to initiate the Dataguard configuration on the primary machine. Here are the steps to configure Dataguard on the primary side for the Oracle 19c setup with PDB:
Step 1. Enable Archivelog Mode and Force logging
To ensure proper functionality, it is necessary for the primary database to operate in archivelog mode with force logging enabled. Please follow the steps below to enable force logging:
SQL> select log_mode from v$database; LOG_MODE SQL> shu immediate SQL> startup mount SQL> alter database archivelog; SQL> alter database force logging; SQL> select name,force_logging,log_mode from v$database; NAME FORCE_LOGGING LOG_MODE |
Step 2. Create standby redologfiles
To proceed, it is essential to incorporate standby redo log files. Please utilize the following commands to add them:
alter database add standby logfile group 4 ‘/u01/app/oracle/oradata/ORCL/redo04.log’ size 100m; alter database add standby logfile group 5 ‘/u01/app/oracle/oradata/ORCL/redo05.log’ size 100m; alter database add standby logfile group 6 ‘/u01/app/oracle/oradata/ORCL/redo06.log’ size 100m; alter database add standby logfile group 7 ‘/u01/app/oracle/oradata/ORCL/redo07.log’ size 100m; |
Now, Check redolog members’ detail which will show the standby redologs as added in the Above step:
SQL> select group#,member,type,status from v$logfile; GROUP# MEMBER TYPE STATUS 7 rows selected. |
Step 3. Create TNS entry for both (Primary & Standby)
In order to establish connectivity, it is necessary to create TNS and Listener entries for both databases. In my case, I will be adding the following entry to the “tnsnames.ora” file and copying it to both sides.
Location of the TNS file: “/u01/app/oracle/product/19.3.0/db_home/network/admin/tnsnames.ora”
ORCL = ORCLDR = |
Listener Entry On Primary Side
Listener file Location: “/u01/app/oracle/product/19.3.0/db_home/network/admin/listener.ora”
[oracle@primary admin]$ cat listener.ora # listener.ora Network Configuration File: /u01/app/oracle/product/19.3.0/db_home/network/admin/listener.ora SID_LIST_LISTENER = LISTENER = |
Listener Entry On Standby Side
[oracle@stby admin]$ cat listener.ora # listener.ora Network Configuration File: /u01/app/oracle/product/19.3.0/db_home/network/admin/listener.ora LISTENER = ADR_BASE_LISTENER = /u01/app/oracle |
Checking Connectivity on Both the Server through TNS Ping Utility
Start the listener and attempt to ping the TNS entry from both servers using the provided commands.
$tnsping orcldr $tnsping orcl |
NOTE |
If TNSPING is not working If your tnsping is not working then you have to recheck the below points: Check hostname or IP address in tnsnames.ora file Check /etc/hosts file entry Check firewall status – It should be disabled How to disable Firewall You can follow the below steps to disable the firewall.
If the Firewall is in Running State then Use the Following Given Commands to Stop and Disable the Firewall
|
Step 4. Parameters Configuration of the dataguard on primary side
SQL> ALTER SYSTEM SET log_archive_config=’dg_config=(orcl,orcldr)’ SCOPE=both; SQL> ALTER SYSTEM SET fal_server=’orcldr’ SCOPE=both; SQL> ALTER SYSTEM SET fal_client=’orcl’ SCOPE=both; SQL> ALTER SYSTEM SET standby_file_management=’AUTO’ SCOPE=both; SQL> ALTER SYSTEM SET log_archive_dest_1=’location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=orcl’ SCOPE=both; SQL> ALTER SYSTEM SET log_archive_dest_2=’service=orcldr async valid_for=(online_logfiles,primary_role) db_unique_name=orcldr’ SCOPE=both; SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE; |
Step 5. Password file Configuration
Copy the password file from the primary server to the standby server and rename it on the standby server with the name of the standby database.
$ scp orapworcl oracle@192.168.1.110:$ORACLE_HOME/dbs/ |
Rename password file on standby:
$ cd $ORACLE_HOME/dbs |
Step 6: Activate Fast Recovery Area (FRA) on the Primary side.
In this setup, we utilize Fast Recovery Area (FRA) for archiving purposes, hence it is necessary to enable it as the first step.
SQL> alter system set db_recovery_file_dest_size=10G; SQL> alter system set db_recovery_file_dest=’/u01/app/oracle/fast_recovery_area/’; |
Step 7: Verify the locations of datafiles and audit files on the Primary side.
SQL> select name from v$datafile; NAME 13 rows selected. SQL> show parameter audit_file_dest NAME TYPE VALUE |
Step 8. Action on Standby for Creating the Directories
Create the following required directories on the standby side as given below: ‘
$mkdir -p /u01/app/oracle/oradata/ORCLDR/ |
Step 9. Create PFILE for Standby
Create a PFILE using the following parameters only given below:
$ vi /u01/app/oracle/product/19.3.0/db_home/dbs/initorcldr.ora db_name=orcl enable_pluggable_database=true |
Step 10. Starting the Standby Database in Nomount State
Start Standby database in nomount state using the PFILE Create in Step 9
$ export ORACLE_SID=orcldr |
Step 11: Establish a connection with RMAN.
$ rman target sys/sys@orcl auxiliary sys/sys@orcldr |
Begin the process of constructing the standby database using RMAN. It is now time to build the standby database utilizing RMAN. Kindly execute to the following RMAN Script in the RMAN Prompt Connected above:
RMAN> run { allocate channel c1 type disk; allocate channel c2 type disk; allocate channel c3 type disk; allocate auxiliary channel c4 type disk; allocate auxiliary channel c5 type disk; allocate auxiliary channel c6 type disk; duplicate target database for standby from active database spfile parameter_value_convert ‘orcl’,’orcldr’ set db_name=’orcl’ set db_unique_name=’orcldr’ set audit_file_dest=’/u01/app/oracle/admin/orcl/adump’ set diagnostic_dest=’/u01/app/oracle/admin/orcl/adump’ set db_file_name_convert=’/u01/app/oracle/oradata/ORCL/’,’/u01/app/oracle/oradata/ORCLDR/’ set log_file_name_convert=’/u01/app/oracle/oradata/ORCL/’,’/u01/app/oracle/oradata/ORCLDR/’ set control_files=’/ocptechnology/app/oracle/oradata/ORCLDR/standby1.ctl’ set log_archive_max_processes=’5′ set fal_client=’orcldr’ set fal_server=’orcl’ set standby_file_management=’AUTO’ set log_archive_config=’dg_config=(orcl,orcldr)’ set compatible=’19.0.0.0.0′ nofilenamecheck; } |
Once the RMAN process mentioned above is completed, the configuration of our Dataguard has been successfully accomplished. We can now proceed to open the standby database and initiate the Managed Recovery Process (MRP).
SQL> alter database open; SQL> alter database recover managed standby database disconnect nodelay; |
Step 11: Checking the MRP Process
To verify the status of the Managed Recovery Process (MRP) and determine if it is currently running, you can utilize the provided command.
SQL> select sequence#,process,status from v$managed_standby |
Step 12: Checking the Standby Database Role and Status
Verify the role and open status of the standby database with the following Given Command:
SQL> select name,open_mode,database_role from v$database; NAME OPEN_MODE DATABASE_ROLE |