DataGuard Configuration in 12.2.0.1 Container Database
DataGuard Configuration in 12.2.0.1 Container Database
DataGuard Configuration in 12.2.0.1 Container Database
1 Container Database
Table
0. Introduction
1. Environment
2. Enable Forced Logging on Primary
3. Check Password File on Primary
4. Configure a Standby Redo Log on Primary
5. Verify Archive Mode Enabled on Primary
6. Set Primary Database Initialization Parameters
7. Transfer PFILE AND PASSWORD FILE TO STANDBY SIDE
8. Prepare an Initialization Parameter File for the Standby Database on Standby
9. Crete required directories on Standby
10. Add below entry in ORATAB on Standby
11. Create spfile from pfile on Standby
12. Configure TNS Entries on Primary
13. Configure TNS Entries on Standby
14. Verify connection ‘AS SYSDBA’ from Primary
15. Create Standby Database using duplicate command
16. Enable MRP on Standby
17. Open PDB in READ-ONLY Mode
18. Verify the log shipping Is Performing Properly
19. Verify the Physical Standby Database Is Performing Properly
0. Introduction
PLEASE NOTE in 12c Data Guard is set up at the Container level and not the individual
Pluggable database level as the redo log files only belong to the Container database and the
individual pluggable databases do not have their own online redo log files.
Oracle Active Data Guard enables read-only access to a physical standby database for queries,
sorting, reporting, web-based access, etc., while continuously applying changes received from
the production/primary database.
1. Environment
Source:
Platform : Linuxx86_64
Server Name : RAC1.RAJASEKHAR.COM, IP: 192.168.2.101
DB_UNIQUE_NAME : CDB1
Flashback : Disabled
Target:
Platform : Linuxx86_64
DB_UNIQUE_NAME : CDB1_DG
Flashback : Disabled
------------------------------
CDB$ROOT
SQL>
FORCE_LOGGING
---------------------------------------
NO
Database altered.
---------------------------------------
YES <----
SQL>
/u01/app/oracle/product/12.2.0.1/dbs
[oracle@rac1 dbs]$
4. Configure a Standby Redo Log on Primary
Note :
-- Since we have 3 online redo log file groups, we need to create 4(3+1) Standby redo log
file groups
-- Standy Redo logs files come into picture only when protection mode is Maximum Availability
and Maximum Protection.
CON_NAME
------------------------------
CDB$ROOT
SQL>
SQL> select b.thread#, a.group#, a.member, b.bytes FROM v$logfile a, v$log b WHERE a.group# =
b.group#;
1 3 /u01/app/oracle/oradata/CDB1/redo03.log 209715200
1 2 /u01/app/oracle/oradata/CDB1/redo02.log 209715200
1 1 /u01/app/oracle/oradata/CDB1/redo01.log 209715200
SQL>
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/u01/app/oracle/oradata/CDB1/redo04.log')
SIZE 200M; <---
Database altered.
Database altered.
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/u01/app/oracle/oradata/CDB1/redo07.log')
SIZE 200M;
Database altered.
SQL>
3 ONLINE /u01/app/oracle/oradata/CDB1/redo03.log NO 0
2 ONLINE /u01/app/oracle/oradata/CDB1/redo02.log NO 0
1 ONLINE /u01/app/oracle/oradata/CDB1/redo01.log NO 0
4 STANDBY /u01/app/oracle/oradata/CDB1/redo04.log NO 0
5 STANDBY /u01/app/oracle/oradata/CDB1/redo05.log NO 0
6 STANDBY /u01/app/oracle/oradata/CDB1/redo06.log NO 0
7 STANDBY /u01/app/oracle/oradata/CDB1/redo07.log NO 0
7 rows selected.
SQL> select a.group#, a.member, b.bytes FROM v$logfile a, v$standby_log b WHERE a.group# =
b.group#;
4 /u01/app/oracle/oradata/CDB1/redo04.log 209715200
5 /u01/app/oracle/oradata/CDB1/redo05.log 209715200
6 /u01/app/oracle/oradata/CDB1/redo06.log 209715200
7 /u01/app/oracle/oradata/CDB1/redo07.log 209715200
SQL>
/db_1/dbs/spfileapac.ora
File created.
System altered.
System altered.
System altered.
System altered.
System altered.
SQL> ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=30 scope=both;
System altered.
System altered.
System altered.
System altered.
System altered.
File created.
SQL>
CDB1.__data_transfer_cache_size=0
CDB1.__db_cache_size=1291845632
CDB1.__inmemory_ext_roarea=0
CDB1.__inmemory_ext_rwarea=0
CDB1.__java_pool_size=16777216
CDB1.__large_pool_size=33554432
CDB1.__pga_aggregate_target=620756992
CDB1.__sga_target=1845493760
CDB1.__shared_io_pool_size=100663296
CDB1.__shared_pool_size=385875968
CDB1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/CDB1/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/CDB1/control01.ctl','/u01/app/oracle/oradata/CDB1/co
ntrol02.ctl'
*.db_block_size=8192
*.db_file_name_convert='/u01/app/oracle/oradata/CDB1_DG','/u01/app/oracle/oradata/CDB1','/u01
/app/oracle/oradata/CDB1_DG/PDB1','/u01/app/oracle/oradata/CDB1/PDB1'
*.db_name='CDB1'
*.db_unique_name='CDB1'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=CDB1XDB)'
*.enable_pluggable_database=true
*.fal_client='CDB1'
*.fal_server='CDB1_DG'
*.local_listener='LISTENER_CDB1'
*.log_archive_config='DG_CONFIG=(CDB1,CDB1_DG)'
*.log_archive_dest_1='LOCATION=/u02/arch/CDB1 VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=CDB1'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes=30
*.log_file_name_convert='/u01/app/oracle/oradata/CDB1_DG','/u01/app/oracle/oradata/CDB1'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=583m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1746m
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
[oracle@rac1 ~]$
7. Transfer SPFILE AND PASSWORD FILE TO STANDBY SIDE
Copy the password file from the primary $ORACLE_HOME/dbs and rename it to the standby database name.
The username is required to be SYS and the password needs to be the same on the Primary and Standby.
The best practice for this is to copy the passwordfile as suggested.
The password file name must match the instance name/SID used at the standby site, not the DB_NAME.
oracle@rac2's password:
initCDB1.ora
100% 1769 1.7KB/s 00:00
orapwCDB1
100% 3584 3.5KB/s 00:00
[oracle@rac1 dbs]$
CDB1_DG.__data_transfer_cache_size=0
CDB1_DG.__db_cache_size=1291845632
CDB1_DG.__inmemory_ext_roarea=0
CDB1_DG.__inmemory_ext_rwarea=0
CDB1_DG.__java_pool_size=16777216
CDB1_DG.__large_pool_size=33554432
CDB1_DG.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
CDB1_DG.__pga_aggregate_target=620756992
CDB1_DG.__sga_target=1845493760
CDB1_DG.__shared_io_pool_size=100663296
CDB1_DG.__shared_pool_size=385875968
CDB1_DG.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/CDB1_DG/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/CDB1_DG/control01.ctl','/u01/app/oracle/oradata/CDB1
_DG/control02.ctl'
*.db_block_size=8192
*.db_file_name_convert='/u01/app/oracle/oradata/CDB1','/u01/app/oracle/oradata/CDB1_DG','/u01
/app/oracle/oradata/CDB1/PDB1','/u01/app/oracle/oradata/CDB1_DG/PDB1'
*.db_name='CDB1'
*.db_unique_name='CDB1_DG'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=CDB1_DGXDB)'
*.enable_pluggable_database=true
*.fal_client='CDB1_DG'
*.fal_server='CDB1'
*.local_listener='LISTENER_CDB1_DG'
*.log_archive_config='DG_CONFIG=(CDB1,CDB1_DG)'
*.log_archive_dest_1='LOCATION=/u02/arch/CDB1_DG VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=CDB1_DG'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes=30
*.log_file_name_convert='/u01/app/oracle/oradata/CDB1','/u01/app/oracle/oradata/CDB1_DG'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=583m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1746m
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
[oracle@rac2 ~]$
CDB1_DG:/u01/app/oracle/product/12.2.0.1:N
SQL>
File created.
SQL>
SQL>
.1/dbs/spfileCDB1_DG.ora
SQL>
12. Configure TNS Entries on Primary
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
)
[oracle@rac1 admin]$
LISTENER_CDB1 =
CDB1 =
(DESCRIPTION =
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CDB1)
PDB1 =
(DESCRIPTION =
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb1)
CDB1_DG =
(DESCRIPTION =
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CDB1_DG)(UR = A)
[oracle@rac1 admin]$
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.rajasekhar.com)(PORT=1521)))
------------------------
Alias LISTENER
SNMP OFF
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.rajasekhar.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=rac1.rajasekhar.com)(PORT=5500))(Security=(my_wall
et_directory=/u01/app/oracle/admin/CDB1/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
[oracle@rac1 admin]$
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 17-JUL-2018 21:22:20
/u01/app/oracle/product/12.2.0.1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
OK (0 msec)
[oracle@rac1 admin]$
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 17-JUL-2018 21:28:23
/u01/app/oracle/product/12.2.0.1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
OK (0 msec)
[oracle@rac1 admin]$
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
[oracle@rac2 admin]$
LISTENER_CDB1_DG =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.102)(PORT = 1521))
CDB1 =
(DESCRIPTION =
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CDB1)
CDB1_DG =
(DESCRIPTION =
(SERVER = DEDICATED)
(SERVICE_NAME = CDB1_DG)(UR = A)
PDB1 =
(DESCRIPTION =
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
[oracle@rac2 admin]$
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit
Production
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac2.rajasekhar.com)(PORT=1521)))
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
SNMP OFF
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac2.rajasekhar.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
[oracle@rac2 admin]$
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 17-JUL-2018 21:38:14
/u01/app/oracle/product/12.2.0.1/network/admin/sqlnet.ora
OK (0 msec)
[oracle@rac2 ~]$
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 17-JUL-2018 21:38:22
/u01/app/oracle/product/12.2.0.1/network/admin/sqlnet.ora
OK (0 msec)
[oracle@rac2 ~]$
Connected to:
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit
Production
[oracle@rac1 ~]$
Connected to:
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit
Production
[oracle@rac1 ~]$
On Primary:
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB1 (DBID=931007404)
RMAN> duplicate target database for standby from active database nofilenamecheck;
{
sql clone 'alter database mount standby database';
"/u01/app/oracle/oradata/CDB1_DG/temp01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/pdbseed/temp012017-10-13_17-53-30-404-PM.dbf";
"/u01/app/oracle/oradata/CDB1_DG/PDB1/temp01.dbf";
switch clone tempfile all;
"/u01/app/oracle/oradata/CDB1_DG/system01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/sysaux01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/undotbs01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/pdbseed/system01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/pdbseed/sysaux01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/users01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/PDB1/system01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/PDB1/sysaux01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/PDB1/undotbs01.dbf";
"/u01/app/oracle/oradata/CDB1_DG/PDB1/users01.dbf";
restore
RMAN> exit
ORACLE_SID = [CDB1_DG] ?
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
Database altered.
SQL>
oracle 15074 14602 0 21:56 pts/0 00:00:00 /bin/bash -c ps -ef | grep mrp
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL>
oracle 15091 14602 0 21:57 pts/0 00:00:00 /bin/bash -c ps -ef | grep mrp
SQL>
SQL>
SQL>
On Primary
Connected to:
------------------------------
CDB$ROOT
SQL>
SQL>
9 12-JUL-18 17-JUL-18
10 17-JUL-18 17-JUL-18
11 17-JUL-18 17-JUL-18
12 17-JUL-18 17-JUL-18
12 17-JUL-18 17-JUL-18
13 17-JUL-18 17-JUL-18
13 17-JUL-18 17-JUL-18
14 17-JUL-18 17-JUL-18
14 17-JUL-18 17-JUL-18
15 17-JUL-18 17-JUL-18
15 17-JUL-18 17-JUL-18
11 rows selected.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
--------------
18 <-----
SQL>
On Standby
2 ONLINE /u01/app/oracle/oradata/CDB1_DG/redo02.log NO 0
1 ONLINE /u01/app/oracle/oradata/CDB1_DG/redo01.log NO 0
4 STANDBY /u01/app/oracle/oradata/CDB1_DG/redo04.log NO 0
5 STANDBY /u01/app/oracle/oradata/CDB1_DG/redo05.log NO 0
6 STANDBY /u01/app/oracle/oradata/CDB1_DG/redo06.log NO 0
7 STANDBY /u01/app/oracle/oradata/CDB1_DG/redo07.log NO 0
7 rows selected.
SQL>
12 17-JUL-18 17-JUL-18
13 17-JUL-18 17-JUL-18
14 17-JUL-18 17-JUL-18
15 17-JUL-18 17-JUL-18
16 17-JUL-18 17-JUL-18
17 17-JUL-18 17-JUL-18
18 17-JUL-18 17-JUL-18
7 rows selected.
--------------
18 <----
SQL>
The Pluggable database PDB1 has been opened in READ ONLY mode, but the Container Database is running as an Active
Standby database and applying changes as they are received from the primary even when the Standby Container database
and all the associated pluggable databases have been opened in read only mode. This means Active Dataguard is working..
On Primary
Session altered.
SQL> create user raj identified by raj default tablespace users temporary tablespace temp;
User created.
Grant succeeded.
User altered.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit
Production
[oracle@rac1 ~]$ sqlplus raj/raj@pdb1 <----
Connected to:
USER is "RAJ"
1 row created.
SQL> /
1 row created.
SQL> /
1 row created.
SQL> /
Enter value for a: VIJAY
1 row created.
SQL> COMMIT;
Commit complete.
NAME ROLE
---------- ----------
RAJ DBA
SUGI DBA
TEJU DBA
VIJAY DBA
ERROR at line 1:
ERROR at line 1:
Connected.
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL>
MAX(SEQUENCE#)
--------------
21 <----
SQL>
On Standby
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 18-JUL-2018 10:10:06
/u01/app/oracle/product/12.2.0.1/network/admin/sqlnet.ora
OK (10 msec)
[oracle@rac2 admin]$
Connected to:
NAME ROLE
---------- ----------
RAJ DBA
SUGI DBA
TEJU DBA
VIJAY DBA
SQL>
Connected.
MRP0 WAIT_FOR_LOG 1 22 0
SQL>
SQL> select max(sequence#) from v$archived_log where applied='YES';
MAX(SEQUENCE#)
--------------
21 <---
SQL>