12c新特性:Rman中通过网络恢复文件

从12.1版本开始,rman提供了一个新功能,RESOTORE/RECOVER DATBASE USING SERVICE,可以直接通过网络对包含所需文件的物理备库进行文件的还原和恢复。可以恢复整库,数据文件,控制文件,参数文件或者表空间等。当你需要将备库与主库同步时通过网络还原文件非常有用。

通过网络使用备份集来还原和恢复文件,所有你可以使用多部分备份,加密和压缩等来提高备份和恢复的效率。

一般可以用在这些常见的场景:

  • 你需要前滚物理备库让它能与主库保持一致。

    一般通过创建主库的增量备份,然后恢复到备库。

  • 需要还原主库丢失的数据文件、控制文件或者表空间等,那么可以通过一致的物理备库上的文件来进行恢复。

12c以前,如果想要通过增量备份来让备库与主库同步成一致:

  1. 在主库上创建一个备库的控制文件
  2. 以备库的当前SCN号为起点,在主库上做一个增量备份
  3. 将增量备份拷贝到备库上,然后注册到RMAN的catalog
  4. 使用新的控制文件将备库启动到mount状态
  5. 取消备库的恢复应用,恢复增量备份
  6. 开启备库的恢复进程

而12c以后,步骤就简化了许多,只需要执行RECOVER … FROM SERVICE即可,这个命令则完成了下面这些过程:

  1. 以备库数据文件头里记录的SCN号为起点,在主库创建了增量备份
  2. 通过网络传输增量备份到备库机器
  3. 应用这些增量备份到备库

这样可以将备库的文件恢复到与主库保持一致,但是这种情况下备库的控制文件仍然记录的是旧的SCN号,要比现在备库数据文件里记录的SCN号要小。因此要完成整个同步工作,则需要更新备库的控制文件来使SCN号保持一致。

这里就模拟以前的一个例子处理一个dg gap同步问题,看看新功能带来的便利性。

查看主备库目前状态都是正常

1
2
3
4
5
6
7
8
9
10
11
12
13
--primary
sys@ORA12C> select db_unique_name,OPEN_MODE,DATABASE_ROLE from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
------------------------------ -------------------- ----------------
ora12c READ WRITE PRIMARY

--standby
sys@ORA12C> select db_unique_name,OPEN_MODE,DATABASE_ROLE from v$database;

DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE
------------------------------ -------------------- ----------------
ORA12C_DG READ ONLY WITH APPLY PHYSICAL STANDBY

查看同步情况

1
2
3
4
5
6
7
8
9
10
11
12
13
DGMGRL> show configuration;

Configuration - ora12ccfg

Protection Mode: MaxAvailability
Members:
ora12c - Primary database
ora12c_dg - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS (status updated 43 seconds ago)

将备库重启到mount状态

1
2
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;

停止同步,切换几个日志文件,然后删除主库归档

1
2
3
edit database ora12c_dg set state='apply-off';

alter system swithc logfile;

检查日志出现告警

1
2
3
4
5
6
7
8
9
10
11
12
13
14
DGMGRL> show configuration

Configuration - ora12ccfg

Protection Mode: MaxPerformance
Members:
ora12c - Primary database
ora12c_dg - Physical standby database
Warning: ORA-16853: apply lag has exceeded specified threshold

Fast-Start Failover: DISABLED

Configuration Status:
WARNING (status updated 19 seconds ago)

检查主备库数据文件的scn号

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
--primary
sys@ORA12C> select HXFIL File_num,substr(HXFNM,1,40) HXFNM,fhscn from x$kcvfh;

FILE_NUM HXFNM FHSCN
---------- ------------------------------------------------------------ --------------------
1 /u01/app/oracle/oradata/ORA12C/datafile/ 11049071
3 /u01/app/oracle/oradata/ORA12C/datafile/ 11049071
4 /u01/app/oracle/oradata/ORA12C/datafile/ 11049071
5 /u01/app/oracle/oradata/ORA12C/datafile/ 1439827
6 /u01/app/oracle/oradata/ORA12C/datafile/ 1439827
7 /u01/app/oracle/oradata/ORA12C/datafile/ 11049071
8 /u01/app/oracle/oradata/ORA12C/datafile/ 1439827
9 /u01/app/oracle/oradata/ORA12C/86DF3648F 11049071
10 /u01/app/oracle/oradata/ORA12C/86DF3648F 11049071
11 /u01/app/oracle/oradata/ORA12C/86DF3648F 11049071
12 /u01/app/oracle/oradata/ORA12C/86DF3648F 11049071
43 /u01/app/oracle/oradata/ORA12C/8838793F1 11049071
44 /u01/app/oracle/oradata/ORA12C/8838793F1 11049071
45 /u01/app/oracle/oradata/ORA12C/8838793F1 11049071

--standby
FILE_NUM HXFNM FHSCN
---------- ------------------------------------------------------------ --------------------
1 /u01/app/oracle/oradata/ORA12C_DG/datafi 11049003
3 /u01/app/oracle/oradata/ORA12C_DG/datafi 11049003
4 /u01/app/oracle/oradata/ORA12C_DG/datafi 11049003
5 /u01/app/oracle/oradata/ORA12C_DG/86DF14 1439827
6 /u01/app/oracle/oradata/ORA12C_DG/86DF14 1439827
7 /u01/app/oracle/oradata/ORA12C_DG/datafi 11049003
8 /u01/app/oracle/oradata/ORA12C_DG/86DF14 1439827
9 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11049003
10 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11049003
11 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11049003
12 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11049003
43 /u01/app/oracle/oradata/ORA12C_DG/883879 11049003
44 /u01/app/oracle/oradata/ORA12C_DG/883879 11049003
45 /u01/app/oracle/oradata/ORA12C_DG/883879 11049003

这里看到除了5、6、8三个文件以外,其他的数据文件主备的scn号都不一致,检查备库当前的scn

1
2
3
4
5
sys@ORA12C> SELECT CURRENT_SCN FROM V$DATABASE;

CURRENT_SCN
-----------
11049002

采用rman的新功能,recover standby using service,通过RMAN连接到target备库,然后用主库的service执行恢复备库命令。

语法:SYNTAX – RECOVER DATABASE FROM SERVICE < PRIMARY DB SERVICE NAME > NOREDO USING COMPRESSED 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
54
55
56
[oracle@stbyum ~]$ rman target /



RMAN> recover database from service ora12c noredo using compressed backupset;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=619 device type=DISK
skipping datafile 5; already restored to SCN 1439827
skipping datafile 6; already restored to SCN 1439827
skipping datafile 8; already restored to SCN 1439827
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00001: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_system_gfnobxo0_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00003: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_sysaux_gfnoc19w_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00004: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_undotbs1_gfnod4tg_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00007: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_users_gfnog41g_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00009: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_system_gfnog8nr_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00010: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_sysaux_gfnogcrs_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00011: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_undotbs1_gfnogmbq_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00012: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_users_gfnoh25p_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00043: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_system_gfnohkg4_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00044: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_sysaux_gfnohrhf_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using compressed network backup set from service ora12c
destination for restore of datafile 00045: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_undotbs1_gfnoj06c_.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16

可以看到这里只有数据文件被还原了,没有归档日志应用,没有控制文件,这表示目前备库不是一致的,

重新检查两边的数据文件的scn号

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
--primary
sys@ORA12C> select HXFIL File_num,substr(HXFNM,1,40) HXFNM,fhscn from x$kcvfh;

FILE_NUM HXFNM FHSCN
---------- ------------------------------------------------------------ --------------------
1 /u01/app/oracle/oradata/ORA12C/datafile/ 11055068
3 /u01/app/oracle/oradata/ORA12C/datafile/ 11055098
4 /u01/app/oracle/oradata/ORA12C/datafile/ 11055131
5 /u01/app/oracle/oradata/ORA12C/datafile/ 1439827
6 /u01/app/oracle/oradata/ORA12C/datafile/ 1439827
7 /u01/app/oracle/oradata/ORA12C/datafile/ 11055143
8 /u01/app/oracle/oradata/ORA12C/datafile/ 1439827
9 /u01/app/oracle/oradata/ORA12C/86DF3648F 11055152
10 /u01/app/oracle/oradata/ORA12C/86DF3648F 11055166
11 /u01/app/oracle/oradata/ORA12C/86DF3648F 11055181
12 /u01/app/oracle/oradata/ORA12C/86DF3648F 11055200
43 /u01/app/oracle/oradata/ORA12C/8838793F1 11055225
44 /u01/app/oracle/oradata/ORA12C/8838793F1 11055239
45 /u01/app/oracle/oradata/ORA12C/8838793F1 11055266

--standby
sys@ORA12C> select HXFIL File_num,substr(HXFNM,1,40) HXFNM,fhscn from x$kcvfh;

FILE_NUM HXFNM FHSCN
---------- ------------------------------------------------------------ --------------------
1 /u01/app/oracle/oradata/ORA12C_DG/datafi 11055068
3 /u01/app/oracle/oradata/ORA12C_DG/datafi 11055098
4 /u01/app/oracle/oradata/ORA12C_DG/datafi 11055131
5 /u01/app/oracle/oradata/ORA12C_DG/86DF14 1439827
6 /u01/app/oracle/oradata/ORA12C_DG/86DF14 1439827
7 /u01/app/oracle/oradata/ORA12C_DG/datafi 11055143
8 /u01/app/oracle/oradata/ORA12C_DG/86DF14 1439827
9 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11055152
10 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11055166
11 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11055181
12 /u01/app/oracle/oradata/ORA12C_DG/86DF36 11055200
43 /u01/app/oracle/oradata/ORA12C_DG/883879 11055225
44 /u01/app/oracle/oradata/ORA12C_DG/883879 11055239
45 /u01/app/oracle/oradata/ORA12C_DG/883879 11055266

可以看到现在两边的scn都同步到了一致状态。

因为数据文件都进行了恢复,控制文件还是老的,所以要从主库还原最新的备库控制文件

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
RMAN> shutdown immediate

database dismounted
Oracle instance shut down

RMAN> startup nomount

connected to target database (not started)
Oracle instance started

Total System Global Area 5083496448 bytes

Fixed Size 8803264 bytes
Variable Size 1207962688 bytes
Database Buffers 3858759680 bytes
Redo Buffers 7970816 bytes

RMAN> restore standby controlfile from service ora12c;

Starting restore at 22-MAY-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=743 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service ora12c
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:06
output file name=/u01/app/oracle/oradata/ORA12C/controlfile/o1_mf_gcm27myg_.ctl
output file name=/u01/app/oracle/fast_recovery_area/ora12c/ORA12C/controlfile/o1_mf_gcm27ndj_.ctl
Finished restore at 22-MAY-19

RMAN> alter database mount;

Statement processed
released channel: ORA_DISK_1

这一步完成以后,备库控制文件里记录的文件名是与主库一样,如果本来主备库路径和名称就是一致的,那么就不用做其他处理了,否则需要对控制文件的内容做更新。

修正控制文件里记录的数据文件和临时文件的名称

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
RMAN> catalog start with '/u01/app/oracle/oradata/ORA12C_DG';

Starting implicit crosscheck backup at 22-MAY-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=253 device type=DISK
Crosschecked 20 objects
Finished implicit crosscheck backup at 22-MAY-19

Starting implicit crosscheck copy at 22-MAY-19
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 22-MAY-19

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/ora12c/ORA12C/ORA12C_DG/autobackup/2019_04_23/o1_mf_s_1006353206_gcxdzml6_.bkp
File Name: /u01/app/oracle/fast_recovery_area/ora12c/ORA12C/ORA12C_DG/autobackup/2019_04_24/o1_mf_s_1006442710_gd03trx4_.bkp
File Name: /u01/app/oracle/fast_recovery_area/ora12c/ORA12C/ORA12C_DG/autobackup/2019_04_24/o1_mf_s_1006454159_gd0hmrfs_.bkp
File Name: /u01/app/oracle/fast_recovery_area/ora12c/ORA12C/ORA12C_DG/autobackup/2019_05_06/o1_mf_s_1007567615_gdztcxvr_.bkp
File Name: /u01/app/oracle/fast_recovery_area/ora12c/ORA12C/ORA12C_DG/autobackup/2019_05_06/o1_mf_s_1007571825_gdzy5vg5_.bkp

searching for all files that match the pattern /u01/app/oracle/oradata/ORA12C_DG

List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_system_gcxbppbo_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_sysaux_gcxbq4jy_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_undotbs1_gcxbqfcq_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_users_gcxbsd21_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_temp_gcxbvd7s_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_system_gfnobxo0_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_sysaux_gfnoc19w_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_undotbs1_gfnod4tg_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_users_gfnog41g_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_temp_gfnonot8_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_system_gcxbqvmf_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_sysaux_gcxbqyr5_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_undotbs1_gcxbsf50_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_temp_gcxbvg7d_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_system_gfnodmhj_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_sysaux_gfnodpls_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_undotbs1_gfnog77f_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_temp_gfnonr04_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_system_gcxbsgb6_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_sysaux_gcxbsknh_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_undotbs1_gcxbsnt4_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_users_gcxbt3z2_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_temp_gczp8ojm_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_tbs_noco_gf2fxhlt_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_tbs_comp_gf2fxkmm_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_system_gfnog8nr_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_sysaux_gfnogcrs_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_undotbs1_gfnogmbq_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_users_gfnoh25p_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_1_gcxbtmj1_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_2_gcxbtnfs_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_3_gcxbtopn_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_4_gcxbtq2x_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_5_gcxbtsh9_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_6_gcxbttm1_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_7_gcxbtvgx_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_1_gfnojotd_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_2_gfnojtn0_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_3_gfnojzln_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_4_gfnok35r_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_5_gfnok7fj_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_6_gfnol2wo_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_7_gfnolyr2_.log
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_system_gd0fcdjn_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_sysaux_gd0fcmgq_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_undotbs1_gd0fcpow_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_system_gd0fp8hg_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_sysaux_gd0fpcmw_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_undotbs1_gd0fpgxn_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_system_gdzoy61r_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_sysaux_gdzoy61s_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_undotbs1_gdzoy61t_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_temp_gdzst0jh_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_system_gdzxf5td_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_sysaux_gdzxf5tf_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_undotbs1_gdzxf5tg_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_temp_gdzxmo4z_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_system_gf0c32gr_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_sysaux_gf0c32gs_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_undotbs1_gf0c32gt_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_system_gfnohkg4_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_sysaux_gfnohrhf_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_undotbs1_gfnoj06c_.dbf

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_system_gcxbppbo_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_sysaux_gcxbq4jy_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_undotbs1_gcxbqfcq_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_users_gcxbsd21_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_temp_gcxbvd7s_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_system_gfnobxo0_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_sysaux_gfnoc19w_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_undotbs1_gfnod4tg_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_users_gfnog41g_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_temp_gfnonot8_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_system_gcxbqvmf_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_sysaux_gcxbqyr5_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_undotbs1_gcxbsf50_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_temp_gcxbvg7d_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_system_gfnodmhj_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_sysaux_gfnodpls_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_undotbs1_gfnog77f_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_temp_gfnonr04_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_system_gcxbsgb6_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_sysaux_gcxbsknh_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_undotbs1_gcxbsnt4_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_users_gcxbt3z2_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_temp_gczp8ojm_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_tbs_noco_gf2fxhlt_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_tbs_comp_gf2fxkmm_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_system_gfnog8nr_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_sysaux_gfnogcrs_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_undotbs1_gfnogmbq_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_users_gfnoh25p_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_system_gd0fcdjn_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_sysaux_gd0fcmgq_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_undotbs1_gd0fcpow_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_system_gd0fp8hg_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_sysaux_gd0fpcmw_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8741EB39B020CBF3E0536892A8C0E24F/datafile/o1_mf_undotbs1_gd0fpgxn_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_system_gdzoy61r_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_sysaux_gdzoy61s_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_undotbs1_gdzoy61t_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/88336E2F7C204DA0E0536892A8C0C724/datafile/o1_mf_temp_gdzst0jh_.tmp
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_system_gf0c32gr_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_sysaux_gf0c32gs_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_undotbs1_gf0c32gt_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_system_gfnohkg4_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_sysaux_gfnohrhf_.dbf
File Name: /u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_undotbs1_gfnoj06c_.dbf

List of Files Which Were Not Cataloged
=======================================
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_1_gcxbtmj1_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_2_gcxbtnfs_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_3_gcxbtopn_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_4_gcxbtq2x_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_5_gcxbtsh9_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_6_gcxbttm1_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_7_gcxbtvgx_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_1_gfnojotd_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_2_gfnojtn0_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_3_gfnojzln_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_4_gfnok35r_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_5_gfnok7fj_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_6_gfnol2wo_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/onlinelog/o1_mf_7_gfnolyr2_.log
RMAN-07529: Reason: catalog is not supported for this file type
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_system_gdzxf5td_.dbf
RMAN-07519: Reason: Error while cataloging. See alert.log.
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_sysaux_gdzxf5tf_.dbf
RMAN-07519: Reason: Error while cataloging. See alert.log.
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_undotbs1_gdzxf5tg_.dbf
RMAN-07519: Reason: Error while cataloging. See alert.log.
File Name: /u01/app/oracle/oradata/ORA12C_DG/8835360767C07549E0536892A8C06926/datafile/o1_mf_temp_gdzxmo4z_.tmp
RMAN-07518: Reason: Foreign database file DBID: 980071166 Database Name: CDB1

Switch to cataloged copy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
RMAN> SWITCH DATABASE TO COPY;

datafile 1 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_system_gfnobxo0_.dbf"
datafile 3 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_sysaux_gfnoc19w_.dbf"
datafile 4 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_undotbs1_gfnod4tg_.dbf"
datafile 5 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_system_gfnodmhj_.dbf"
datafile 6 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_sysaux_gcxbqyr5_.dbf"
datafile 7 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/datafile/o1_mf_users_gfnog41g_.dbf"
datafile 8 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/86DF1439DC9B8E60E0536892A8C0ECA0/datafile/o1_mf_undotbs1_gfnog77f_.dbf"
datafile 9 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_system_gfnog8nr_.dbf"
datafile 10 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_sysaux_gfnogcrs_.dbf"
datafile 11 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_undotbs1_gfnogmbq_.dbf"
datafile 12 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/86DF3648F8F79A5AE0536892A8C00070/datafile/o1_mf_users_gfnoh25p_.dbf"
datafile 43 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_system_gfnohkg4_.dbf"
datafile 44 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_sysaux_gfnohrhf_.dbf"
datafile 45 switched to datafile copy "/u01/app/oracle/oradata/ORA12C_DG/8838793F133511C4E0536892A8C01690/datafile/o1_mf_undotbs1_gfnoj06c_.dbf"

如果在备库进行recover from service的过程中,主库新增了数据文件,那么需要单独将这个文件恢复到备库,也就是之前步骤查询的数据库SCN号

1
2
3
4
5
6
7
8
9
10
11
SELECT file# FROM V$DATAFILE WHERE creation_change# >= v$database.current_scn(STANDBY);

-- NON-CATALOG:
RUN
{
SET NEWNAME FOR DATABASE TO '/u01/app/oracle/oradata/ORA12C_DG';
RESTORE DATAFILE XX FROM SERVICE ORA12C;
}

-- CATALOG:
RESTORE DATAFILE XX FROM SERVICE ORA12C;

更新备库控制文件中redo日志文件的名称,这里直接clear备库日志,等下RMAN会自动重建

1
2
3
4
5
6
7
alter database clear logfile group 1;
alter database clear logfile group 2;
alter database clear logfile group 3;
alter database clear logfile group 4;
alter database clear logfile group 5;
alter database clear logfile group 6;
alter database clear logfile group 7;

主库做几个日志切换

1
ALTER SYSTEM ARCHIVE LOG CURRENT;

备库开启恢复进程

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
RMAN> recover database;

Starting recover at 22-MAY-19
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 175 is already on disk as file /u01/arch/ora12c/1_175_1006450609.dbf
archived log for thread 1 with sequence 176 is already on disk as file /u01/arch/ora12c/1_176_1006450609.dbf
archived log for thread 1 with sequence 177 is already on disk as file /u01/arch/ora12c/1_177_1006450609.dbf
archived log file name=/u01/arch/ora12c/1_175_1006450609.dbf thread=1 sequence=175
archived log file name=/u01/arch/ora12c/1_176_1006450609.dbf thread=1 sequence=176
archived log file name=/u01/arch/ora12c/1_177_1006450609.dbf thread=1 sequence=177
media recovery complete, elapsed time: 00:00:59
Finished recover at 22-MAY-19

RMAN> ALTER DATABASE OPEN READ ONLY;

Statement processed

DGMGRL> edit database ora12c_dg set state='apply-on';
Succeeded.
DGMGRL> show configuration

Configuration - ora12ccfg

Protection Mode: MaxPerformance
Members:
ora12c - Primary database
ora12c_dg - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS (status updated 1 second ago)

12c新特性:Rman中通过网络恢复文件
https://www.xbdba.com/2019/05/22/12c-newfeature-rman-recover-database-using-service/
作者
xbdba
发布于
2019年5月22日
许可协议