11gR2dataguard備庫(kù)文件損壞處理

  1. 環(huán)境模擬:

    成都創(chuàng)新互聯(lián)是專業(yè)的茂南網(wǎng)站建設(shè)公司,茂南接單;提供成都做網(wǎng)站、成都網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行茂南網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!

    主庫(kù):

SQL> select DATABASE_ROLE,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PRIMARY  READ WRITE

        備庫(kù):

SQL> select DATABASE_ROLE,open_mode from v$database;
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY

2.主庫(kù)中斷日志傳輸,備庫(kù)停止日志應(yīng)用,然后再主庫(kù)更新數(shù)據(jù)。

SQL>  ALTER SYSTEM SET log_archive_dest_state_2='reset' SCOPE=BOTH;
System altered.

alert日志可以看到,不再向備庫(kù)傳輸日志:

ALTER SYSTEM SET log_archive_dest_state_2='reset' SCOPE=BOTH;
Wed Oct 21 10:41:05 2015
Thread 1 advanced to log sequence 355 (LGWR switch)
  Current log# 1 seq# 355 mem# 0: +DATA/phub/onlinelog/group_1.262.890480943
  Current log# 1 seq# 355 mem# 1: +DATA/phub/onlinelog/group_1.263.890480945
Wed Oct 21 10:41:05 2015
Archived Log entry 707 added for thread 1 sequence 354 ID 0x1fffdaed dest 1:
Thread 1 cannot allocate new log, sequence 356
Checkpoint not complete
  Current log# 1 seq# 355 mem# 0: +DATA/phub/onlinelog/group_1.262.890480943
  Current log# 1 seq# 355 mem# 1: +DATA/phub/onlinelog/group_1.263.890480945
Thread 1 advanced to log sequence 356 (LGWR switch)
  Current log# 2 seq# 356 mem# 0: +DATA/phub/onlinelog/group_2.264.890480945
  Current log# 2 seq# 356 mem# 1: +DATA/phub/onlinelog/group_2.265.890480945
Wed Oct 21 10:41:06 2015
Archived Log entry 708 added for thread 1 sequence 355 ID 0x1fffdaed dest 1:

備庫(kù)停止日志應(yīng)用:

SQL> ALTER DATABASE recover managed standby DATABASE cancel;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY

測(cè)試數(shù)據(jù):

主庫(kù),

SQL> conn scott/scott;
Connected.
SQL> select count(*) from test;
  COUNT(*)
----------
     87065

備庫(kù):

SQL> select count(*) from test;

  COUNT(*)

----------

     87065

主庫(kù)更新test表數(shù)據(jù):

SQL> delete from test where rownum<1000;
999 rows deleted.
SQL> update test set owner='SCOTT' where object_id<10000;
8812 rows updated.
SQL> insert into test select * from test;
86066 rows created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.

刪除最新歸檔日志:

ASMCMD [+data/PHUB/ARCHIVELOG/2015_10_21] > rm -rf thread_1_seq_359.544.893674539
ASMCMD [+data/PHUB/ARCHIVELOG/2015_10_21] > rm -rf thread_1_seq_358.543.893674457
ASMCMD [+data/PHUB/ARCHIVELOG/2015_10_21] > rm -rf thread_1_seq_357.542.893674453
ASMCMD [+data/PHUB/ARCHIVELOG/2015_10_21] >

啟用主庫(kù)日志傳輸:

SQL> ALTER system SET log_archive_dest_state_2 = 'enable';

System altered.

啟用備庫(kù)日志應(yīng)用:

SQL> conn / as sysdba
Connected.
SQL> ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION;
Database altered.

查看備庫(kù)alert日志:

[oracle@dg trace]$ tail -f alert_MECBS.log 

Serial Media Recovery started

Managed Standby Recovery not using Real Time Apply

Waiting for all non-current ORLs to be archived...

All non-current ORLs have been archived.

Completed: ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION

Media Recovery Log +DATA/mecbs/archivelog/2015_10_21/thread_1_seq_354.606.893674715

Media Recovery Log +DATA/mecbs/archivelog/2015_10_21/thread_1_seq_355.607.893674715

Media Recovery Log +DATA/mecbs/archivelog/2015_10_21/thread_1_seq_356.605.893674715

Media Recovery Waiting for thread 1 sequence 357

Fetching gap sequence in thread 1, gap sequence 357-359

Wed Oct 21 11:01:34 2015

FAL[client]: Failed to request gap sequence

 GAP - thread 1 sequence 357-359

 DBID 536511065 branch 890484819

FAL[client]: All defined FAL servers have been attempted.

------------------------------------------------------------

Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization

parameter is defined to a value that's sufficiently large

enough to maintain adequate log switch information to resolve

archivelog gaps.

------------------------------------------------------------

解決辦法:

查詢主庫(kù)scn:

  1. SQL> SELECT SEQUENCE#,FIRST_CHANGE#,NEXT_CHANGE# FROM v$archived_log WHERE SEQUENCE# > 356 ORDER BY 1;
     SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
    ---------- ------------- ------------
           357 5501419      5501424
           358 5501424      5501430
           359 5501430      5501524
           360 5501524      5501782
           360 5501524      5501782

2)根據(jù)scn,進(jìn)行rman增量備份

RMAN> backup device type disk incremental from scn 5501419 database format '/home/oracle/data_%U.bak';
Starting backup at 21-OCT-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=400 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=613 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/phub/datafile/llc01.dbf
input datafile file number=00003 name=+DATA/phub/datafile/undotbs1.260.891340857
input datafile file number=00004 name=+DATA/phub/datafile/users.269.891340843
channel ORA_DISK_1: starting piece 1 at 21-OCT-15
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=+DATA/phub/datafile/sysaux.272.891340857
input datafile file number=00007 name=+DATA/phub/datafile/idx01.dbf
input datafile file number=00001 name=+DATA/phub/datafile/system.271.891340857
input datafile file number=00005 name=+DATA/phub/datafile/example.287.891340843
channel ORA_DISK_2: starting piece 1 at 21-OCT-15
channel ORA_DISK_1: finished piece 1 at 21-OCT-15
piece handle=/home/oracle/data_5lqk8pt4_1_1.bak tag=TAG20151021T111028 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:06
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
channel ORA_DISK_2: finished piece 1 at 21-OCT-15
piece handle=/home/oracle/data_5mqk8pt4_1_1.bak tag=TAG20151021T111028 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:01:05
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 21-OCT-15
channel ORA_DISK_1: finished piece 1 at 21-OCT-15
piece handle=/home/oracle/data_5nqk8pv6_1_1.bak tag=TAG20151021T111028 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-OCT-15

上傳備份文件到備庫(kù):

[oracle@cwogg ~]$ scp data_5* 172.16.30.228:/home/oracle/
oracle@172.16.30.228's password: 
data_5lqk8pt4_1_1.bak                                                           100% 1248KB   1.2MB/s   00:00    
data_5mqk8pt4_1_1.bak                                                           100% 7128KB   7.0MB/s   00:00    
data_5nqk8pv6_1_1.bak                                                           100%   10MB  10.2MB/s   00:00

備庫(kù)上進(jìn)行recover:

SQL> ALTER DATABASE recover managed standby DATABASE cancel;
Database altered

[oracle@dg ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Oct 21 11:19:03 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PHUB (DBID=536511065)

RMAN> catalog start with '/home/oracle/backup/';

using target database control file instead of recovery catalog

searching for all files that match the pattern /home/oracle/backup/

List of Files Unknown to the Database

=====================================

File Name: /home/oracle/backup/data_5lqk8pt4_1_1.bak

File Name: /home/oracle/backup/data_5mqk8pt4_1_1.bak

File Name: /home/oracle/backup/data_5nqk8pv6_1_1.bak

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/backup/data_5lqk8pt4_1_1.bak

File Name: /home/oracle/backup/data_5mqk8pt4_1_1.bak

File Name: /home/oracle/backup/data_5nqk8pv6_1_1.bak

恢復(fù)備庫(kù):

[oracle@dg ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 21 11:22:44 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area  835104768 bytes

Fixed Size    2257840 bytes

Variable Size  541068368 bytes

Database Buffers  289406976 bytes

Redo Buffers    2371584 bytes

Database mounted.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

[oracle@dg ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Oct 21 11:23:39 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PHUB (DBID=536511065, not open)

RMAN> recover database noredo;

Starting recover at 21-OCT-15

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=36 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=37 device type=DISK

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: +DATA/mecbs/datafile/system.259.891103927

destination for restore of datafile 00002: +DATA/mecbs/datafile/sysaux.260.891104071

destination for restore of datafile 00005: +DATA/mecbs/datafile/example.261.891104187

destination for restore of datafile 00007: +DATA/mecbs/datafile/idx.410.891688925

channel ORA_DISK_1: reading from backup piece /home/oracle/backup/data_5mqk8pt4_1_1.bak

channel ORA_DISK_2: starting incremental datafile backup set restore

channel ORA_DISK_2: specifying datafile(s) to restore from backup set

destination for restore of datafile 00003: +DATA/mecbs/datafile/undotbs1.262.891104243

destination for restore of datafile 00004: +DATA/mecbs/datafile/users.263.891104267

destination for restore of datafile 00006: +DATA/mecbs/datafile/llc.258.891103925

channel ORA_DISK_2: reading from backup piece /home/oracle/backup/data_5lqk8pt4_1_1.bak

channel ORA_DISK_1: piece handle=/home/oracle/backup/data_5mqk8pt4_1_1.bak tag=TAG20151021T111028

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

channel ORA_DISK_2: piece handle=/home/oracle/backup/data_5lqk8pt4_1_1.bak tag=TAG20151021T111028

channel ORA_DISK_2: restored backup piece 1

channel ORA_DISK_2: restore complete, elapsed time: 00:00:03

Finished recover at 21-OCT-15

查看備庫(kù)alert日志:

Wed Oct 21 11:23:45 2015

Incremental restore complete of datafile 3 +DATA/mecbs/datafile/undotbs1.262.891104243

  checkpoint is 5502788

  last deallocation scn is 1354205

Wed Oct 21 11:23:45 2015

Incremental restore complete of datafile 5 +DATA/mecbs/datafile/example.261.891104187

  checkpoint is 5502790

  last deallocation scn is 1114995

Incremental restore complete of datafile 4 +DATA/mecbs/datafile/users.263.891104267

  checkpoint is 5502788

  last deallocation scn is 3

Incremental restore complete of datafile 1 +DATA/mecbs/datafile/system.259.891103927

  checkpoint is 5502790

  last deallocation scn is 1095967

Incremental restore complete of datafile 6 +DATA/mecbs/datafile/llc.258.891103925

  checkpoint is 5502788

  last deallocation scn is 1099825

Incremental restore complete of datafile 7 +DATA/mecbs/datafile/idx.410.891688925

  checkpoint is 5502790

Incremental restore complete of datafile 2 +DATA/mecbs/datafile/sysaux.260.891104071

  checkpoint is 5502790

  last deallocation scn is 994406

開(kāi)啟日志應(yīng)用:

SQL> ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION;

Database altered.

主庫(kù)切換日志:

SQL> ALTER system switch logfile;
System altered.
SQL> /
System altered.
SQL> SELECT MAX(al.SEQUENCE#) "Last Seq Recieved", MAX(lh.SEQUENCE#) "Last Seq Applied" FROM v$archived_log al, v$log_history lh;  
Last Seq Recieved Last Seq Applied
----------------- ----------------
      363       363

備庫(kù):

SQL> SELECT MAX(al.SEQUENCE#) "Last Seq Recieved", MAX(lh.SEQUENCE#) "Last Seq Applied" FROM v$archived_log al, v$log_history lh;  

Last Seq Recieved Last Seq Applied

----------------- ----------------

     363       356

此時(shí)備庫(kù)仍然顯示有g(shù)ap:

Completed: ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION
Media Recovery Waiting for thread 1 sequence 357
Fetching gap sequence in thread 1, gap sequence 357-359
Wed Oct 21 11:27:29 2015
RFS[1]: Selected log 4 for thread 1 sequence 363 dbid 536511065 branch 890484819
Wed Oct 21 11:27:29 2015
Archived Log entry 333 added for thread 1 sequence 362 ID 0x1fffdaed dest 1:
Wed Oct 21 11:27:49 2015
RFS[1]: Selected log 5 for thread 1 sequence 364 dbid 536511065 branch 890484819
Wed Oct 21 11:27:49 2015
Archived Log entry 334 added for thread 1 sequence 363 ID 0x1fffdaed dest 1:
Wed Oct 21 11:27:52 2015
FAL[client]: Failed to request gap sequence
 GAP - thread 1 sequence 357-359
 DBID 536511065 branch 890484819
FAL[client]: All defined FAL servers have been attempted.
------------------------------------------------------------
Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that's sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
------------------------------------------------------------

停止備庫(kù)日志應(yīng)用,在重啟,

兩邊數(shù)據(jù)以及同步了:

SQL> archive log list;

Database log mode       Archive Mode

Automatic archival       Enabled

Archive destination       +DATA

Oldest online log sequence     365

Next log sequence to archive   0

Current log sequence       367

SQL> archive log list;

Database log mode       Archive Mode

Automatic archival       Enabled

Archive destination       +DATA

Oldest online log sequence     365

Next log sequence to archive   367

Current log sequence       367

但是備庫(kù)alertlog仍然報(bào)錯(cuò):找不到那3個(gè)歸檔文件:

FAL[client]: Failed to request gap sequence

 GAP - thread 1 sequence 357-359

 DBID 536511065 branch 890484819

FAL[client]: All defined FAL servers have been attempted.

重建備庫(kù)的控制文件:

SQL> ALTER DATABASE CREATE standby controlfile AS '/tmp/standby.ctl';   
Database altered.
[oracle@cwogg tmp]$ scp standby.ctl 172.16.30.228:/home/oracle/
oracle@172.16.30.228's password: 
standby.ctl                                                                     100%   10MB  10.1MB/s   00:00

[oracle@dg ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 21 11:40:43 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount;

ORACLE instance started.

Total System Global Area  835104768 bytes

Fixed Size    2257840 bytes

Variable Size  541068368 bytes

Database Buffers  289406976 bytes

Redo Buffers    2371584 bytes

RMAN> restore controlfile from '/home/oracle/standby.ctl';

Starting restore at 21-OCT-15

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=24 device type=DISK

channel ORA_DISK_1: copied control file copy

output file name=+DATA/mecbs/controlfile/control01.ctl

output file name=+DATA/mecbs/controlfile/control02.ctl

Finished restore at 21-OCT-15

RMAN> startup mount;

database is already started

database mounted

released channel: ORA_DISK_1

待續(xù),,,

分享文章:11gR2dataguard備庫(kù)文件損壞處理
文章源于:http://www.muchs.cn/article30/jpjjso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開(kāi)發(fā)全網(wǎng)營(yíng)銷推廣、App開(kāi)發(fā)品牌網(wǎng)站制作、定制網(wǎng)站、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開(kāi)發(fā)