oracle 11g ADG GAP修复---方法2
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 | 一、模拟产生GAP 1.备库停止DG同步进程: SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination /oracle/archive Oldest online log sequence 72 Next log sequence to archive 0 Current log sequence 74 SQL> alter database recover managed standby database cancel; Database altered. SQL> SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. 2.主库切换多次归档: SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination /oracle/archive Oldest online log sequence 72 Next log sequence to archive 74 Current log sequence 74 SQL> SQL> SQL> SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. SQL> / System altered. SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination /oracle/archive Oldest online log sequence 76 Next log sequence to archive 78 Current log sequence 78 3.主库删除/移动最近几个归档日志: [oracle@dgdb1 ~]$ cd /oracle/archive/ [oracle@dgdb1 archive]$ mv 1_74_1024761634.dbf 1_75_1024761634.dbf 1_76_1024761634.dbf 1_77_1024761634.dbf /home/oracle 4.备库开启同步进程: SQL> alter database recover managed standby database using current logfile disconnect from session; Database altered. 5.查看GAP: SQL> select * from v$archive_gap; THREAD# LOW_SEQUENCE# HIGH_SEQUENCE# ---------- ------------- -------------- 1 73 77 SQL> SELECT max(sequence#) from v$archived_log where applied= 'YES' ; MAX(SEQUENCE#) -------------- 73 丢失了74-77四个日志 二、恢复备库: 1.在主库上创建一个备库的控制文件: SQL> alter database create standby controlfile as '/home/oracle/standby.ctl' ; Database altered. 2.以备库的当前SCN号为起点,在主库上做一个增量备份 查询备库当前SCN: SQL> select current_scn from v$database; CURRENT_SCN ----------- 1248633 确认主备GAP期间是否新增数据文件: SQL> select file# from v$datafile where creation_change# > =1248633; 如果存在新增数据文件,备库恢复时需要先restore新添加的数据文件。 主库根据备库scn号进行增量备份: RMAN> run{ allocate channel c1 type disk; allocate channel c2 type disk; backup INCREMENTAL from scn 1248633 database format '/home/oracle/incre_%U' ; release channel c1; release channel c2; } 2> 3> 4> 5> 6> 7> allocated channel: c1 channel c1: SID=52 device type=DISK allocated channel: c2 channel c2: SID=54 device type=DISK Starting backup at 10-MAY-22 channel c1: starting full datafile backup set channel c1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/rmanpri/system01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/rmanpri/users01.dbf channel c1: starting piece 1 at 10-MAY-22 channel c2: starting full datafile backup set channel c2: specifying datafile(s) in backup set input datafile file number=00002 name=/u01/app/oracle/oradata/rmanpri/sysaux01.dbf input datafile file number=00003 name=/u01/app/oracle/oradata/rmanpri/undotbs01.dbf channel c2: starting piece 1 at 10-MAY-22 channel c2: finished piece 1 at 10-MAY-22 piece handle=/home/oracle/incre_0u0t5vb9_1_1 tag=TAG20220510T185433 comment=NONE channel c2: backup set complete, elapsed time: 00:01:06 channel c2: starting full datafile backup set channel c2: specifying datafile(s) in backup set including current control file in backup set channel c2: starting piece 1 at 10-MAY-22 channel c2: finished piece 1 at 10-MAY-22 piece handle=/home/oracle/incre_0v0t5vdb_1_1 tag=TAG20220510T185433 comment=NONE channel c2: backup set complete, elapsed time: 00:00:01 channel c1: finished piece 1 at 10-MAY-22 piece handle=/home/oracle/incre_0t0t5vb9_1_1 tag=TAG20220510T185433 comment=NONE channel c1: backup set complete, elapsed time: 00:01:10 Finished backup at 10-MAY-22 released channel: c1 released channel: c2 [oracle@dgdb1 trace]$ ll /home/oracle/ total 20404 -rw-r----- 1 oracle oinstall 221184 May 10 18:55 incre_0t0t5vb9_1_1 -rw-r----- 1 oracle oinstall 344064 May 10 18:55 incre_0u0t5vb9_1_1 -rw-r----- 1 oracle oinstall 10092544 May 10 18:55 incre_0v0t5vdb_1_1 -rw-r----- 1 oracle oinstall 10043392 May 10 18:48 standby.ctl 将增量备份和控制文件拷贝到备库上: [oracle@dgdb1 trace]$ scp /home/oracle/incre_0* dgdb2:/home/oracle oracle@dgdb2's password: incre_0t0t5vb9_1_1 100% 216KB 216.0KB/s 00:00 incre_0u0t5vb9_1_1 100% 336KB 336.0KB/s 00:00 incre_0v0t5vdb_1_1 100% 9856KB 9.6MB/s 00:01 [oracle@dgdb1 trace]$ scp /home/oracle/standby.ctl dgdb2:/home/oracle oracle@dgdb2's password: standby.ctl [oracle@dgdb2 trace]$ ll /home/oracle/ total 20216 -rw-r----- 1 oracle oinstall 221184 May 11 17:49 incre_0t0t5vb9_1_1 -rw-r----- 1 oracle oinstall 344064 May 11 17:49 incre_0u0t5vb9_1_1 -rw-r----- 1 oracle oinstall 10092544 May 11 17:49 incre_0v0t5vdb_1_1 -rw-r----- 1 oracle oinstall 10043392 May 11 17:50 standby.ctl 备库关闭数据库实例,开启至nomount状态: SQL> alter database recover managed standby database cancel; Database altered. SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup nomount ORACLE instance started. Total System Global Area 584568832 bytes Fixed Size 2255432 bytes Variable Size 226493880 bytes Database Buffers 352321536 bytes Redo Buffers 3497984 bytes 备库恢复新的控制文件: RMAN> restore controlfile from '/home/oracle/standby.ctl' ; Starting restore at 11-MAY-22 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=19 device type=DISK channel ORA_DISK_1: copied control file copy output file name=/u01/app/oracle/oradata/rmanstd/control01.ctl output file name=/u01/app/oracle/fast_recovery_area/rmanstd/control02.ctl Finished restore at 11-MAY-22 备库开启到mount状态: SQL> alter database mount; Database altered. 确认取消日志应用: SQL> alter database recover managed standby database cancel; Database altered. 增量备份注册到RMAN的catalog: RMAN> catalog start with '/home/oracle' ; released channel: ORA_DISK_1 Starting implicit crosscheck backup at 11-MAY-22 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=19 device type=DISK Crosschecked 9 objects Finished implicit crosscheck backup at 11-MAY-22 Starting implicit crosscheck copy at 11-MAY-22 using channel ORA_DISK_1 Crosschecked 4 objects Finished implicit crosscheck copy at 11-MAY-22 searching for all files in the recovery area cataloging files... no files cataloged searching for all files that match the pattern /home/oracle List of Files Unknown to the Database ===================================== File Name: /home/oracle/.bashrc File Name: /home/oracle/.bash_logout File Name: /home/oracle/incre_0v0t5vdb_1_1 File Name: /home/oracle/.bash_history File Name: /home/oracle/.oracle/logs/installActions2019-11-04_11-00-39AM.log File Name: /home/oracle/.oracle/logs/oraInstall2019-11-04_11-00-39AM. out File Name: /home/oracle/.oracle/logs/oraInstall2019-11-04_11-00-39AM.err File Name: /home/oracle/.bash_profile File Name: /home/oracle/incre_0u0t5vb9_1_1 File Name: /home/oracle/incre_0t0t5vb9_1_1 File Name: /home/oracle/.kshrc File Name: /home/oracle/standby.ctl File Name: /home/oracle/.viminfo Do you really want to catalog the above files (enter YES or NO)? yes cataloging files... cataloging done List of Cataloged Files ======================= File Name: /home/oracle/incre_0v0t5vdb_1_1 File Name: /home/oracle/incre_0u0t5vb9_1_1 File Name: /home/oracle/incre_0t0t5vb9_1_1 File Name: /home/oracle/standby.ctl 备库开启恢复增量备份: RMAN> recover database noredo; Starting recover at 11-MAY-22 using channel ORA_DISK_1 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle/oradata/rmanstd/system01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/rmanstd/users01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/incre_0t0t5vb9_1_1 channel ORA_DISK_1: piece handle=/home/oracle/incre_0t0t5vb9_1_1 tag=TAG20220510T185433 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00002: /u01/app/oracle/oradata/rmanstd/sysaux01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/rmanstd/undotbs01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/incre_0u0t5vb9_1_1 channel ORA_DISK_1: piece handle=/home/oracle/incre_0u0t5vb9_1_1 tag=TAG20220510T185433 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished recover at 11-MAY-22 备库开启日志同步进程: SQL> alter database recover managed standby database using current logfile disconnect from session; Database altered. 查看GAP: SQL> select * from v$archive_gap; no rows selected SQL> SELECT max(sequence#) from v$archived_log where applied= 'YES' ; MAX(SEQUENCE#) -------------- 主库: SQL> alter system switch logfile; System altered. SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination /oracle/archive Oldest online log sequence 79 Next log sequence to archive 81 Current log sequence 81 备库: SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination /oracle/archive Oldest online log sequence 79 Next log sequence to archive 0 Current log sequence 81 GAP修复完成。 |
分类:
oracle
, oracle-troubleshooting
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)