ORACLE RAC資料庫的備份與恢復(3)
3、執行RAC資料庫的備份
基本上,RAC下建立備份任務,備份語句是不需要做什麼修改的,只要前面的準備工作都做好了(主要是歸檔檔案),那麼備份是會很順暢的。
首先來舉個例子,預設情況下直接執行備份,通過RMAN連線到任意結點執行,這裡我們在節點2端執行備份操作:
[oracle@jssdbn 2 ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on T hu Jan 2 11: 1 4:19 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: JSSDB (DBID=953576437)
RMAN> run{
2> allocate channel c0 device type disk format ¨/data/%U¨;
3> backup database plus archivelog ;
4> }
allocated channel: c0
channel c0: sid=146 instance=jssdbn2 devtype=DISK
.............................
.............................
RMAN-03002: failure of backup plus archivelog command at 01/28/2010 11:17:07
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /data/oradata/jssdbn1/archivelog/1_214_703671669.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3從提示資訊可以清晰的看出,錯誤的原因是找不到指定的歸檔檔案。實際上這裡的缺少不是沒有,而是說執行備份的節點上找不到這個歸檔,遇到這種問題,就可以按照1.2小節中提示的方法進行處理。
問題處理完之後,再次執行相同的備份指令碼:
RMAN> run{
2> allocate channel c0 device type disk format ¨/data/backup/%U¨;
3> backup database plus archivelog ;
4> }
using target database control file instead of recovery catalog
allocated channel: c0
channel c0: sid=147 instance=jssdbn2 devtype=DISK
Starting backup at 28-JAN-10
current log archived
archived log /data/oradata/jssdbn1/archivelog/1_214_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 214
archived log /data/oradata/jssdbn1/archivelog/1_215_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 215
archived log /data/oradata/jssdbn1/archivelog/1_216_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 216
archived log /data/oradata/jssdbn1/archivelog/1_217_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 217
archived log /data/oradata/jssdbn1/archivelog/1_218_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 218
archived log /data/oradata/jssdbn1/archivelog/1_219_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 219
archived log /data/oradata/jssdbn1/archivelog/1_220_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 220
archived log /data/oradata/jssdbn1/archivelog/1_221_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 221
archived log /data/oradata/jssdbn1/archivelog/1_222_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 222
archived log /data/oradata/jssdbn1/archivelog/2_80_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 2, sequence 80
channel c0: starting archive log backupset
channel c0: specifying archive log(s) in backup set
input archive log thread=1 sequence=214 recid=15 stamp=709470986
input archive log thread=1 sequence=215 recid=16 stamp=709470986
input archive log thread=1 sequence=216 recid=17 stamp=709470986
input archive log thread=1 sequence=217 recid=18 stamp=709470986
input archive log thread=1 sequence=218 recid=10 stamp=709386699
input archive log thread=1 sequence=219 recid=8 stamp=709377003
input archive log thread=1 sequence=220 recid=13 stamp=709470839
input archive log thread=1 sequence=221 recid=20 stamp=709471027
input archive log thread=1 sequence=222 recid=24 stamp=709471178
input archive log thread=2 sequence=80 recid=22 stamp=709471126
input archive log thread=2 sequence=81 recid=6 stamp=709351223
input archive log thread=2 sequence=82 recid=11 stamp=709423258
input archive log thread=2 sequence=83 recid=12 stamp=709470834
input archive log thread=2 sequence=84 recid=19 stamp=709471026
input archive log thread=2 sequence=85 recid=23 stamp=709471176
channel c0: starting piece 1 at 28-JAN-10
channel c0: finished piece 1 at 28-JAN-10
piece handle=/data/backup/01l4jaui_1_1 tag=TAG20100128T111946 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:16
Finished backup at 28-JAN-10
Starting backup at 28-JAN-10
channel c0: starting full datafile backupset
channel c0: specifying datafile(s) in backupset
input datafile fno=00003 name=+ASMDISK1/jssdb/datafile/sysaux.266.703671697
input datafile fno=00001 name=+ASMDISK1/jssdb/datafile/system.260.703671683
input datafile fno=00002 name=+ASMDISK1/jssdb/datafile/undotbs1.259.703671695
input datafile fno=00004 name=+ASMDISK1/jssdb/datafile/undotbs2.258.703671705
input datafile fno=00006 name=+ASMDISK1/jssdb/datafile/jsstbs.269.703779631
input datafile fno=00005 name=+ASMDISK1/jssdb/datafile/users.257.703671709
channel c0: starting piece 1 at 28-JAN-10
channel c0: finished piece 1 at 28-JAN-10
piece handle=/data/backup/02l4jav5_1_1 tag=TAG20100128T112005 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:25
channel c0: starting full datafile backupset
channel c0: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel c0: starting piece 1 at 28-JAN-10
channel c0: finished piece 1 at 28-JAN-10
piece handle=/data/backup/03l4javu_1_1 tag=TAG20100128T112005 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:03
Finished backup at 28-JAN-10
Starting backup at 28-JAN-10
current log archived
archived log /data/oradata/jssdbn1/archivelog/1_223_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 223
channel c0: starting archive log backupset
channel c0: specifying archive log(s) in backup set
input archive log thread=1 sequence=223 recid=26 stamp=709471235
input archive log thread=2 sequence=86 recid=28 stamp=709471236
channel c0: starting piece 1 at 28-JAN-10
channel c0: finished piece 1 at 28-JAN-10
piece handle=/data/backup/04l4jb05_1_1 tag=TAG20100128T112037 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:02
Finished backup at 28-JAN-10
released channel: c0一切順利,備份集建立成功。
不過,這裡隱含一個問題,通常我們習慣於在備份完歸檔之後刪除原歸檔檔案,以釋放相應的磁碟空間,不過在當前這個情況下,如果你嘗試清除歸檔的話,如無意外肯定會報錯,例如:
RMAN> delete archivelog sequence 214 thread 1;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=134 instance=jssdbn2 devtype=DISK
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
15 1 214 A 24-JAN-10 /data/oradata/jssdbn2/archivelog/1_214_703671669.dbf
1 1 214 A 24-JAN-10 /data/oradata/jssdbn1/archivelog/1_214_703671669.dbf
Do you really want to delete the above objects (enter YES or NO)? yes
deleted archive log
archive log filename=/data/oradata/jssdbn2/archivelog/1_214_703671669.dbf recid=15 stamp=709470986
Deleted 1 objects
RMAN-06207: WARNING: 1 objects could not be deleted for DISK channel(s) due
RMAN-06208: to mismatched status. Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects
RMAN-06211: ==========================
RMAN-06212: Object Type Filename/Handle
RMAN-06213: --------------- ---------------------------------------------------
RMAN-06214: Archivelog /data/oradata/jssdbn1/archivelog/1_214_703671669.dbf節點2端的歸檔成功刪除,可是節點1端生成的歸檔刪除報錯,覺著奇怪嗎?其實如果你稍稍開動一下腦筋,隨便動用幾十萬億個腦細胞就肯定能想明白這個事兒,沒錯,這裡報錯的原來就是節點2上操作不了節點1中的" /data/oradata/jssdbn1/archivelog/1_214_703671669.dbf " 這個檔案,你想說到節點1端去刪除?那也會有問題,因為節點1又操作不了節點2上的" /data/oradata/jssdbn2/archivelog/1_214_703671669.dbf " 這個檔案,咋整?我有辦法,用家樂濃湯寶吧,三碗水,一個雞湯口味。。。。Oo對不起對不起,最近廣告看多了。我真正想說的是,用RMAN中的通道吧。
插播內容:配置多通道連線不同例項,認真看,不是廣告。
可以通過configure預配置幾個通道(一般有幾個例項就配幾個通道),用來連線相應的例項,命令列如下:
RMAN> configure channel 1 device type disk connect ¨sys/123456@jssdbn1¨;
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT ¨*¨;
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1
RMAN> configure channel 2 device type disk connect ¨sys/123456@jssdbn2¨;
new RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT ¨*¨;
new RMAN configuration parameters are successfully storedConfigure channel 大家應該看著眼熟,有不認識的建議重溫" 一步一步學RMAN" ,或者瀏覽" 塗抹ORACLE--三思筆記第8章" ,關於connect子句簡單解釋兩句,後跟目標例項的使用者名稱密碼及網路服務名,這個網路服務名要確保執行備份的節點中確實進行了配置喲,不然該通道連線時肯定就會報錯了。
配置完成之後,檢視當前通道配置情況,應顯示如下:
RMAN> show channel;
RMAN configuration parameters are:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT ¨*¨;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT ¨*¨;而且這種方式還有一個好處,就是RMAN能夠智慧的對備份中出現"問題"的任務進行再分配,比如說通道1和通道2同時執行備份,其中通道1備份資料檔案134,通道2備份資料檔案2和5,假如通道2執行過程中由於某些原因崩潰,RMAN可以自動將任務放回到通道1上執行。
接下來,還有很重要的一步,啟動並行,並且至少要啟動"節點數量"個並行度。這樣的目的是為了RMAN在分配任務時,自動至少啟動多個通道並連線到相應的例項上,操作如下,例如我們這裡的雙節點RAC,就配置2個並行度:
RMAN> configure device type disk parallelism 2;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1這樣,當執行RMAN任務時,它就會根據任務所需,自動分配通道連線到適當例項,執行適當的操作。例如,再將從節點2端刪除214序號的歸檔檔案,操作如下:
RMAN> delete archivelog sequence 214;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=130 instance=jssdbn1 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=152 instance=jssdbn2 devtype=DISK
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
1 1 214 A 24-JAN-10 /data/oradata/jssdbn1/archivelog/1_214_703671669.dbf
Do you really want to delete the above objects (enter YES or NO)? yes
deleted archive log
archive log filename=/data/oradata/jssdbn1/archivelog/1_214_703671669.dbf recid=1 stamp=709219728
Deleted 1 objects成功刪除,這個成功也體現了分配通道後RMAN的智慧,它會根據配置給不同的通道分配不同的任務,這樣也就不用擔心節點路徑不同導致刪除任務的失敗了。
路障基本掃除,下面綜合來測試一下,執行指令碼如下:
RMAN> run{
allocate channel c0 device type disk format ¨/data/backup/%U¨;
backup database plus archivelog;
release channel c0;
}
allocated channel: c0
channel c0: sid=144 instance=jssdbn2 devtype=DISK
Starting backup at 03-FEB-10
current log archived
archived log /data/oradata/jssdbn1/archivelog/1_224_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 224
archived log /data/oradata/jssdbn1/archivelog/1_225_703671669.dbf not found or out of sync with catalog
.....................
........................
trying alternate file for archivelog thread 1, sequence 237
archived log /data/oradata/jssdbn1/archivelog/2_88_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 2, sequence 88
channel c0: starting archive log backupset
channel c0: specifying archive log(s) in backup set
input archive log thread=1 sequence=224 recid=64 stamp=709997627
input archive log thread=1 sequence=225 recid=65 stamp=709997630
............................
...............................
input archive log thread=2 sequence=97 recid=66 stamp=709997682
channel c0: starting piece 1 at 03-FEB-10
channel c0: finished piece 1 at 03-FEB-10
piece handle=/data/backup/05l53d3s_1_1 tag=TAG20100203T133451 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:36
Finished backup at 03-FEB-10
Starting backup at 03-FEB-10
channel c0: starting full datafile backupset
channel c0: specifying datafile(s) in backupset
input datafile fno=00003 name=+ASMDISK1/jssdb/datafile/sysaux.266.703671697
input datafile fno=00001 name=+ASMDISK1/jssdb/datafile/system.260.703671683
input datafile fno=00002 name=+ASMDISK1/jssdb/datafile/undotbs1.259.703671695
input datafile fno=00004 name=+ASMDISK1/jssdb/datafile/undotbs2.258.703671705
input datafile fno=00006 name=+ASMDISK1/jssdb/datafile/jsstbs.269.703779631
input datafile fno=00005 name=+ASMDISK1/jssdb/datafile/users.257.703671709
channel c0: starting piece 1 at 03-FEB-10
channel c0: finished piece 1 at 03-FEB-10
piece handle=/data/backup/06l53d53_1_1 tag=TAG20100203T133531 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:25
channel c0: starting full datafile backupset
channel c0: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel c0: starting piece 1 at 03-FEB-10
channel c0: finished piece 1 at 03-FEB-10
piece handle=/data/backup/07l53d5s_1_1 tag=TAG20100203T133531 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:03
Finished backup at 03-FEB-10
Starting backup at 03-FEB-10
current log archived
archived log /data/oradata/jssdbn1/archivelog/1_238_703671669.dbf not found or out of sync with catalog
trying alternate file for archivelog thread 1, sequence 238
channel c0: starting archive log backupset
channel c0: specifying archive log(s) in backup set
input archive log thread=1 sequence=238 recid=70 stamp=709997762
input archive log thread=2 sequence=98 recid=69 stamp=709997760
channel c0: starting piece 1 at 03-FEB-10
channel c0: finished piece 1 at 03-FEB-10
piece handle=/data/backup/08l53d64_1_1 tag=TAG20100203T133604 comment=NONE
channel c0: backup set complete, elapsed time: 00:00:02
Finished backup at 03-FEB-10
released channel: c0然後執行命令刪除所有已備份過的歸檔檔案,因為有預設通道的存在,因此這裡可以不用再分配通道了,直接執行如下:
RMAN> delete noprompt archivelog all backed up 1 times to device type disk;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=127 instance=jssdbn1 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=128 instance=jssdbn2 devtype=DISK
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
64 1 224 A 28-JAN-10 /data/oradata/jssdbn2/archivelog/1_224_703671669.dbf
.......................................
.........................................
66 2 97 A 03-FEB-10 /data/oradata/jssdbn2/archivelog/2_97_703671669.dbf
69 2 98 A 03-FEB-10 /data/oradata/jssdbn2/archivelog/2_98_703671669.dbf
deleted archive log
archive log filename=/data/oradata/jssdbn1/archivelog/1_224_703671669.dbf recid=30 stamp=709542410
deleted archive log
archive log filename=/data/oradata/jssdbn1/archivelog/1_225_703671669.dbf recid=32 stamp=709542491
.......................................
.........................................
deleted archive log
archive log filename=/data/oradata/jssdbn2/archivelog/2_97_703671669.dbf recid=66 stamp=709997682
deleted archive log
archive log filename=/data/oradata/jssdbn2/archivelog/2_98_703671669.dbf recid=69 stamp=709997760
Deleted 27 objects竣工!其它就不說了,上述執行的指令碼為RMAN備份的最核心指令碼,實際使用時可在此基本上進行相應的補充,比如增加備份型別、通道的設定、驗證備份集、清除過期備份、日誌輸出等等操作。這部分相關知識已有專門論述,在此不再重複,感興趣的朋友可以參考三思的著作“塗抹ORACLE--三思筆記” 一書第七章和第八章。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7607759/viewspace-631030/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復:polardb資料庫備份與恢復資料庫
- RAC備份恢復之Voting備份與恢復
- postgresql備份與恢復資料庫SQL資料庫
- 資料庫備份恢復資料庫
- 資料庫備份與恢復技術資料庫
- 將RAC備份集恢復為單例項資料庫單例資料庫
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫
- Oracle 備份 與 恢復 概述Oracle
- MySQL-19.資料庫備份與恢復MySql資料庫
- mongodb資料庫備份與恢復(資料庫資料遷移)MongoDB資料庫
- 備份與恢復:Polardb資料庫資料基於時間點恢復資料庫
- Mysql資料備份與恢復MySql
- Dedecms資料庫恢復與備份的兩種方法資料庫
- 淺談達夢資料庫的備份與恢復資料庫
- PostgreSql資料庫的備份和恢復SQL資料庫
- 備份與恢復oracle_homeOracle
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- Oracle資料庫冷備和恢復Oracle資料庫
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- ORACLE DG從庫 Rman備份恢復Oracle
- mysqldump使用方法(MySQL資料庫的備份與恢復)MySql資料庫
- RabbitMQ如何備份與恢復資料MQ
- Oracle 12c 備份與恢復Oracle
- Mongo 資料庫備份和恢復命令Go資料庫
- pg_dump 備份,恢復資料庫資料庫
- 資料庫資料恢復—無備份,binlog未開啟的Mysql資料庫資料恢復案例資料庫資料恢復MySql
- oracle drop table purge無備份bbed恢復(3/3)Oracle
- vivo 資料庫備份恢復系統演化資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- PG-pg_dump備份/恢復資料庫資料庫
- 【ASK_ORACLE】Oracle 12c之CDB與PDB的備份與恢復(二)備份恢復之前你需要知道的Oracle
- Oracle 9i統計資訊備份與恢復Oracle
- Oracle 備份恢復之 FlashbackOracle
- ORACLE備份&恢復案例(轉)Oracle
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- 如何在HarmonyOS對資料庫進行備份,恢復與加密資料庫加密
- 分散式文件儲存資料庫之MongoDB備份與恢復分散式資料庫MongoDB
- gitlab的資料備份和恢復Gitlab