Huaiyao's Notes

RMAN restore archivelog

Need manually backup and restore archivelog in standby database to sync other physical standby database.

Backup

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
allocate channel d5 type disk;
allocate channel d6 type disk;
allocate channel d7 type disk;
allocate channel d8 type disk;
backup archivelog FROM SEQUENCE 96363 UNTIL SEQUENCE 96488 thread 1 format '/opt/oracle/admin/rjin2/arch_%d_%T_%U';
release channel d1;
release channel d2;
release channel d3;
release channel d4;
release channel d5;
release channel d6;
release channel d7;
release channel d8;
}

Transfer backupset

1
:/opt/oracle/admin> scp -r oracle@rjin01dbs011.stubcorp.com:/opt/oracle/admin/rjin2 .

Try to restore

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
RJINUXR:/opt/oracle/admin>rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jul 20 23:10:41 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RJINUX (DBID=162984333)
RMAN> run
2> {
3> allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
allocate channel d5 type disk;
allocate channel d6 type disk;
allocate channel d7 type disk;
allocate channel d8 type disk;
set archivelog destination to '/opt/oracle/admin/rjin2/';
restore archivelog from logseq=96363 until logseq=96488 thread=1;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
release channel d5;
release channel d6;
release channel d7;
release channel d8;
}
4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21>
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: SID=574 device type=DISK
allocated channel: d2
channel d2: SID=713 device type=DISK
allocated channel: d3
channel d3: SID=858 device type=DISK
allocated channel: d4
channel d4: SID=1708 device type=DISK
allocated channel: d5
channel d5: SID=429 device type=DISK
allocated channel: d6
channel d6: SID=572 device type=DISK
allocated channel: d7
channel d7: SID=1142 device type=DISK
allocated channel: d8
channel d8: SID=2136 device type=DISK
executing command: SET ARCHIVELOG DESTINATION
Starting restore at 20-JUL-17
released channel: d1
released channel: d2
released channel: d3
released channel: d4
released channel: d5
released channel: d6
released channel: d7
released channel: d8
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/20/2017 23:11:22
RMAN-20242: specification does not match any archived log in the repository

Catalog backupset

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
RJINUXR:/opt/oracle/admin>ls -ltr /opt/oracle/admin/rjin2/
total 521088
-rw-r-----. 1 oracle oinstall 62310400 Jul 20 23:10 arch_RJINUX_20170720_lhs9rvp9_1_1
-rw-r-----. 1 oracle oinstall 62039552 Jul 20 23:10 arch_RJINUX_20170720_lgs9rvp9_1_1
-rw-r-----. 1 oracle oinstall 71940608 Jul 20 23:10 arch_RJINUX_20170720_les9rvp8_1_1
-rw-r-----. 1 oracle oinstall 68512768 Jul 20 23:10 arch_RJINUX_20170720_lds9rvp8_1_1
-rw-r-----. 1 oracle oinstall 60165120 Jul 20 23:10 arch_RJINUX_20170720_lcs9rvp8_1_1
-rw-r-----. 1 oracle oinstall 74117632 Jul 20 23:10 arch_RJINUX_20170720_ljs9rvp9_1_1
-rw-r-----. 1 oracle oinstall 76642816 Jul 20 23:10 arch_RJINUX_20170720_lfs9rvp8_1_1
-rw-r-----. 1 oracle oinstall 57842176 Jul 20 23:10 arch_RJINUX_20170720_lis9rvp9_1_1
RJINUXR:/opt/oracle/admin>rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jul 20 23:13:16 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RJINUX (DBID=162984333)
RMAN> catalog start with '/opt/oracle/admin/rjin2/';
using target database control file instead of recovery catalog
searching for all files that match the pattern /opt/oracle/admin/rjin2/
List of Files Unknown to the Database
=====================================
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lfs9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_ljs9rvp9_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lgs9rvp9_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lds9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lhs9rvp9_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_les9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lcs9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lis9rvp9_1_1
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lfs9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_ljs9rvp9_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lgs9rvp9_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lds9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lhs9rvp9_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_les9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lcs9rvp8_1_1
File Name: /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lis9rvp9_1_1
RMAN> exit
Recovery Manager complete.

Restore archivelog

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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
RJINUXR:/opt/oracle/admin>rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jul 20 23:17:12 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: RJINUX (DBID=162984333)
RMAN>
RMAN> run
2> {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
allocate channel d5 type disk;
allocate channel d6 type disk;
allocate channel d7 type disk;
allocate channel d8 type disk;
set archivelog destination to '/opt/oracle/admin/rjin2/';
restore archivelog from logseq=96363 until logseq=96488 thread=1;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
release channel d5;
release channel d6;
release channel d7;
release channel d8;
}
3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21>
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: SID=572 device type=DISK
allocated channel: d2
channel d2: SID=713 device type=DISK
allocated channel: d3
channel d3: SID=858 device type=DISK
allocated channel: d4
channel d4: SID=431 device type=DISK
allocated channel: d5
channel d5: SID=574 device type=DISK
allocated channel: d6
channel d6: SID=1142 device type=DISK
allocated channel: d7
channel d7: SID=2136 device type=DISK
allocated channel: d8
channel d8: SID=288 device type=DISK
executing command: SET ARCHIVELOG DESTINATION
Starting restore at 20-JUL-17
channel d1: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d1: restoring archived log
archived log thread=1 sequence=96410
channel d1: restoring archived log
archived log thread=1 sequence=96411
channel d1: restoring archived log
archived log thread=1 sequence=96412
channel d1: restoring archived log
archived log thread=1 sequence=96413
channel d1: restoring archived log
archived log thread=1 sequence=96414
channel d1: restoring archived log
archived log thread=1 sequence=96415
channel d1: restoring archived log
archived log thread=1 sequence=96416
channel d1: restoring archived log
archived log thread=1 sequence=96417
channel d1: restoring archived log
archived log thread=1 sequence=96418
channel d1: restoring archived log
archived log thread=1 sequence=96419
channel d1: restoring archived log
archived log thread=1 sequence=96420
channel d1: restoring archived log
archived log thread=1 sequence=96421
channel d1: restoring archived log
archived log thread=1 sequence=96422
channel d1: restoring archived log
archived log thread=1 sequence=96423
channel d1: restoring archived log
archived log thread=1 sequence=96424
channel d1: restoring archived log
archived log thread=1 sequence=96425
channel d1: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lfs9rvp8_1_1
channel d2: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d2: restoring archived log
archived log thread=1 sequence=96474
channel d2: restoring archived log
archived log thread=1 sequence=96475
channel d2: restoring archived log
archived log thread=1 sequence=96476
channel d2: restoring archived log
archived log thread=1 sequence=96477
channel d2: restoring archived log
archived log thread=1 sequence=96478
channel d2: restoring archived log
archived log thread=1 sequence=96479
channel d2: restoring archived log
archived log thread=1 sequence=96480
channel d2: restoring archived log
archived log thread=1 sequence=96481
channel d2: restoring archived log
archived log thread=1 sequence=96482
channel d2: restoring archived log
archived log thread=1 sequence=96483
channel d2: restoring archived log
archived log thread=1 sequence=96484
channel d2: restoring archived log
archived log thread=1 sequence=96485
channel d2: restoring archived log
archived log thread=1 sequence=96486
channel d2: restoring archived log
archived log thread=1 sequence=96487
channel d2: restoring archived log
archived log thread=1 sequence=96488
channel d2: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_ljs9rvp9_1_1
channel d3: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d3: restoring archived log
archived log thread=1 sequence=96426
channel d3: restoring archived log
archived log thread=1 sequence=96427
channel d3: restoring archived log
archived log thread=1 sequence=96428
channel d3: restoring archived log
archived log thread=1 sequence=96429
channel d3: restoring archived log
archived log thread=1 sequence=96430
channel d3: restoring archived log
archived log thread=1 sequence=96431
channel d3: restoring archived log
archived log thread=1 sequence=96432
channel d3: restoring archived log
archived log thread=1 sequence=96433
channel d3: restoring archived log
archived log thread=1 sequence=96434
channel d3: restoring archived log
archived log thread=1 sequence=96435
channel d3: restoring archived log
archived log thread=1 sequence=96436
channel d3: restoring archived log
archived log thread=1 sequence=96437
channel d3: restoring archived log
archived log thread=1 sequence=96438
channel d3: restoring archived log
archived log thread=1 sequence=96439
channel d3: restoring archived log
archived log thread=1 sequence=96440
channel d3: restoring archived log
archived log thread=1 sequence=96441
channel d3: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lgs9rvp9_1_1
channel d4: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d4: restoring archived log
archived log thread=1 sequence=96379
channel d4: restoring archived log
archived log thread=1 sequence=96380
channel d4: restoring archived log
archived log thread=1 sequence=96381
channel d4: restoring archived log
archived log thread=1 sequence=96382
channel d4: restoring archived log
archived log thread=1 sequence=96383
channel d4: restoring archived log
archived log thread=1 sequence=96384
channel d4: restoring archived log
archived log thread=1 sequence=96385
channel d4: restoring archived log
archived log thread=1 sequence=96386
channel d4: restoring archived log
archived log thread=1 sequence=96387
channel d4: restoring archived log
archived log thread=1 sequence=96388
channel d4: restoring archived log
archived log thread=1 sequence=96389
channel d4: restoring archived log
archived log thread=1 sequence=96390
channel d4: restoring archived log
archived log thread=1 sequence=96391
channel d4: restoring archived log
archived log thread=1 sequence=96392
channel d4: restoring archived log
archived log thread=1 sequence=96393
channel d4: restoring archived log
archived log thread=1 sequence=96394
channel d4: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lds9rvp8_1_1
channel d5: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d5: restoring archived log
archived log thread=1 sequence=96442
channel d5: restoring archived log
archived log thread=1 sequence=96443
channel d5: restoring archived log
archived log thread=1 sequence=96444
channel d5: restoring archived log
archived log thread=1 sequence=96445
channel d5: restoring archived log
archived log thread=1 sequence=96446
channel d5: restoring archived log
archived log thread=1 sequence=96447
channel d5: restoring archived log
archived log thread=1 sequence=96448
channel d5: restoring archived log
archived log thread=1 sequence=96449
channel d5: restoring archived log
archived log thread=1 sequence=96450
channel d5: restoring archived log
archived log thread=1 sequence=96451
channel d5: restoring archived log
archived log thread=1 sequence=96452
channel d5: restoring archived log
archived log thread=1 sequence=96453
channel d5: restoring archived log
archived log thread=1 sequence=96454
channel d5: restoring archived log
archived log thread=1 sequence=96455
channel d5: restoring archived log
archived log thread=1 sequence=96456
channel d5: restoring archived log
archived log thread=1 sequence=96457
channel d5: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lhs9rvp9_1_1
channel d6: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d6: restoring archived log
archived log thread=1 sequence=96395
channel d6: restoring archived log
archived log thread=1 sequence=96396
channel d6: restoring archived log
archived log thread=1 sequence=96397
channel d6: restoring archived log
archived log thread=1 sequence=96398
channel d6: restoring archived log
archived log thread=1 sequence=96399
channel d6: restoring archived log
archived log thread=1 sequence=96400
channel d6: restoring archived log
archived log thread=1 sequence=96401
channel d6: restoring archived log
archived log thread=1 sequence=96402
channel d6: restoring archived log
archived log thread=1 sequence=96403
channel d6: restoring archived log
archived log thread=1 sequence=96404
channel d6: restoring archived log
archived log thread=1 sequence=96405
channel d6: restoring archived log
archived log thread=1 sequence=96406
channel d6: restoring archived log
archived log thread=1 sequence=96407
channel d6: restoring archived log
archived log thread=1 sequence=96408
channel d6: restoring archived log
archived log thread=1 sequence=96409
channel d6: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_les9rvp8_1_1
channel d7: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d7: restoring archived log
archived log thread=1 sequence=96363
channel d7: restoring archived log
archived log thread=1 sequence=96364
channel d7: restoring archived log
archived log thread=1 sequence=96365
channel d7: restoring archived log
archived log thread=1 sequence=96366
channel d7: restoring archived log
archived log thread=1 sequence=96367
channel d7: restoring archived log
archived log thread=1 sequence=96368
channel d7: restoring archived log
archived log thread=1 sequence=96369
channel d7: restoring archived log
archived log thread=1 sequence=96370
channel d7: restoring archived log
archived log thread=1 sequence=96371
channel d7: restoring archived log
archived log thread=1 sequence=96372
channel d7: restoring archived log
archived log thread=1 sequence=96373
channel d7: restoring archived log
archived log thread=1 sequence=96374
channel d7: restoring archived log
archived log thread=1 sequence=96375
channel d7: restoring archived log
archived log thread=1 sequence=96376
channel d7: restoring archived log
archived log thread=1 sequence=96377
channel d7: restoring archived log
archived log thread=1 sequence=96378
channel d7: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lcs9rvp8_1_1
channel d8: starting archived log restore to user-specified destination
archived log destination=/opt/oracle/admin/rjin2/
channel d8: restoring archived log
archived log thread=1 sequence=96458
channel d8: restoring archived log
archived log thread=1 sequence=96459
channel d8: restoring archived log
archived log thread=1 sequence=96460
channel d8: restoring archived log
archived log thread=1 sequence=96461
channel d8: restoring archived log
archived log thread=1 sequence=96462
channel d8: restoring archived log
archived log thread=1 sequence=96463
channel d8: restoring archived log
archived log thread=1 sequence=96464
channel d8: restoring archived log
archived log thread=1 sequence=96465
channel d8: restoring archived log
archived log thread=1 sequence=96466
channel d8: restoring archived log
archived log thread=1 sequence=96467
channel d8: restoring archived log
archived log thread=1 sequence=96468
channel d8: restoring archived log
archived log thread=1 sequence=96469
channel d8: restoring archived log
archived log thread=1 sequence=96470
channel d8: restoring archived log
archived log thread=1 sequence=96471
channel d8: restoring archived log
archived log thread=1 sequence=96472
channel d8: restoring archived log
archived log thread=1 sequence=96473
channel d8: reading from backup piece /opt/oracle/admin/rjin2/arch_RJINUX_20170720_lis9rvp9_1_1
channel d4: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_lds9rvp8_1_1 tag=TAG20170720T230926
channel d4: restored backup piece 1
channel d4: restore complete, elapsed time: 00:02:35
channel d2: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_ljs9rvp9_1_1 tag=TAG20170720T230926
channel d2: restored backup piece 1
channel d2: restore complete, elapsed time: 00:03:07
channel d3: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_lgs9rvp9_1_1 tag=TAG20170720T230926
channel d3: restored backup piece 1
channel d3: restore complete, elapsed time: 00:03:07
channel d7: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_lcs9rvp8_1_1 tag=TAG20170720T230926
channel d7: restored backup piece 1
channel d7: restore complete, elapsed time: 00:03:07
channel d8: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_lis9rvp9_1_1 tag=TAG20170720T230926
channel d8: restored backup piece 1
channel d8: restore complete, elapsed time: 00:03:07
channel d1: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_lfs9rvp8_1_1 tag=TAG20170720T230926
channel d1: restored backup piece 1
channel d1: restore complete, elapsed time: 00:03:17
channel d6: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_les9rvp8_1_1 tag=TAG20170720T230926
channel d6: restored backup piece 1
channel d6: restore complete, elapsed time: 00:03:17
channel d5: piece handle=/opt/oracle/admin/rjin2/arch_RJINUX_20170720_lhs9rvp9_1_1 tag=TAG20170720T230926
channel d5: restored backup piece 1
channel d5: restore complete, elapsed time: 00:03:27
Finished restore at 20-JUL-17
released channel: d1
released channel: d2
released channel: d3
released channel: d4
released channel: d5
released channel: d6
released channel: d7
released channel: d8
RMAN> exit
Recovery Manager complete.

From the standby alert log, I can see archivelogs are applying.

An easy way

1
2
3
4
5
6
7
8
9
10
11
rman target sys/xxxx@RJINUXP
connect auxiliary sys/xxxx@RJINUXR
run {
allocate channel prmy1 type disk;
allocate auxiliary channel stby1 type disk;
allocate channel prmy2 type disk;
allocate auxiliary channel stby2 type disk;
allocate channel prmy3 type disk;
allocate auxiliary channel stby3 type disk;
backup as copy archivelog from logseq 96363 until logseq 96488 thread=1 auxiliary format '+RJIN_FRA/';
}