Oracle學(xué)習(xí)之RMAN(三)全量備份-創(chuàng)新互聯(lián)

 我們已經(jīng)知道如何進(jìn)入rman,并連接到需要備份的數(shù)據(jù)庫(kù)上。那么如何使用rman備份,以及rman能備份哪些東西呢?

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),磐安企業(yè)網(wǎng)站建設(shè),磐安品牌網(wǎng)站建設(shè),網(wǎng)站定制,磐安網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,磐安網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
  • 備份數(shù)據(jù)庫(kù)

RMAN> backup database; Starting backup at 2015/07/08 00:58:27 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/devdb/system01.dbf input datafile file number=00002 name=/u01/app/oracle/oradata/devdb/sysaux01.dbf input datafile file number=00005 name=/u01/app/oracle/oradata/devdb/example01.dbf input datafile file number=00003 name=/u01/app/oracle/oradata/devdb/undotbs01.dbf input datafile file number=00006 name=/u01/app/oracle/oradata/devdb/idx01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/devdb/users01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/08 00:58:28 channel ORA_DISK_1: finished piece 1 at 2015/07/08 01:00:33 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T005827_bsr19n9z_.bkp tag=TAG20150708T005827 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:02:05 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 2015/07/08 01:00:34 channel ORA_DISK_1: finished piece 1 at 2015/07/08 01:00:35 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncsnf_TAG20150708T005827_bsr1flnq_.bkp tag=TAG20150708T005827 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 01:00:35
  • 備份表空間

RMAN> backup tablespace users ; Starting backup at 2015/07/08 01:59:43 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00004 name=/u01/app/oracle/oradata/devdb/users01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/08 01:59:43 channel ORA_DISK_1: finished piece 1 at 2015/07/08 01:59:44 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T015943_bsr4whv0_.bkp tag=TAG20150708T015943 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 01:59:44
  • 備份數(shù)據(jù)文件

RMAN> backup datafile '/u01/app/oracle/oradata/devdb/system01.dbf'; Starting backup at 2015/07/08 02:01:07 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/devdb/system01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:01:08 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:01:33 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T020108_bsr4z487_.bkp tag=TAG20150708T020108 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:01:34 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:01:35 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncsnf_TAG20150708T020108_bsr4zygn_.bkp tag=TAG20150708T020108 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 02:01:35

需要說明的一點(diǎn)時(shí),RMAN無法備份臨時(shí)文件。其實(shí)道理很簡(jiǎn)單,臨時(shí)文件根本沒有必要備份。

RMAN> backup datafile '/u01/app/oracle/oradata/devdb/temp01.dbf'; Starting backup at 2015/07/08 02:02:24 using channel ORA_DISK_1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup command at 07/08/2015 02:02:24 RMAN-20201: datafile not found in the recovery catalog RMAN-06010: error while looking up datafile: /u01/app/oracle/oradata/devdb/temp01.dbf RMAN> backup tempfile '/u01/app/oracle/oradata/devdb/temp01.dbf'; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "tempfile": expecting one of: "archivelog, as, auxiliary, backupset, backup, channel, check, controlfilecopy, copies, copy, cumulative, current, database, datafilecopy, datafile, db_file_name_convert, db_recovery_file_dest, device, diskratio, duration, filesperset, force, format, for, from, full, incremental, keep, maxsetsize, nochecksum, noexclude, nokeep, not, pool, proxy, recovery, reuse, section, skip readonly, skip, spfile, tablespace, tag, to, validate, (" RMAN-01007: at line 1 column 8 file: standard input
  • 備份控制文件

  1. 手工備份控制文件

RMAN> backup current controlfile; Starting backup at 2015/07/08 02:08:15 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:08:16 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:08:17 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncnnf_TAG20150708T020815_bsr5djdz_.bkp tag=TAG20150708T020815 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 02:08:17

2. INCLUDE CURRENT CONTROLFILE

RMAN> BACKUP DATAFILE '/u01/app/oracle/oradata/devdb/example01.dbf' INCLUDE CURRENT CONTROLFILE; Starting backup at 2015/07/08 02:13:22 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00005 name=/u01/app/oracle/oradata/devdb/example01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:13:22 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:13:29 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T021322_bsr5p2of_.bkp tag=TAG20150708T021322 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:13:30 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:13:31 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncnnf_TAG20150708T021322_bsr5pbv3_.bkp tag=TAG20150708T021322 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 02:13:31

無論進(jìn)行什么備份,只要在備份語句后面加上INCLUDE CURRENT CONTROLFILE,RMAN就會(huì)自動(dòng)備份controlfile 。

3. 通過配置RMAN的參數(shù),讓rman無論在做了何種備份時(shí)都會(huì)自動(dòng)備份controlfile。

RMAN> SHOW CONTROLFILE AUTOBACKUP; RMAN configuration parameters for database with db_unique_name DEVDB are: CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; new RMAN configuration parameters: CONFIGURE CONTROLFILE AUTOBACKUP ON; new RMAN configuration parameters are successfully stored RMAN> BACKUP DATAFILE '/u01/app/oracle/oradata/devdb/undotbs01.dbf'; Starting backup at 2015/07/08 02:18:38 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00003 name=/u01/app/oracle/oradata/devdb/undotbs01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:18:38 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:18:39 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T021838_bsr5zyb4_.bkp tag=TAG20150708T021838 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 02:18:39 Starting Control File and SPFILE Autobackup at 2015/07/08 02:18:39 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/autobackup/2015_07_08/o1_mf_s_884485119_bsr5zzrp_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2015/07/08 02:18:40

設(shè)置了CONTROLFILE AUTOBACKUP ON后,rman不光自動(dòng)備份控制文件,連spfile也一同被備份。

 如果你仔細(xì)留意備份時(shí)打印的信息,你就是會(huì)發(fā)現(xiàn)當(dāng)我們執(zhí)行backup database時(shí),即便CONTROLFILE AUTOBACKUP設(shè)置成off。rman也會(huì)自動(dòng)備份控制文件和spfile。因?yàn)槟J(rèn)情況下,rman把controlfile與spfile當(dāng)成是數(shù)據(jù)庫(kù)的一部分。

  • 備份歸檔日志

  1. 執(zhí)行backup archivelog命令

RMAN> backup archivelog all; Starting backup at 2015/07/08 02:36:09 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=16 RECID=7 STAMP=884486041 input archived log thread=1 sequence=17 RECID=8 STAMP=884486144 input archived log thread=1 sequence=18 RECID=9 STAMP=884486148 input archived log thread=1 sequence=19 RECID=10 STAMP=884486151 input archived log thread=1 sequence=20 RECID=11 STAMP=884486169 channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:36:09 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:36:10 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_annnn_TAG20150708T023609_bsr70spk_.bkp tag=TAG20150708T023609 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 02:36:10 Starting Control File and SPFILE Autobackup at 2015/07/08 02:36:10 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/autobackup/2015_07_08/o1_mf_s_884486170_bsr70v0k_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2015/07/08 02:36:11

2. 執(zhí)行backup命令時(shí),添加plus archivelog子句。

RMAN> backup database plus archivelog; Starting backup at 2015/07/08 02:41:08 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=16 RECID=7 STAMP=884486041 input archived log thread=1 sequence=17 RECID=8 STAMP=884486144 input archived log thread=1 sequence=18 RECID=9 STAMP=884486148 input archived log thread=1 sequence=19 RECID=10 STAMP=884486151 input archived log thread=1 sequence=20 RECID=11 STAMP=884486169 input archived log thread=1 sequence=21 RECID=12 STAMP=884486468 channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:41:08 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:41:09 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_annnn_TAG20150708T024108_bsr7b4wr_.bkp tag=TAG20150708T024108 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 02:41:09 Starting backup at 2015/07/08 02:41:09 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/devdb/system01.dbf input datafile file number=00002 name=/u01/app/oracle/oradata/devdb/sysaux01.dbf input datafile file number=00005 name=/u01/app/oracle/oradata/devdb/example01.dbf input datafile file number=00003 name=/u01/app/oracle/oradata/devdb/undotbs01.dbf input datafile file number=00006 name=/u01/app/oracle/oradata/devdb/idx01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/devdb/users01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:41:10 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:42:05 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T024110_bsr7b68z_.bkp tag=TAG20150708T024110 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55 Finished backup at 2015/07/08 02:42:05 Starting backup at 2015/07/08 02:42:05 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=22 RECID=13 STAMP=884486525 channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:42:05 channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:42:06 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_annnn_TAG20150708T024205_bsr7cxsd_.bkp tag=TAG20150708T024205 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/08 02:42:06 Starting Control File and SPFILE Autobackup at 2015/07/08 02:42:06 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/autobackup/2015_07_08/o1_mf_s_884486526_bsr7cz3l_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2015/07/08 02:42:07

這種方式與上種有什么區(qū)別呢,區(qū)別太明顯了,BACKUP.....PLUS ARCHIVELOG命令在備份過程中會(huì)依次執(zhí)行下列步驟:

1>.運(yùn)行ALTER SYSTEM ARCHIVE LOG CURRENT語句對(duì)當(dāng)前redolog進(jìn)行歸檔。

2>.執(zhí)行BACKUP ARCHIVELOG ALL命令備份所有已歸檔日志。

3>.執(zhí)行BACKUP命令對(duì)指定項(xiàng)進(jìn)行備份。

4>.再次運(yùn)行ALTER SYSTEM ARCHIVE LOG CURRENT對(duì)當(dāng)前redolog歸檔。

5>.對(duì)新生成的尚未備份的歸檔文件進(jìn)行備份。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)站名稱:Oracle學(xué)習(xí)之RMAN(三)全量備份-創(chuàng)新互聯(lián)
當(dāng)前URL:http://muchs.cn/article24/dcjjje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、品牌網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站營(yíng)銷、App設(shè)計(jì)、建站公司

廣告

聲明:本網(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í)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)