By Mouhamadou Diaw
Generally we do active duplicate from primary database, but I think it should be fine to see what happen if we do active duplicate a database from a standby database. So, I do some tests and I write the results in this blog
Below the actual configuration of my Data Guard environment
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
DGMGRL> show configurationConfiguration - db21 Protection Mode: MaxPerformance Members: DB21_SITE1 - Primary database DB21_SITE2 - Physical standby databaseFast-Start Failover: DisabledConfiguration Status:SUCCESS (status updated 35 seconds ago)DGMGRL> |
The tests are done with Oracle 21c but I guess it should work for 19c
Standby in Read Only Mode
The first tests I do is with the standby opened in read only mode
If you do not have Active Data Duard license stop the apply process before opening the database in Read Only mode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
oracle@oraadserver2:/home/oracle/ [DB21 (CDB$ROOT)] DB21********* dbi services Ltd. *********STATUS : OPENDB_UNIQUE_NAME : DB21_SITE2OPEN_MODE : READ ONLYLOG_MODE : ARCHIVELOGDATABASE_ROLE : PHYSICAL STANDBYFLASHBACK_ON : YESFORCE_LOGGING : YESVERSION : 21.0.0.0.0CDB Enabled : YESList PDB(s) MOUNTED : PDB1, PDB2, PDB3List PDB(s) READ ONLY : PDB$SEED*************************************oracle@oraadserver2:/home/oracle/ [DB21 (CDB$ROOT)] |
The goal is to duplicate the standby database DB21_SITE2 to DB21CLNE to a remote server. I assume that all network files are already configured. Password file, spfile are also already configured.
From the source server
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
oracle@oraadserver2:/home/oracle/ [DB21 (CDB$ROOT)] tnsping db21_site2TNS Ping Utility for Linux: Version 21.0.0.0.0 - Production on 06-APR-2022 13:29:59Copyright (c) 1997, 2020, Oracle. All rights reserved.Used parameter files:/u01/app/oracle/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oraadserver2)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB21_SITE2_DGMGRL)))OK (0 msec)oracle@oraadserver2:/home/oracle/ [DB21 (CDB$ROOT)] tnsping db21clneTNS Ping Utility for Linux: Version 21.0.0.0.0 - Production on 06-APR-2022 13:30:05Copyright (c) 1997, 2020, Oracle. All rights reserved.Used parameter files:/u01/app/oracle/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oraadserver4)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB21CLNE)))OK (0 msec)oracle@oraadserver2:/home/oracle/ [DB21 (CDB$ROOT)] |
From the target server
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
oracle@oraadserver4:/home/oracle/ [DB21CLNE (CDB$ROOT)] tnsping db21_site2TNS Ping Utility for Linux: Version 21.0.0.0.0 - Production on 06-APR-2022 13:33:12Copyright (c) 1997, 2020, Oracle. All rights reserved.Used parameter files:/u01/app/oracle/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oraadserver2)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB21_SITE2_DGMGRL)))OK (0 msec)oracle@oraadserver4:/home/oracle/ [DB21CLNE (CDB$ROOT)] tnsping db21clneTNS Ping Utility for Linux: Version 21.0.0.0.0 - Production on 06-APR-2022 13:33:16Copyright (c) 1997, 2020, Oracle. All rights reserved.Used parameter files:/u01/app/oracle/network/admin/sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oraadserver4)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB21CLNE)))OK (10 msec)oracle@oraadserver4:/home/oracle/ [DB21CLNE (CDB$ROOT)] |
I then create a simple duplicate rman script
|
1
2
3
4
5
6
|
oracle@oraadserver4: [DB21CLNE (CDB$ROOT)] cat duplicate_from_standby.rcvconnect target sys/******@db21_site2connect auxiliary sys/****@db21clnerun {duplicate target database to DB21CLNE from active database nofilenamecheck;} |
After starting the target database DB21CLNE in NOMOUNT state, I run the script to create DB21CLNE
|
1
|
oracle@oraadserver4: [DB21CLNE (CDB$ROOT)] nohup rman cmdfile=duplicate_from_standby.rcv log=duplicate_standby_`date +"%Y-%m-%d_%H%M%S"`.log & |
A few minutes later the duplicate went fine (output truncated)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
Recovery Manager: Release 21.0.0.0.0 - Production on Wed Apr 6 14:51:56 2022Version 21.1.0.0.0Copyright (c) 1982, 2020, Oracle and/or its affiliates. All rights reserved.RMAN> connect target *2> connect auxiliary *3> run {4> duplicate target database to DB21CLNE from active database nofilenamecheck;5> }6> connected to target database: DB21 (DBID=1137202071)connected to auxiliary database: DB21CLNE (not mounted)Starting Duplicate Db at 06-APR-2022 14:51:57using target database control file instead of recovery catalogallocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=25 device type=DISKcurrent log archived at primary databasecurrent log archived at primary databaseduplicating Online logs to Oracle Managed File (OMF) locationduplicating Datafiles to Oracle Managed File (OMF) locationcontents of Memory Script:{ sql clone "alter system set control_files = ''/u01/app/oracle/oradata/DB21CLNE/controlfile/o1_mf_k4v3hqr1_.ctl'', ''/u01/app/oracle/fast_recovery_area/DB21CLNE/controlfile/o1_mf_k4v3hqr7_.ctl'' comment= ''Set by RMAN'' scope=spfile"; sql clone "alter system set db_name = ''DB21'' comment= ''Modified by RMAN duplicate'' scope=spfile"; sql clone "alter system set db_unique_name = ''DB21CLNE'' comment= ''Modified by RMAN duplicate'' scope=spfile"; shutdown clone immediate; startup clone force nomount restore clone from service 'db21_site2' primary controlfile; alter clone database mount;}executing Memory Scriptsql statement: alter system set control_files = ''/u01/app/oracle/oradata/DB21CLNE/controlfile/o1_mf_k4v3hqr1_.ctl'', ''/u01/app/oracle/fast_recovery_area/DB21CLNE/controlfile/o1_mf_k4v3hqr7_.ctl'' comment= ''Set by RMAN'' scope=spfilesql statement: alter system set db_name = ''DB21'' comment= ''Modified by RMAN duplicate'' scope=spfilesql statement: alter system set db_unique_name = ''DB21CLNE'' comment= ''Modified by RMAN duplicate'' scope=spfileOracle instance shut downOracle instance startedTotal System Global Area 1577057624 bytesFixed Size 9686360 bytesVariable Size 385875968 bytesDatabase Buffers 889192448 bytesRedo Buffers 292302848 bytesStarting restore at 06-APR-2022 14:56:46allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=333 device type=DISKchannel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service db21_site2channel ORA_AUX_DISK_1: restoring control filechannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01output file name=/u01/app/oracle/oradata/DB21CLNE/controlfile/o1_mf_k4v3hqr1_.ctloutput file name=/u01/app/oracle/fast_recovery_area/DB21CLNE/controlfile/o1_mf_k4v3hqr7_.ctlFinished restore at 06-APR-2022 14:56:49database mounted……Executing: alter database force loggingcontents of Memory Script:{ Alter clone database open resetlogs;}executing Memory Scriptdatabase openedExecuting: alter database flashback oncontents of Memory Script:{ sql clone "alter pluggable database all open";}executing Memory Scriptsql statement: alter pluggable database all openFinished Duplicate Db at 06-APR-2022 15:02:41Recovery Manager complete. |
And DB21CLNE is created and opened in READ WRITE and ready to be used
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
oracle@oraadserver4:/u01/app/oracle/admin/DB21CLNE/create/ [DB21CLNE (CDB$ROOT)] DB21CLNE********* dbi services Ltd. *********STATUS : OPENDB_UNIQUE_NAME : DB21CLNEOPEN_MODE : READ WRITELOG_MODE : ARCHIVELOGDATABASE_ROLE : PRIMARYFLASHBACK_ON : YESFORCE_LOGGING : YESVERSION : 21.0.0.0.0CDB Enabled : YESList PDB(s) READ ONLY : PDB$SEEDList PDB(s) READ WRITE : PDB1, PDB2, PDB3************************************* |
Standby in MOUNT Mode
I decide to do the same tests , but with the source standby database in MOUNT state
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
oracle@oraadserver2:/home/oracle/ [DB21 (CDB$ROOT)] DB21********* dbi services Ltd. *********STATUS : MOUNTEDDB_UNIQUE_NAME : DB21_SITE2OPEN_MODE : MOUNTEDLOG_MODE : ARCHIVELOGDATABASE_ROLE : PHYSICAL STANDBYFLASHBACK_ON : YESFORCE_LOGGING : YESCDB Enabled : YESList PDB(s) MOUNTED : PDB$SEED, PDB1, PDB2, PDB3*************************************oracle@oraadserver2:/home/oracle/ [DB21 (CDB$ROOT)] |
In this case the starts fine, but the recovery process was asking for a archived and was not able to finish. There was no error returned, but the duplicate is asking, asking the missing archived
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
RMAN> connect target *2> connect auxiliary *3> run {4> duplicate target database to DB21CLNE from active database nofilenamecheck;5> }6>connected to target database: DB21 (DBID=1137202071, not open)connected to auxiliary database: DB21CLNE (not mounted)Starting Duplicate Db at 06-APR-2022 14:12:28using target database control file instead of recovery catalogallocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=23 device type=DISKcurrent log archived at primary databasecurrent log archived at primary databaseduplicating Online logs to Oracle Managed File (OMF) locationduplicating Datafiles to Oracle Managed File (OMF) locationcontents of Memory Script:{ sql clone "alter system set control_files = ''/u01/app/oracle/oradata/DB21CLNE/controlfile/o1_mf_k4v15kz7_.ctl'', ''/u01/app/oracle/fast_recovery_area/DB21CLNE/controlfile/o1_mf_k4v15l04_.ctl'' comment= ''Set by RMAN'' scope=spfile"; sql clone "alter system set db_name = ''DB21'' comment= ''Modified by RMAN duplicate'' scope=spfile"; sql clone "alter system set db_unique_name = ''DB21CLNE'' comment= ''Modified by RMAN duplicate'' scope=spfile"; shutdown clone immediate; startup clone force nomount restore clone from service 'db21_site2' primary controlfile; alter clone database mount;}executing Memory Script……starting media recoveryarchived log file name=/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06/o1_mf_1_35_k4v156k8_.arc thread=1 sequence=35archived log file name=/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06/o1_mf_1_35_k4v156k8_.arc thread=1 sequence=35archived log file name=/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06/o1_mf_1_35_k4v156k8_.arc thread=1 sequence=35......archived log file name=/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06/o1_mf_1_35_k4v156k8_.arc thread=1 sequence=35archived log file name=/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06/o1_mf_1_35_k4v156k8_.arc thread=1 sequence=35archived log file name=/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06/o1_mf_1_35_k4v156k8_.arc thread=1 sequence=35archived log file name=/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06/o1_mf_1_35_k4v156k8_.arc thread=1 sequence=35…. |
As a workaround from the standby server I manually copy the requested archive to the remote source server
|
1
|
oracle@oraadserver2 ] scp o1_mf_1_35_k4v156k8_.arc oraadserver4:/u01/app/oracle/fast_recovery_area/DB21_SITE2/archivelog/2022_04_06 |
And the duplicate process went fine
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
……contents of Memory Script:{ Alter clone database open resetlogs;}executing Memory Scriptdatabase openedExecuting: alter database flashback oncontents of Memory Script:{ sql clone "alter pluggable database all open";}executing Memory Scriptsql statement: alter pluggable database all openFinished Duplicate Db at 06-APR-2022 14:34:39Recovery Manager complete. |
So we can see that duplicate can be done from a standby database like a primary one. Just when the standby is mounted, you may have to manually copy some archived.
Note that I repeat the duplicate a second time with the database mount and I had the same behavior, I had to manually copy a missing archived log.
Alex
01.11.2023I get the error with the absent archived log file even when the source standby database is opened (in read only mode of course)