oracle利用scn增量備份來實現同步dataguard
環境:主庫和備庫形成oracle dataguard環境
實施目標:利用scn增量備份來實現同步dataguard
主要解決以下問題:
The steps in this section can used to resolve problems of missing or corrupted archive log file, an unresolveable archive gap, or need to roll standby forward in time without applying a large number of archivelog files.
1 :主庫不小心刪除歸檔,而這時歸檔還沒傳遞到備庫
2 :主庫由於資料變更生成大量的歸檔,而備庫不能及時應用,可能會導致幾天的延遲
3:主庫的歸檔檔案遭到破壞,導致備庫不能應用
步驟如下:
請嚴格按照以下步驟來實施:
1) Stop the managed recovery process (MRP) on the STANDBY database
停止備庫的日誌傳輸程式
alter database recover managed standby database cancel;
2) Determine the SCN of the STANDBY database.
查出備庫的最小scn號,用以下命令:
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
3164433
SQL> select min(f.fhscn) from x$kcvfh f, v$datafile d
where f.hxfil =d.file#
and d.enabled != 'READ ONLY' ;
MIN(F.FHSCN)
3162298 --這裡我們取3162298
3) Take an incremental backup of the PRIMARY database
在主庫執行以下命令實現增量備份:
RMAN> BACKUP INCREMENTAL FROM SCN 3162298 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
4) Transfer all backup sets to STANDBY server
傳輸主庫的增量備份檔案到備庫
scp /tmp/ForStandby_* standby:/tmp
5) Catalog the backups in STANDBY controlfile.
在備庫執行以下catalog命令,使得備庫控制檔案能夠識別到scn增量備份值
RMAN> CATALOG START WITH '/tmp/ForStandby';
List of Files Unknown to the Database
=====================================
File Name: /tmp/ForStandby_2lkglss4_1_1
File Name: /tmp/ForStandby_2mkglst8_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: /tmp/ForStandby_2lkglss4_1_1
File Name: /tmp/ForStandby_2mkglst8_1_1
6) Recover the STANDBY database with the cataloged incremental backup:
在備庫恢復增量備份集
RMAN> RECOVER DATABASE NOREDO;
starting recover at 03-JUN-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=28 devtype=DISK
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DATA/mystd/datafile/system.297.688213333
destination for restore of datafile 00002: +DATA/mystd/datafile/undotbs1.268.688213335
destination for restore of datafile 00003: +DATA/mystd/datafile/sysaux.267.688213333
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_2lkglss4_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/tmp/ForStandby_2lkglss4_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished recover at 03-JUN-09
7) In RMAN, connect to the PRIMARY database and create a standby control file backup:
主庫建立standby控制檔案
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/ForStandbyCTRL.bck';
8) Copy the standby control file backup to the STANDBY system.
從主庫庫複製standby控制檔案到備庫
scp /tmp/ForStandbyCTRL.bck standby:/tmp
9) Capture datafile information in STANDBY database.
獲取備庫的資料檔案資訊,以便和主庫的資料檔案資訊對比,包括路徑,是否不一致等
spool datafile_names_step8.txt
set lines 200
col name format a60
select file#, name from v$datafile order by file# ;
spool off
10) From RMAN, connect to STANDBY database and restore the standby control file:
備庫恢復從主庫複製過來的standby控制檔案
RMAN> SHUTDOWN IMMEDIATE ;
RMAN> STARTUP NOMOUNT;
RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/ForStandbyCTRL.bck';
Starting restore at 03-JUN-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output filename=+DATA/mystd/controlfile/current.257.688583989
Finished restore at 03-JUN-09
11) Shut down the STANDBY database and startup mount:
備庫關閉後啟動到mount狀態
RMAN> SHUTDOWN;
RMAN> STARTUP MOUNT;
12) Catalog datafiles in STANDBY if location/name of datafiles is different
如果備庫和主庫的資料檔案路徑不同,則需要用以下方法進行路徑改名
RMAN> CATALOG START WITH '+DATA/mystd/datafile/';
List of Files Unknown to the Database
=====================================
File Name: +data/mystd/DATAFILE/SYSTEM.309.685535773
File Name: +data/mystd/DATAFILE/SYSAUX.301.685535773
File Name: +data/mystd/DATAFILE/UNDOTBS1.302.685535775
File Name: +data/mystd/DATAFILE/SYSTEM.297.688213333
File Name: +data/mystd/DATAFILE/SYSAUX.267.688213333
File Name: +data/mystd/DATAFILE/UNDOTBS1.268.688213335
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +data/mystd/DATAFILE/SYSTEM.297.688213333
File Name: +data/mystd/DATAFILE/SYSAUX.267.688213333
File Name: +data/mystd/DATAFILE/UNDOTBS1.268.688213335
可以在主庫用以下sql,查出大於備庫scn後面主庫有沒有新增加資料檔案,如果有則參考Note 1531031.1
SQL>SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > 3162298
這裡的環境是沒有,則繼續往下走switch datafile:
RMAN> SWITCH DATABASE TO COPY;
datafile 1 switched to datafile copy "+DATA/mystd/datafile/system.297.688213333"
datafile 2 switched to datafile copy "+DATA/mystd/datafile/undotbs1.268.688213335"
datafile 3 switched to datafile copy "+DATA/mystd/datafile/sysaux.267.688213333"
13) Configure the STANDBY database to use flashback (optional)
如果備庫要配置flashback,則把它開啟,這步是可選的
SQL> ALTER DATABASE FLASHBACK OFF;
SQL> ALTER DATABASE FLASHBACK ON;
14) On STANDBY database, clear all standby redo log groups:
在備庫清除所有的standby redo log
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;
15) On the STANDBY database, start the MRP
追加完成,啟用日誌恢復
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
實施目標:利用scn增量備份來實現同步dataguard
主要解決以下問題:
The steps in this section can used to resolve problems of missing or corrupted archive log file, an unresolveable archive gap, or need to roll standby forward in time without applying a large number of archivelog files.
1 :主庫不小心刪除歸檔,而這時歸檔還沒傳遞到備庫
2 :主庫由於資料變更生成大量的歸檔,而備庫不能及時應用,可能會導致幾天的延遲
3:主庫的歸檔檔案遭到破壞,導致備庫不能應用
步驟如下:
請嚴格按照以下步驟來實施:
1) Stop the managed recovery process (MRP) on the STANDBY database
停止備庫的日誌傳輸程式
alter database recover managed standby database cancel;
2) Determine the SCN of the STANDBY database.
查出備庫的最小scn號,用以下命令:
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
3164433
SQL> select min(f.fhscn) from x$kcvfh f, v$datafile d
where f.hxfil =d.file#
and d.enabled != 'READ ONLY' ;
MIN(F.FHSCN)
3162298 --這裡我們取3162298
3) Take an incremental backup of the PRIMARY database
在主庫執行以下命令實現增量備份:
RMAN> BACKUP INCREMENTAL FROM SCN 3162298 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
4) Transfer all backup sets to STANDBY server
傳輸主庫的增量備份檔案到備庫
scp /tmp/ForStandby_* standby:/tmp
5) Catalog the backups in STANDBY controlfile.
在備庫執行以下catalog命令,使得備庫控制檔案能夠識別到scn增量備份值
RMAN> CATALOG START WITH '/tmp/ForStandby';
List of Files Unknown to the Database
=====================================
File Name: /tmp/ForStandby_2lkglss4_1_1
File Name: /tmp/ForStandby_2mkglst8_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: /tmp/ForStandby_2lkglss4_1_1
File Name: /tmp/ForStandby_2mkglst8_1_1
6) Recover the STANDBY database with the cataloged incremental backup:
在備庫恢復增量備份集
RMAN> RECOVER DATABASE NOREDO;
starting recover at 03-JUN-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=28 devtype=DISK
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DATA/mystd/datafile/system.297.688213333
destination for restore of datafile 00002: +DATA/mystd/datafile/undotbs1.268.688213335
destination for restore of datafile 00003: +DATA/mystd/datafile/sysaux.267.688213333
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_2lkglss4_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/tmp/ForStandby_2lkglss4_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished recover at 03-JUN-09
7) In RMAN, connect to the PRIMARY database and create a standby control file backup:
主庫建立standby控制檔案
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/ForStandbyCTRL.bck';
8) Copy the standby control file backup to the STANDBY system.
從主庫庫複製standby控制檔案到備庫
scp /tmp/ForStandbyCTRL.bck standby:/tmp
9) Capture datafile information in STANDBY database.
獲取備庫的資料檔案資訊,以便和主庫的資料檔案資訊對比,包括路徑,是否不一致等
spool datafile_names_step8.txt
set lines 200
col name format a60
select file#, name from v$datafile order by file# ;
spool off
10) From RMAN, connect to STANDBY database and restore the standby control file:
備庫恢復從主庫複製過來的standby控制檔案
RMAN> SHUTDOWN IMMEDIATE ;
RMAN> STARTUP NOMOUNT;
RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/ForStandbyCTRL.bck';
Starting restore at 03-JUN-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output filename=+DATA/mystd/controlfile/current.257.688583989
Finished restore at 03-JUN-09
11) Shut down the STANDBY database and startup mount:
備庫關閉後啟動到mount狀態
RMAN> SHUTDOWN;
RMAN> STARTUP MOUNT;
12) Catalog datafiles in STANDBY if location/name of datafiles is different
如果備庫和主庫的資料檔案路徑不同,則需要用以下方法進行路徑改名
RMAN> CATALOG START WITH '+DATA/mystd/datafile/';
List of Files Unknown to the Database
=====================================
File Name: +data/mystd/DATAFILE/SYSTEM.309.685535773
File Name: +data/mystd/DATAFILE/SYSAUX.301.685535773
File Name: +data/mystd/DATAFILE/UNDOTBS1.302.685535775
File Name: +data/mystd/DATAFILE/SYSTEM.297.688213333
File Name: +data/mystd/DATAFILE/SYSAUX.267.688213333
File Name: +data/mystd/DATAFILE/UNDOTBS1.268.688213335
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +data/mystd/DATAFILE/SYSTEM.297.688213333
File Name: +data/mystd/DATAFILE/SYSAUX.267.688213333
File Name: +data/mystd/DATAFILE/UNDOTBS1.268.688213335
可以在主庫用以下sql,查出大於備庫scn後面主庫有沒有新增加資料檔案,如果有則參考Note 1531031.1
SQL>SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > 3162298
這裡的環境是沒有,則繼續往下走switch datafile:
RMAN> SWITCH DATABASE TO COPY;
datafile 1 switched to datafile copy "+DATA/mystd/datafile/system.297.688213333"
datafile 2 switched to datafile copy "+DATA/mystd/datafile/undotbs1.268.688213335"
datafile 3 switched to datafile copy "+DATA/mystd/datafile/sysaux.267.688213333"
13) Configure the STANDBY database to use flashback (optional)
如果備庫要配置flashback,則把它開啟,這步是可選的
SQL> ALTER DATABASE FLASHBACK OFF;
SQL> ALTER DATABASE FLASHBACK ON;
14) On STANDBY database, clear all standby redo log groups:
在備庫清除所有的standby redo log
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;
15) On the STANDBY database, start the MRP
追加完成,啟用日誌恢復
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-2113506/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle之差異增量備份與累積增量備份Oracle
- Oracle RMAN 增量備份Oracle
- Oracle的差異增量備份和累積增量備份Oracle
- 基於data guard 增量scn的rman備份重新同步rolling forward物理備庫Forward
- linux 利用rsync實現檔案增量同步Linux
- Oracle的差異增量備份和累積增量備份(zt)Oracle
- Oracle 11g RMAN備份-增量備份Oracle
- mysql 利用binlog增量備份、恢復MySql
- oracle資料庫備份之exp增量備份Oracle資料庫
- oracle實驗記錄 (恢復-rman增量備份)Oracle
- Percona XtraBackup 實現全備&增量備份與恢復
- 使用RMAN增量更新備份實現快速還原
- oracle 增量備份恢復驗證Oracle
- ORACLE 11G透過SCN做增量備份修復standby庫詳細過程Oracle
- ORACLE 11G通過SCN做增量備份修復standby庫詳細過程Oracle
- Rman增量壓縮備份來解決備份空間不足
- oracle基於SCN增量恢復Oracle
- mysql利用binlog增量備份,還原例項MySql
- Mysql增量備份MySql
- 增量備份 PostgreSQLSQL
- oracle10g RMAN增量備份策略Oracle
- oracle聯機熱備份的原理,及rman增量備份原理Oracle
- Oracle聯機熱備份的原理及rman增量備份原理Oracle
- oracle scn與備份恢復backup recovery(一)Oracle
- 利用增量備份恢復gap歸檔丟失DG
- rman備份和增量備份指令碼指令碼
- oracle聯機熱備份的原理及rman增量備份原理(zt)Oracle
- Backup And Recovery User's Guide-RMAN備份概念-增量備份-累積增量備份GUIIDE
- Backup And Recovery User's Guide-RMAN備份概念-增量備份-差異增量備份GUIIDE
- Backup And Recovery User's Guide-RMAN備份概念-增量備份-多級增量備份GUIIDE
- LINUX下ORACLE增量備份的步驟LinuxOracle
- 實戰-MySQL定時增量備份(2)MySql
- 關於9i RMAN 增量備份中的資料塊SCN比較
- Backup And Recovery User's Guide-RMAN備份概念-增量備份-增量備份演算法GUIIDE演算法
- Oracle SCN機制———在備份與恢復中Oracle
- 完全備份、差異備份、增量備份的區別
- XtraBackup完整備份與增量備份的原理
- 使用RMAN增量備份處理Dataguard因歸檔丟失造成的gap