Configuring Oracle 19c Data Guard

                     

      ·        High Availability [Database Level]
·        Standby server is not worthy useless until disaster comes.
·        Primary Server [user will only connected]
·        Standby Server [Up to 32]
·        Primary & Standby server are connected through Network.
·        Failure Activity - Convert standby server as primary server.
·        If you create a table internally generate archive log then archive log are shipping from  primary to standby through network.
·        On primary, LNSn process captures redo from redo log buffer (or from redo log files if         written quickly by LGWR process) and then sends it to RFS process on Standby database through Oracle net. Once RFS process writes redo to standby redo log files it will be applied on standby database through MRP process.
·        Managed Recovery Process (MRP) will applied (execute) changes to the database.
 
Server 01: DC (Primary)
 
[root@primary ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.73.134  primary.shohan.com      primary
192.168.73.135  standby.shohan.com      standby
 
Server 02: DR (Standby)
 
[root@standby ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.73.134  primary.shohan.com      primary
192.168.73.135  standby.shohan.com      standby
 
Server 01: DC (Primary)
              
SQL> alter database force logging;
 
o   Check the size of online logfile and create same size standby logfile
 
SQL> select GROUP#,THREAD#,SEQUENCE#,bytes/1024/1024,MEMBERS,STATUS from v$log;
 
   GROUP#    THREAD#  SEQUENCE# BYTES/1024/1024    MEMBERS STATUS
---------- ---------- ---------- --------------- ---------- ----------------
         1          1          4             200          1 INACTIVE
         2          1          5             200          1 ACTIVE
         3          1          6             200          1 CURRENT
 
SQL> select member from v$logfile;
 
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/MAXCDB/redo03.log
/u01/app/oracle/oradata/MAXCDB/redo02.log
/u01/app/oracle/oradata/MAXCDB/redo01.log
 
o   Create standby redo logs for switchovers and should be adding one extra.
 
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 4 '/u01/app/oracle/oradata/MAXCDB/redo04.log' SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 5 '/u01/app/oracle/oradata/MAXCDB/redo05.log' SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 6 '/u01/app/oracle/oradata/MAXCDB/redo06.log' SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 7 '/u01/app/oracle/oradata/MAXCDB/redo07.log' SIZE 200M;

 
SQL> SELECT group#, type, member FROM v$logfile WHERE type = 'STANDBY' order by group#;
 
o   Check DB_NAME & DB_UNIQUE_NAME
 
SQL> show parameter db_name 
                              
TYPE         VALUE       NAME
----------- ----------- -----------
db_name       string      maxcdb
 
SQL> show parameter db_unique_name  
                                 
TYPE              VALUE        NAME
---------------  ------------ -----------
db_unique_name     string      maxcdb
 
o   Set the log_archive_config parameter
 
SQL> alter system set log_archive_config='dg_config=(maxcdb,stand)';
 
o   set remote archivelog destination for standby & local is in flash_recovery_area.
 
SQL> alter system set log_archive_dest_2='service=stand async noaffirm reopen=15 valid_for=(all_logfiles,primary_role) db_unique_name=stand';    
 
System altered.
 
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
 
System altered.
              
SQL> alter system set remote_login_passwordfile='EXCLUSIVE' scope=spfile;
 
SQL> alter system set fal_server='stand';
 
[oracle@primary ~]$ cd $ORACLE_HOME/network/admin
 
[oracle@primary admin]$ vi listener.ora
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = maxcdb)
      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
      (SID_NAME = maxcdb)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = maxpdb)
      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
      (SID_NAME = maxpdb)
    )
  )
 
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.134)(PORT = 1521))
  )
 
ADR_BASE_LISTENER = /u01/app/oracle
 
o   TNS FIle on both primary and standby
 
MAXCDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.134)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = maxcdb)
    )
  )
 
STAND =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.135)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = maxcdb)
    )
  )
 
LISTENER_MAXCDB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.134)(PORT = 1521))
 
MAXPDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.134)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = maxpdb)
    )
  )
 
o   Stop and Start the listener
 
oracle@primary admin]$ lsnrctl stop
oracle@primary admin]$ lsnrctl start
 
o   Crosscheck with tnsping for both stand and primary database.
 
[oracle@primary admin]$ tnsping maxcdb
 
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 07-AUG-2024 22:19:48
Copyright (c) 1997, 2019, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/19.0.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = primary.shohan.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = maxcdb)))
OK (0 msec)
 
[oracle@primary admin]$ tnsping stand
 
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 09-AUG-2024 20:49:21
Copyright (c) 1997, 2019, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/19.0.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.135)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = maxcdb)))
TNS-12541: TNS:no listener
 
o   Move the PFILE,Password file,listener.ora,tnsnames.ora file to standby. Change the name of files as per standby database.
 
[oracle@primary admin]$ scp listener.ora 192.168.73.135:/u01/app/oracle/product/19.0.0/dbhome_1/network/admin
 
The authenticity of host '192.168.73.134 (192.168.73.135)' can't be established.
ECDSA key fingerprint is SHA256:zZ7IkyYbrgaYCI/gMmp1C68FqwMahKMcMniTfaG/BcY.
ECDSA key fingerprint is MD5:9f:eb:77:48:d9:f9:0a:f1:40:e7:d7:9d:1e:5c:69:8e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.73.134' (ECDSA) to the list of known hosts.
oracle@192.168.73.135's password:
listener.ora                                  100%  614   607.7KB/s   00:00
 
[oracle@primary admin]$ scp tnsnames.ora 192.168.73.135:/u01/app/oracle/product/19.0.0/dbhome_1/network/admin
 
oracle@192.168.73.135's password:
tnsnames.ora                                  100%  792   850.0KB/s   00:00
 
o   Create pfile from spfile for the standby database
 
[oracle@primary ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Aug 8 01:15:34 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
 
SQL> create pfile from spfile;
 
File created.
 
[oracle@primary dbs]$ scp initmaxcdb.ora 192.168.73.135:/u01/app/oracle/product/19.0.0/dbhome_1/dbs
 
The authenticity of host '192.168.73.135 (192.168.73.135)' can't be established.
ECDSA key fingerprint is SHA256:zZ7IkyYbrgaYCI/gMmp1C68FqwMahKMcMniTfaG/BcY.
ECDSA key fingerprint is MD5:9f:eb:77:48:d9:f9:0a:f1:40:e7:d7:9d:1e:5c:69:8e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.73.135' (ECDSA) to the list of known hosts.
oracle@192.168.73.135's password:
initmaxcdb.ora                                100% 1443   597.8KB/s   00:00
 
[oracle@primary dbs]$ scp orapwmaxcdb 192.168.73.135:/u01/app/oracle/product/19.0.0/dbhome_1/dbs
 
oracle@192.168.73.135's password:
orapwmaxcdb                                   100% 2048     1.1MB/s   00:00
[oracle@primary dbs]$
 
Server 02: DR (Standby)
 
[oracle@standby admin]$ vi listener.ora
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = maxcdb)
      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
      (SID_NAME = maxcdb)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = maxpdb)
      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
      (SID_NAME = maxpdb)
    )
  )
 
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.135)(PORT = 1521))
  )
 
ADR_BASE_LISTENER = /u01/app/oracle
 
[oracle@standby admin]$ vi tnsnames.ora
 
MAXCDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.134)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = maxcdb)
    )
  )
 
STAND =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.135)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = maxcdb)
    )
  )
 
LISTENER_MAXCDB =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.134)(PORT = 1521))
 
MAXPDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.73.135)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = maxpdb)
    )
  )
 
[oracle@standby dbs]$ vi initmaxcdb.ora
 
*.audit_file_dest='/u01/app/oracle/admin/maxcdb/adump'
*.audit_trail='db'
*.compatible='19.0.0'
*.control_files='/u01/app/oracle/oradata/MAXCDB/control01.ctl','/u01/app/oracle/fast_recovery_area/MAXCDB/control02.ctl'
*.db_block_size=8192
*.db_name='maxcdb'
*.db_unique_name='stand'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=12732m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=maxcdbXDB)'
*.enable_pluggable_database=true
*.fal_server='maxcdb'
*.local_listener='LISTENER_MAXCDB'
*.log_archive_config='dg_config=(maxcdb,stand)'
*.log_archive_dest_2='service=maxcdb async noaffirm reopen=15 valid_for=(all_logfiles,primary_role) db_unique_name=maxcdb'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=578m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1732m
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
 
[oracle@standby dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area
[oracle@standby dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area/MAXCDB/
[oracle@standby dbs]$ mkdir -p /u01/app/oracle/oradata/MAXCDB/
[oracle@standby dbs]$ mkdir -p /u01/app/oracle/admin/maxcdb/adump
  
[oracle@standby dbs]$ sqlplus / as sysdba
 
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 9 21:11:23 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to an idle instance.
 
SQL> startup nomount
 
ORACLE instance started.
Total System Global Area 1828714320 bytes
Fixed Size                  9135952 bytes
Variable Size             436207616 bytes
Database Buffers         1375731712 bytes
Redo Buffers                7639040 bytes
 
SQL> create spfile from pfile;
 
File created.
 
SQL> startup nomount force;
 
ORACLE instance started.
Total System Global Area 1828714320 bytes
Fixed Size                  9135952 bytes
Variable Size             436207616 bytes
Database Buffers         1375731712 bytes
Redo Buffers                7639040 bytes
 
[oracle@primary ~]$ rman target sys/oracle@maxcdb auxiliary sys/oracle@stand
 
Recovery Manager: Release 19.0.0.0.0 - Production on Fri Aug 9 21:13:53 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.
 
connected to target database: MAXCDB (DBID=2567024698)
connected to auxiliary database: MAXCDB (not mounted)
 
RMAN> DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE NOFILENAMECHECK;
 
Starting Duplicate Db at 09-AUG-24
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=7 device type=DISK
contents of Memory Script:
{
   backup as copy reuse
   passwordfile auxiliary format  '/u01/app/oracle/product/19.0.0/dbhome_1/dbs/orapwmaxcdb'   ;
}
executing Memory Script
input datafile copy RECID=13 STAMP=1176585386 file name=/u01/app/oracle/oradata/MAXCDB/maxpdb/undotbs01.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=14 STAMP=1176585386 file name=/u01/app/oracle/oradata/MAXCDB/maxpdb/users01.dbf
Finished Duplicate Db at 09-AUG-24
 
Server 02: DR (Standby)
 
SQL> select name, open_mode, database_role, INSTANCE_NAME from v$database,v$instance;
 
NAME      OPEN_MODE            DATABASE_ROLE    INSTANCE_NAME
--------- -------------------- ---------------- ----------------
MAXCDB    MOUNTED              PHYSICAL STANDBY maxcdb
 
SQL> shu immediate
 
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1828714320 bytes
Fixed Size                  9135952 bytes
Variable Size             436207616 bytes
Database Buffers         1375731712 bytes
Redo Buffers                7639040 bytes
Database mounted.
Database opened.
 
SQL> select name, open_mode, database_role, INSTANCE_NAME from v$database,v$instance;
 
NAME      OPEN_MODE            DATABASE_ROLE    INSTANCE_NAME
--------- -------------------- ---------------- ----------------
MAXCDB    READ ONLY            PHYSICAL STANDBY maxcdb
 
SQL> alter database recover managed standby database disconnect from session;
 
Database altered.
 
SQL> select name, open_mode, database_role, INSTANCE_NAME from v$database,v$instance;
 
NAME      OPEN_MODE            DATABASE_ROLE    INSTANCE_NAME
--------- -------------------- ---------------- ----------------
MAXCDB    READ ONLY WITH APPLY PHYSICAL STANDBY maxcdb
 
o   Find the gap of log sequence applied in Primary and Standby instance
 
SQL> select sequenceInPrimary, sequenceSynchedInStandBy, sequenceInPrimary-sequenceSynchedInStandBy as  logApplyGap from (select max(sequence#) sequenceInPrimary from v$archived_log) ,(select max(sequence#) sequenceSynchedInStandBy from v$archived_log where applied='YES');
 
SEQUENCEINPRIMARY SEQUENCESYNCHEDINSTANDBY LOGAPPLYGAP
----------------------------- -------------------------------------------  --------------------
               10                                                 10                                         0

Previous Post Next Post

نموذج الاتصال