Data Guard Workshop Lab Exercise Twelve
Data Guard Workshop Lab Exercise Twelve
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 1
Create the container database CDB1 via DBCA
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 2
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 3
Create an empty container database and ensure Local Undo Tablespaces are enabled for pluggable databases
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 4
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 5
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 6
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 7
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 8
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 9
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 10
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 11
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 12
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 13
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 14
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 15
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 16
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 17
On the standby host (host02) edit the listener.ora file
Add a static entry for cdb1_sb and reload the listener (lsnrctl reload)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = cdb1)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1)
(GLOBAL_DBNAME = cdb1_sb)
On both the primary as well as standby hosts, add entries in the tnsnames.ora file
CDB1 =
(DESCRIPTION =
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cdb1)
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 18
)
CDB1_sb =
(DESCRIPTION =
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cdb1_sb)
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 19
Create the init.ora file for the standby container database
Copy the init.ora from the primary database and make the following changes
*.db_unique_name='cdb1_sb'
*.standby_file_management=auto
*.log_archive_config='dg_config=(cdb1,cdb1_sb)'
*.fal_client=cdb1_sb
*.fal_server=cdb1
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 20
Enter password:
Connected to an idle instance.
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
RMAN>
duplicate target database for standby
from active database
dorecover
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 21
nofilenamecheck
;
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 22
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/u01/app/oracle/oradata/cdb1/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/cdb1/control02.ctl
Finished restore at 08-DEC-17
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 23
set newname for datafile 5 to
"/u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/cdb1/users01.dbf";
set newname for datafile 8 to
"/u01/app/oracle/oradata/cdb1/pdbseed/undotbs01.dbf";
restore
from nonsparse from service
'cdb1' clone database
;
sql 'alter system archive log current';
}
executing Memory Script
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 24
executing command: SET NEWNAME
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 25
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/cdb1/users01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service cdb1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/cdb1/pdbseed/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 08-DEC-17
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 26
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service cdb1
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=3
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service cdb1
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=4
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 08-DEC-17
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 27
set until scn 1444009;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 28
Open the standby container database
Database altered.
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY
System altered.
System altered.
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 29
System altered.
System altered.
System altered.
System altered.
On both Primary and Standby container databases create the Standby Log Files
Database altered.
Database altered.
Database altered.
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 30
SQL> alter database add standby logfile group 7 size 200m;
Database altered.
DESTINATION
--------------------------------------------------------------------------------
STATUS ERROR
--------- -----------------------------------------------------------------
VALID
cdb1_sb
VALID
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 31
Note the difference in the STANDBYS clause in the CREATE PLUGGABLE DATABASE statements
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB$SEED
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 32
READ ONLY
PDB1
READ WRITE
PDB2
READ WRITE
On the standby container database check that the pluggable databases have been created and are in mount state
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB$SEED
READ ONLY
PDB1
MOUNTED
PDB2
MOUNTED
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 33
System altered.
On the standby database container try and open the pluggable databases PDB1 and PDB2
Note that we will not be able to open the PDB2 pluggable database.
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB$SEED
READ ONLY
PDB1
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 34
READ ONLY
PDB2
MOUNTED
The data files for PDB2 pluggable database are in OFFLINE and RECOVER mode
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
STATUS
-------
/u01/app/oracle/oradata/cdb1/system01.dbf
SYSTEM
/u01/app/oracle/oradata/cdb1/sysaux01.dbf
ONLINE
/u01/app/oracle/oradata/cdb1/undotbs01.dbf
ONLINE
/u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf
SYSTEM
/u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf
ONLINE
/u01/app/oracle/oradata/cdb1/users01.dbf
ONLINE
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 35
/u01/app/oracle/oradata/cdb1/pdbseed/undotbs01.dbf
ONLINE
/u01/app/oracle/oradata/cdb1/pdb1/system01.dbf
SYSTEM
/u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf
RECOVER
/u01/app/oracle/oradata/cdb1/pdb1/undotbs01.dbf
ONLINE
/u01/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00012
SYSOFF
/u01/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00013
RECOVER
/u01/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00014
RECOVER
13 rows selected.
Change the Protection Level on the primary container database and perform some DDL and DML activity
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 36
Database altered.
Session altered.
Table created.
SQL> commit;
Commit complete.
COUNT(*)
----------
71478
Verify the changes have been applied on the standby container database as well
Session altered.
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 37
COUNT(*)
----------
71478
CON_NAME
------------------------------
CDB$ROOT
System altered.
Note in this case no STANDBYS clause has been used in the CREATE PLUGGABLE DATABASE statement
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 38
admin user pdbadmin identified by oracle
file_name_convert=('/u01/app/oracle/oradata/cdb1/pdbseed/','/u01/app/oracle/oradata/cdb1/pdb3/')
;
NAME OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED READ ONLY
PDB1 READ ONLY
PDB2 MOUNTED
PDB3 MOUNTED
NAME OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 39
PDB$SEED READ ONLY
PDB1 READ ONLY
PDB2 MOUNTED
PDB3 READ ONLY
On the standby container database site, add an entry in tnsnames.ora for PDB1
PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host02.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb1)
)
)
On the primary container database verify that a switchover operation can be performed
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 40
View the alert log for the container database
2017-12-08T11:14:14.702738+08:00
ALTER DATABASE SWITCHOVER TO cdb1_sb VERIFY
2017-12-08T11:14:14.872259+08:00
SWITCHOVER VERIFY: Send VERIFY request to switchover target CDB1_SB
SWITCHOVER VERIFY WARNING: switchover target has offline datafiles. Verify that those datafiles should remain offline.
SWITCHOVER VERIFY WARNING: switchover target temporary files are not the same with the primary. See switchover target's alert log for
details.
SWITCHOVER VERIFY WARNING: switchover target has offline pluggable databases.
ORA-16475 signalled during: ALTER DATABASE SWITCHOVER TO cdb1_sb VERIFY...
On the standby container database, add files to the temporary tablespaces for both PDB1 as well as PDB3
Session altered.
Tablespace altered.
Session altered.
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 41
SQL> alter tablespace temp add tempfile '/u01/app/oracle/oradata/cdb1/pdb3/temp01.dbf' size 64m;
Tablespace altered.
Database altered.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
DATABASE_ROLE OPEN_MODE
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 42
---------------- --------------------
PRIMARY MOUNTED
Database altered.
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB$SEED
READ ONLY
PDB1
READ WRITE
PDB2
MOUNTED
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 43
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB3
READ WRITE
Open the new standby container database and start all the pluggable databases except PDB2
Enter password:
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 44
SQL> alter pluggable database all except pdb2 open;
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB$SEED
READ ONLY
PDB1
READ ONLY
PDB2
MOUNTED
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
PDB3
READ ONLY
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 45
Start managed recovery on the new standby container database
Database altered.
Data Guard and Backup and Recovery Workshop Lab Exercise Twelve 46