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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux 利用rsync實現檔案增量同步Linux
- oracle資料庫備份之exp增量備份Oracle資料庫
- oracle基於SCN增量恢復Oracle
- oracle 增量備份恢復驗證Oracle
- LINUX下ORACLE增量備份的步驟LinuxOracle
- oracle10g RMAN增量備份策略Oracle
- 【DATAGUARD】Oracle Dataguard物理備庫切換最佳實踐(sqlplus)OracleSQL
- 用增量備份來快速恢復dg
- EXP增量備份
- Xtrabackup增量備份
- 使用RMAN增量備份處理Dataguard因歸檔丟失造成的gap
- 實戰-MySQL定時增量備份(2)MySql
- kettle 實現mysql單表增量同步MySql
- rman 增量備份恢復
- MySQL 定時增量備份MySql
- Oracle 之利用BBED修改資料塊SCN----沒有備份資料檔案的資料恢復Oracle資料恢復
- 【RMAN】Oracle12c之後,rman備份Dataguard備端恢復可能出現邏輯錯誤Oracle
- 【DATAGUARD】Dataguard遠端同步配置最佳實踐
- 東商專案mysql例項庫(dingding)增量備份的實現MySql
- Oracle RMAN備份實戰Oracle
- [20221020]奇怪的增量備份.txt
- Oracle dataguard failover 實戰OracleAI
- Oracle:SCNOracle
- PostgreSQL12中實現增量備份與任意時間點恢復SQL
- Oracle DataGuard 主備切換 (switchover) oracle11gOracle
- 從dataguard備份的恢復機制
- 利用Docker容器實現代理轉發和資料備份Docker
- 【SCN】Oracle SCN 詳細介紹Oracle
- 【Xtrabackup】Xtrabackup全備、增量備份及恢復示例
- mysqldump全量備份+mysqlbinlog二進位制日誌增量備份MySql
- 【SCN】Oracle推薦scn命令參考Oracle
- 【SCN】Oracle檢查scn值指令碼Oracle指令碼
- windows 全量+增量備份指令碼batWindows指令碼BAT
- ORACLE 備份表Oracle
- Oracle SCN詳解Oracle
- ORACLE -詳解SCNOracle
- 【DATAGUARD】Oracle Dataguard nologging 塊修復Oracle
- ORACLE備份策略(轉)Oracle
- ORACLE備份指令碼Oracle指令碼