您的位置:首页 > 其它

Creating A Physical Standby With RMAN Active Duplicate In 11.2.0.3

2017-10-28 00:00 751 查看

CreatingAPhysicalStandbyWithRMANActiveDuplicateIn11.2.0.3

byReneAntunez

May28,2013

Postedin:TechnicalTrack

Tags:Oracle

OtherDBAshavewrittenaboutthistopic,butIwantedittobeavailableonPythian’sblog.WhenIsearchedforhowthiswasdone,othersiteswereeithernotveryclearonthestepstheydid,assumedthatyoualreadyknewwhatyouaredoing,orwentthroughthestepstooquickly.
Ifthisisyourfirsttimebuildingastandby,thereissometerminologyyouneedtoknowbeforegoingintoanyofthestepsincreatingyourphysicalstandby.Itwillhelpyoutobetterunderstandyourdataguardenvironmentandwhatisbeingdone,insteadofsimplycopyinganumberofsteps.ThesearejustthedefinitionsinOracle’sdocumentation,buttheywillhelpyouavoidthearduoussearch.

LOG_ARCHIVE_DEST_n.-Itcontrolsdifferentaspectsofhowredotransportservicestransferredodatafromprimarydatabasedestinationtoastandby.
ThisparameterhasseveralattributesthatareneededtosetupyourDataguardenvironment,Iwillonlymentionthecriticalones:

ASYNC.-Thisisthedefault,theredodatageneratedbyatransactionneednothavebeenreceivedatadestinationwhichhasthisattributebeforethattransactioncancommit.
or

SYNC.-Theredodatageneratedbyatransactionmusthavebeenreceivedbyeveryenableddestinationthathasthisattributebeforethattransactioncancommit.

AFFIRMandNOAFFIRM.-Controlwhetheraredotransportdestinationacknowledgesreceivedredodatabeforeorafterwritingittothestandbyredolog.ThedefaultisNOAFFIRM.

DB_UNIQUE_NAME.-Specifiesauniquenameforthedatabaseatthisdestination.Youmustspecifyaname;thereisnodefaultvalue.

VALID_FOR.-Identifieswhenredotransportservicescantransmitredodatatodestinationsbasedonthefollowingfactors:

redo_log_type.-whetheronlineredologfiles,standbyredologfiles,orbotharecurrentlybeingarchivedonthedatabaseatthisdestination

database_role.-whetherthedatabaseiscurrentlyrunningintheprimaryorthestandbyrole

FAL_SERVER.-SpecifiestheFAL(fetcharchivelog)serverforastandbydatabase.ThevalueisanOracleNetservicename.

FAL_CLIENT.-SpecifiestheFAL(fetcharchivelog)clientnamethatisusedbytheFALservice,configuredthroughtheFAL_SERVERinitializationparameter,torefertotheFALclient.
ThevalueisanOracleNetservicename,whichisassumedtobeconfiguredproperlyontheFALserversystemtopointtotheFALclient(standbydatabase).

LOG_ARCHIVE_CONFIG.-Enablesordisablesthesendingofredologstoremotedestinationsandthereceiptofremoteredologs.
Thisparamete
7fe0
rhasseveralattributes,themostimportantforthisexerciseisbelow:

DG_CONFIG.-Specifiesalistofupto30uniquedatabasenames(definedwiththeDB_UNIQUE_NAMEinitializationparameter)forallofthedatabasesintheDataGuardconfiguration.

Nowthatwehavethedefinitionsoutoftheway(whichyoucanfindatOracle11.2.Documentation),wewillcontinuewiththesetupofourPhysicalStandby.
Forthisexercise,Ihavethefollowing:

Primary:testgg1Server:dlabvm13

Standby:testgg2Server:dlabvm14

ThefirstthingthatweneedtodoisfindwheretheRedoLogsandDatafilesresideinthePrimaryandwherewilltheyresideintheStandbysothatyoucansetyourparametersLOG_FILE_NAME_CONVERTandDB_FILE_NAME_CONVERTproperly.MakesurethatthesedirectorieshavethenecessaryspacetoholdthePrimarydatabase.Ifyoudon’thavethisspace,thendonotcontinue.
Next,assurethatyouareinarchivelogmode,andthatforceloggingisenabledinyourprimary.
Ifyourdatabaseisnotinarchivelogmode,dothefollowing:
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
SQL>shutdownimmediate
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.

SQL>startupmount
ORACLEinstancestarted.

TotalSystemGlobalArea534462464bytes
FixedSize2230072bytes
VariableSize163580104bytes
DatabaseBuffers364904448bytes
RedoBuffers3747840bytes
Databasemounted.

SQL>alterdatabasearchivelog;

Databasealtered.

SQL>alterdatabaseopen;

Databasealtered.

SQL>alterdatabaseforcelogging;

Databasealtered.

SQL>selectlog_mode,force_loggingfromv$database;

LOG_MODEFOR
---------------
ARCHIVELOGYES
Nowthatwearerunninginarchivelogmodeandforceloggingissetfortheprimary,makesurethattheListener/Tnsentriesaresetcorrectlyandthatyoucantnspingthembothfromtheprimary/standby.
Formoredetailsonhowtosetthemup,gotoKamran’sblogentry(Step2).
Theresultinboththeprimaryandstandbyserversshouldbesimilartobelow:
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@dlabvm13.dlab.pythian.com[testgg1]/home/oracle/bin
oracle$tnspingtestgg1

TNSPingUtilityforLinux:Version11.2.0.3.0-Productionon14-MAY-201309:44:34
Copyright(c)1997,2011,Oracle.Allrightsreserved.
Usedparameterfiles:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora

UsedTNSNAMESadaptertoresolvethealias

Attemptingtocontact(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dlabvm13.dlab.pythian.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=testgg1)))

OK(0msec)

oracle@dlabvm13.dlab.pythian.com[testgg1]/home/oracle/bin
oracle$tnspingtestgg2
TNSPingUtilityforLinux:Version11.2.0.3.0-Productionon14-MAY-201309:44:40
Copyright(c)1997,2011,Oracle.Allrightsreserved.

Usedparameterfiles:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora

UsedTNSNAMESadaptertoresolvethealias

Attemptingtocontact(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dlabvm14.dlab.pythian.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=testgg2)))

OK(10msec)
Then,createandreplicatethepasswordfilefromtheprimary$ORACLE_HOME/dbs,andrenameittothestandbydatabasename.ThepasswordfilenamemustmatchtheORACLE_SIDusedatthestandbysite,nottheDB_NAME.
1
2
3
4
5
6
7
oracle@dlabvm13.dlab.pythian.com[testgg1]/u01/app/oracle/product/11.2.0/dbhome_1/dbs
oracle$orapwdfile=orapwtestgg1password=testentries=5

oracle@dlabvm13.dlab.pythian.com[testgg1]/u01/app/oracle/product/11.2.0/dbhome_1/dbs
oracle$scporapwtestgg1dlabvm14:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwtestgg2

orapwtestgg1100%20482.0KB/s00:00
Nowthatthepasswordfilehasbeencreated,youcansetuptheinitfileforthePrimaryDatabase.Asyoucanseeattheend,it’stheparametersweexplainedatthebeginningofthisentry.
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
SQL>!catdg.ora
*.audit_file_dest='/u01/app/oracle/oradata/dump/testgg1/adump'
*.audit_trail='db'
*.compatible='11.2.0'
*.control_files='/u01/app/oracle/oradata/testgg1/control/control01.ctl','/u01/app/oracle/oradata/testgg1/control/control02.ctl'
*.db_block_size=8192
*.db_cache_size=128M
*.db_domain=''
*.db_name='testgg1'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=2G
*.db_unique_name='testgg1'
*.diagnostic_dest='/u01/app/oracle/oradata/dump/testgg1'
*.log_archive_dest_1='location=use_db_recovery_file_destvalid_for=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=testgg1'
*.log_archive_dest_2='SERVICE=testgg2ASYNCvalid_for=(ONLINE_LOGFILES,PRIMARY_ROLE)DB_UNIQUE_NAME=testgg2'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.open_cursors=300
*.pga_aggregate_target=128M
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=512M
testgg11.UNDO_TABLESPACE='UNDOTBS1'
FAL_SERVER=testgg2;
FAL_CLIENT=testgg1;
DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/','/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/'
LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/testgg2/TESTGG2/onlinelog/','/u01/app/oracle/oradata/testgg1/TESTGG1/onlinelog/'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(testgg1,testgg2)'
OneofthecoolestthingsaboutthismethodisthatalmostalloftheworkwewilldowillbeinthePrimarydatabaseserver.TheonlythingyouhavetodointheStandbyServeriscreatethelocationsofmydiagnosticfiles/redo/datafiles/controlfiles,verifytheconnectivitybetweenthePrimaryandtheStandbyandjuststarttheStandbyInstance,whichisournextstep.
ThenextstepistosettheORACLE_SID,ORACLE_HOME,andORACLE_BASEfortheStandbyInstanceandopenitwithminimaloptions:
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
oracle@dlabvm14.dlab.pythian.com[testgg2]/home/oracle/bin
oracle$exportORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"

oracle@dlabvm14.dlab.pythian.com[testgg2]/home/oracle/bin
oracle$exportORACLE_BASE=/u01/app/oracle

oracle@dlabvm14.dlab.pythian.com[testgg2]/home/oracle/bin
oracle$exportORACLE_SID=testgg2

oracle@dlabvm14.dlab.pythian.com[testgg2]/home/oracle/bin
oracle$catdg.ora

DB_NAME=testgg1
DB_UNIQUE_NAME=testgg2
DB_BLOCK_SIZE=8192

oracle@dlabvm14.dlab.pythian.com[testgg2]/home/oracle/bin
oracle$sqlplus
SQL*Plus:Release11.2.0.3.0ProductiononTueMay1409:53:302013
Copyright(c)1982,2011,Oracle.Allrightsreserved.
Enteruser-name:/assysdba

Connectedtoanidleinstance.

SQL>startupnomountpfile='/home/oracle/bin/dg.ora';
ORACLEinstancestarted.
TotalSystemGlobalArea238034944bytes
FixedSize2227136bytes
VariableSize180356160bytes
DatabaseBuffers50331648bytes
RedoBuffers5120000bytes

SQL>exit

DisconnectedfromOracleDatabase11gEnterpriseEditionRelease11.2.0.3.0-64bitProduction

WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions
Nowlet’sgetbacktothePrimarydatabaseserver,wherethenextthingtodoisaddthestandbylogs.Inthiscase,IcreatedtwowiththesamesizeastheOnlineRedoLogsthatIhaveinmyPrimary.
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
SQL>selectinstance_name,host_namefromv$instance;

INSTANCE_NAMEHOST_NAME
--------------------------------------------------------------------------------
testgg1dlabvm13.dlab.pythian.com

SQL>selectnamefromv$database;

NAME
---------
TESTGG1

SQL>selectGROUP#,THREAD#,MEMBERS,BYTESFROMV$LOG;

GROUP#THREAD#MEMBERSBYTES
----------------------------------------
111104857600
211104857600

SQL>ALTERDATABASEADDSTANDBYLOGFILESIZE104857600;

Databasealtered.

SQL>ALTERDATABASEADDSTANDBYLOGFILESIZE104857600;

Databasealtered.

SQL>SELECTGROUP#,BYTESFROMV$STANDBY_LOG;

GROUP#BYTES
--------------------
3104857600
4104857600
OncewehavecreatedtheStandbyLogsinmyPrimaryDatabase,wewillcreatethefollowingRMANruncommandsandthechangestothestandby’sspfileinthisRMANblock.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
oracle@dlabvm13.dlab.pythian.com[testgg1]/home/oracle/bin
oracle$catduplicate.rmn

run{
allocatechannelprmy1typedisk;
allocatechannelprmy2typedisk;
allocatechannelprmy3typedisk;
allocatechannelprmy4typedisk;
allocateauxiliarychannelstbytypedisk;
duplicatetargetdatabaseforstandbyfromactivedatabase
spfile
parameter_value_convert'testgg1','testgg2'
setdb_unique_name='testgg2'
setdb_file_name_convert='/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/','/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/'
setlog_file_name_convert='/u01/app/oracle/oradata/testgg1/TESTGG1/onlinelog/','/u01/app/oracle/oradata/testgg2/TESTGG2/onlinelog/'
setcontrol_files='/u01/app/oracle/oradata/testgg2/control/control01.ctl','/u01/app/oracle/oradata/testgg2/control/control02.ctl'
setlog_archive_max_processes='10'
setfal_client='testgg2'
setfal_server='testgg1'
setstandby_file_management='AUTO'
setlog_archive_config='dg_config=(testgg1,testgg2)'
setlog_archive_dest_2='service=testgg1ASYNCvalid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)db_unique_name=testgg1'
;
}
NowthatthetheRMANcommandfilehasbeencreated,youjustneedtorunthiscommandinthetargetdatabase,whichisthePrimaryDatabase,connectingtotheStandbyastheauxiliary.
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
oracle@dlabvm13.dlab.pythian.com[testgg1]/home/oracle/bin
oracle$rmantargetsys/test@testgg1auxiliarysys/test@testgg2

RecoveryManager:Release11.2.0.3.0-ProductiononThuMay1608:42:462013
Copyright(c)1982,2011,Oracleand/oritsaffiliates.Allrightsreserved.

connectedtotargetdatabase:TESTGG1(DBID=839852638)
connectedtoauxiliarydatabase:TESTGG1(notmounted)

RMAN>@duplicate.rmn

RMAN>
RMAN>run{
2>allocatechannelprmy1typedisk;
3>allocatechannelprmy2typedisk;
4>allocatechannelprmy3typedisk;
5>allocatechannelprmy4typedisk;
6>allocateauxiliarychannelstbytypedisk;
7>duplicatetargetdatabaseforstandbyfromactivedatabase
8>spfile
9>parameter_value_convert'testgg1','testgg2'
10>setdb_unique_name='testgg2'
11>setdb_file_name_convert='/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/','/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/'
12>setlog_file_name_convert='/u01/app/oracle/oradata/testgg1/TESTGG1/onlinelog/','/u01/app/oracle/oradata/testgg2/TESTGG2/onlinelog/'
13>setcontrol_files='/u01/app/oracle/oradata/testgg2/control/control01.ctl','/u01/app/oracle/oradata/testgg2/control/control02.ctl'
14>setlog_archive_max_processes='10'
15>setfal_client='testgg2'
16>setfal_server='testgg1'
17>setstandby_file_management='AUTO'
18>setlog_archive_config='dg_config=(testgg1,testgg2)'
19>setlog_archive_dest_2='service=testgg1ASYNCvalid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)db_unique_name=testgg1'
20>;
21>}
usingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:prmy1
channelprmy1:SID=32devicetype=DISK

allocatedchannel:prmy2
channelprmy2:SID=33devicetype=DISK

allocatedchannel:prmy3
channelprmy3:SID=34devicetype=DISK

allocatedchannel:prmy4
channelprmy4:SID=35devicetype=DISK

allocatedchannel:stby
channelstby:SID=19devicetype=DISK

StartingDuplicateDbat16-MAY-13

contentsofMemoryScript:
{
backupascopyreuse
targetfile'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwtestgg1'auxiliaryformat
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwtestgg2'targetfile
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletestgg1.ora'auxiliaryformat
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletestgg2.ora';
sqlclone"altersystemsetspfile=''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletestgg2.ora''";
}
executingMemoryScript

Startingbackupat16-MAY-13
Finishedbackupat16-MAY-13

sqlstatement:altersystemsetspfile=''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfiletestgg2.ora''

contentsofMemoryScript:
{
sqlclone"altersystemsetaudit_file_dest=
''/u01/app/oracle/oradata/dump/testgg2/adump''comment=
''''scope=spfile";
sqlclone"altersystemsetdiagnostic_dest=
''/u01/app/oracle/oradata/dump/testgg2''comment=
''''scope=spfile";
sqlclone"altersystemsetlog_archive_dest_1=
''location=use_db_recovery_file_destvalid_for=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=testgg2''comment=
''''scope=spfile";
sqlclone"altersystemsetdb_unique_name=
''testgg2''comment=
''''scope=spfile";
sqlclone"altersystemsetdb_file_name_convert=
''/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/'',''/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/''comment=
''''scope=spfile";
sqlclone"altersystemsetlog_file_name_convert=
''/u01/app/oracle/oradata/testgg1/TESTGG1/onlinelog/'',''/u01/app/oracle/oradata/testgg2/TESTGG2/onlinelog/''comment=
''''scope=spfile";
sqlclone"altersystemsetcontrol_files=
''/u01/app/oracle/oradata/testgg2/control/control01.ctl'',''/u01/app/oracle/oradata/testgg2/control/control02.ctl''comment=
''''scope=spfile";
sqlclone"altersystemsetlog_archive_max_processes=
10comment=
''''scope=spfile";
sqlclone"altersystemsetfal_client=
''testgg2''comment=
''''scope=spfile";
sqlclone"altersystemsetfal_server=
''testgg1''comment=
''''scope=spfile";
sqlclone"altersystemsetstandby_file_management=
''AUTO''comment=
''''scope=spfile";
sqlclone"altersystemsetlog_archive_config=
''dg_config=(testgg1,testgg2)''comment=
''''scope=spfile";
sqlclone"altersystemsetlog_archive_dest_2=
''service=testgg1ASYNCvalid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)db_unique_name=testgg1''comment=
''''scope=spfile";
shutdowncloneimmediate;
startupclonenomount;
}
executingMemoryScript

sqlstatement:altersystemsetaudit_file_dest=''/u01/app/oracle/oradata/dump/testgg2/adump''comment=''''scope=spfile

sqlstatement:altersystemsetdiagnostic_dest=''/u01/app/oracle/oradata/dump/testgg2''comment=''''scope=spfile

sqlstatement:altersystemsetlog_archive_dest_1=''location=use_db_recovery_file_destvalid_for=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=testgg2''comment=''''scope=spfile

sqlstatement:altersystemsetdb_unique_name=''testgg2''comment=''''scope=spfile

sqlstatement:altersystemsetdb_file_name_convert=''/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/'',''/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/''comment=''''scope=spfile

sqlstatement:altersystemsetlog_file_name_convert=''/u01/app/oracle/oradata/testgg1/TESTGG1/onlinelog/'',''/u01/app/oracle/oradata/testgg2/TESTGG2/onlinelog/''comment=''''scope=spfile

sqlstatement:altersystemsetcontrol_files=''/u01/app/oracle/oradata/testgg2/control/control01.ctl'',''/u01/app/oracle/oradata/testgg2/control/control02.ctl''comment=''''scope=spfile

sqlstatement:altersystemsetlog_archive_max_processes=10comment=''''scope=spfile

sqlstatement:altersystemsetfal_client=''testgg2''comment=''''scope=spfile

sqlstatement:altersystemsetfal_server=''testgg1''comment=''''scope=spfile

sqlstatement:altersystemsetstandby_file_management=''AUTO''comment=''''scope=spfile

sqlstatement:altersystemsetlog_archive_config=''dg_config=(testgg1,testgg2)''comment=''''scope=spfile

sqlstatement:altersystemsetlog_archive_dest_2=''service=testgg1ASYNCvalid_for=(ONLINE_LOGFILE,PRIMARY_ROLE)db_unique_name=testgg1''comment=''''scope=spfile

Oracleinstanceshutdown

connectedtoauxiliarydatabase(notstarted)
Oracleinstancestarted

TotalSystemGlobalArea534462464bytes

FixedSize2230072bytes
VariableSize163580104bytes
DatabaseBuffers364904448bytes
RedoBuffers3747840bytes
allocatedchannel:stby
channelstby:SID=18devicetype=DISK

contentsofMemoryScript:
{
backupascopycurrentcontrolfileforstandbyauxiliaryformat'/u01/app/oracle/oradata/testgg2/control/control01.ctl';
restoreclonecontrolfileto'/u01/app/oracle/oradata/testgg2/control/control02.ctl'from
'/u01/app/oracle/oradata/testgg2/control/control01.ctl';
}
executingMemoryScript

Startingbackupat16-MAY-13
channelprmy1:startingdatafilecopy
copyingstandbycontrolfile
outputfilename=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_testgg1.ftag=TAG20130516T084319RECID=7STAMP=815561001
channelprmy1:datafilecopycomplete,elapsedtime:00:00:07
Finishedbackupat16-MAY-13

Startingrestoreat16-MAY-13

channelstby:copiedcontrolfilecopy
Finishedrestoreat16-MAY-13

contentsofMemoryScript:
{
sqlclone'alterdatabasemountstandbydatabase';
}
executingMemoryScript

sqlstatement:alterdatabasemountstandbydatabase

contentsofMemoryScript:
{
setnewnamefortempfile1to
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_temp_8qbok7fk_.tmp";
switchclonetempfileall;
setnewnamefordatafile1to
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_system_8ocl7bho_.dbf";
setnewnamefordatafile2to
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sysaux_8ocl7k6n_.dbf";
setnewnamefordatafile3to
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf";
setnewnamefordatafile4to
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_users_8qbolh3g_.dbf";
backupascopyreuse
datafile1auxiliaryformat
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_system_8ocl7bho_.dbf"datafile
2auxiliaryformat
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sysaux_8ocl7k6n_.dbf"datafile
3auxiliaryformat
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf"datafile
4auxiliaryformat
"/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_users_8qbolh3g_.dbf";
sql'altersystemarchivelogcurrent';
}
executingMemoryScript

executingcommand:SETNEWNAME

renamedtempfile1to/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_temp_8qbok7fk_.tmpincontrolfile

executingcommand:SETNEWNAME

executingcommand:SETNEWNAME

executingcommand:SETNEWNAME

executingcommand:SETNEWNAME

Startingbackupat16-MAY-13
channelprmy1:startingdatafilecopy
inputdatafilefilenumber=00001name=/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/o1_mf_system_8ocl7bho_.dbf
channelprmy2:startingdatafilecopy
inputdatafilefilenumber=00002name=/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/o1_mf_sysaux_8ocl7k6n_.dbf
channelprmy3:startingdatafilecopy
inputdatafilefilenumber=00003name=/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf
channelprmy4:startingdatafilecopy
inputdatafilefilenumber=00004name=/u01/app/oracle/oradata/testgg1/TESTGG1/datafile/o1_mf_users_8qbolh3g_.dbf
outputfilename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sys_undo_8ocl7q6c_.dbftag=TAG20130516T084335
channelprmy3:datafilecopycomplete,elapsedtime:00:00:45
outputfilename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_users_8qbolh3g_.dbftag=TAG20130516T084335
channelprmy4:datafilecopycomplete,elapsedtime:00:00:55
outputfilename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_system_8ocl7bho_.dbftag=TAG20130516T084335
channelprmy1:datafilecopycomplete,elapsedtime:00:01:05
outputfilename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sysaux_8ocl7k6n_.dbftag=TAG20130516T084335
channelprmy2:datafilecopycomplete,elapsedtime:00:01:05
Finishedbackupat16-MAY-13

sqlstatement:altersystemarchivelogcurrent

contentsofMemoryScript:
{
switchclonedatafileall;
}
executingMemoryScript

datafile1switchedtodatafilecopy
inputdatafilecopyRECID=7STAMP=815561103filename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_system_8ocl7bho_.dbf
datafile2switchedtodatafilecopy
inputdatafilecopyRECID=8STAMP=815561104filename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sysaux_8ocl7k6n_.dbf
datafile3switchedtodatafilecopy
inputdatafilecopyRECID=9STAMP=815561104filename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_sys_undo_8ocl7q6c_.dbf
datafile4switchedtodatafilecopy
inputdatafilecopyRECID=10STAMP=815561104filename=/u01/app/oracle/oradata/testgg2/TESTGG2/datafile/o1_mf_users_8qbolh3g_.dbf
FinishedDuplicateDbat16-MAY-13
releasedchannel:prmy1
releasedchannel:prmy2
releasedchannel:prmy3
releasedchannel:prmy4
releasedchannel:stby

RMAN>**end-of-file**

RMAN>exit
Asyoucansee,thatwasaseasyaspie.NowwecanjuststarttherecoveryprocessintheStandbyDatabase.Inthiscase,IusedActiveDataguardsothatIcouldshowyouthatitisactuallyworking,butjustbeawarethatthisisaLicensableOption.
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
SQL>alterdatabaseopen;

Databasealtered.

SQL>alterdatabaserecovermanagedstandbydatabasedisconnect;

Databasealtered.

SQL>selectprotection_mode,protection_level,database_role,namefromv$database;

PROTECT
3ff0
ION_MODEPROTECTION_LEVELDATABASE_ROLENAME
-----------------------------------------------------------------
MAXIMUMPERFORMANCEMAXIMUMPERFORMANCEPHYSICALSTANDBYTESTGG1

SQL>selectinstance_name,host_namefromv$instance;

INSTANCE_NAMEHOST_NAME
--------------------------------------------------------------------------------
testgg2dlabvm14.dlab.pythian.com

SQL>select*fromsender.test;
select*fromsender.test
*
ERRORatline1:
ORA-00942:tableorviewdoesnotexist
Now,Igobacktotheprimaryandcreateatablecalledtestintheschemasender.Asyoucanseeabove,thistabledoesn’texistintheStandbydatabase.
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
SQL>selectinstance_name,host_namefromv$instance;

INSTANCE_NAMEHOST_NAME
--------------------------------------------------------------------------------
testgg1dlabvm13.dlab.pythian.com

SQL>selectprotection_mode,protection_level,database_role,namefromv$database;

PROTECTION_MODEPROTECTION_LEVELDATABASE_ROLENAME
-----------------------------------------------------------------
MAXIMUMPERFORMANCEMAXIMUMPERFORMANCEPRIMARYTESTGG1

SQL>createtablesender.test(idnumber);

Tablecreated.

SQL>insertintosender.testvalues(1);

1rowcreated.

SQL>commit;

Commitcomplete.

SQL>altersystemswitchlogfile;

Systemaltered.
IgobacktotheStandby,andwecanseethatwehavethetablethatwejustcreated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SQL>selectprotection_mode,protection_level,database_role,namefromv$database;

PROTECTION_MODEPROTECTION_LEVELDATABASE_ROLENAME
-----------------------------------------------------------------
MAXIMUMPERFORMANCEMAXIMUMPERFORMANCEPHYSICALSTANDBYTESTGG1

SQL>selectinstance_name,host_namefromv$instance;

INSTANCE_NAMEHOST_NAME
--------------------------------------------------------------------------------
testgg2dlabvm14.dlab.pythian.com

SQL>select*fromsender.test;

ID
----------
1
Therearevariouswaystoseeifthisisworkingornot.Youcanuseitinthefollowingquerytoseewhatwasthelastarchivereceived/appliedintheStandbyDatabase.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SQL>SELECT'LastApplied:'Logs,
TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS')TIME,thread#,sequence#
FROMv$archived_log
WHEREsequence#=
(SELECTMAX(sequence#)FROMv$archived_logWHEREapplied='YES'
)
UNION
SELECT'LastReceived:'Logs,
TO_CHAR(next_time,'DD-MON-YY:HH24:MI:SS')TIME,thread#,sequence#
FROMv$archived_log
WHEREsequence#=
(SELECTMAX(sequence#)FROMv$archived_log);

LOGSTIMETHREAD#SEQUENCE#
------------------------------------------------------
LastApplied:16-MAY-13:11:42:52165
LastReceived:16-MAY-13:11:42:52165
WhileinthePrimaryDatabase,youcancheckwhatisthecurrentsequenceandwhatisthependingsequencetobeapplied.
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
SQL>SELECT
(SELECTnameFROMV$DATABASE
)name,
(SELECTMAX(sequence#)FROMv$archived_logWHEREdest_id=1
)Current_primary_seq,
(SELECTMAX(sequence#)
FROMv$archived_log
WHERETRUNC(next_time)>SYSDATE-1
ANDdest_id=2
)max_stby,
(SELECTNVL(
(SELECTMAX(sequence#)-MIN(sequence#)
FROMv$archived_log
WHERETRUNC(next_time)>SYSDATE-1
ANDdest_id=2
ANDapplied='NO'
),0)
FROMDUAL
)"Tobeapplied",
(
(SELECTMAX(sequence#)FROMv$archived_logWHEREdest_id=1
)-
(SELECTMAX(sequence#)FROMv$archived_logWHEREdest_id=2
))"TobeShipped"
FROMDUAL;

NAMECURRENT_PRIMARY_SEQMAX_STBYTobeappliedTobeShipped
----------------------------------------------------------------
TESTGG1656500
IhopethislittleguidehelpsyououtwhenyouaretryingtobuildyourPhysicalStandbyfromanActiveDuplicate.Asalways,testanythingthatIhavesaidormentionedbeforetryingitinaproductionenvironment.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐