rman使用小記_第1頁
rman使用小記_第2頁
rman使用小記_第3頁
rman使用小記_第4頁
rman使用小記_第5頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、http:/download-1. Introduction to Recovery Manager3個(gè)重要的特點(diǎn):在線熱備不需要ALTER TABLESAPCE BEGIN BACKUP or END BACKUP,并且不會產(chǎn)生更多日志Incremental backups and restores. Can recover a NOARCHIVELOG database. However, only take incremental backups of a NOARCHIVELOG database after a consistent shutdown. 只備份HWM以下的blocks

2、檢測數(shù)據(jù)庫壞塊(interruption blocks), Computes checksums for each block during a backup其他作用:復(fù)制一個(gè)prd數(shù)據(jù)庫用來測試,建立或者備份一個(gè)standby dbTests whether files can be backed up or restored without actually performing the backup or restore.Overview of the RMAN EnvironmentRMAN executable (必須的)Target database (必須的)Recovery c

3、atalog database Media management software 2. Connecting to Databases with RMANStarting RMAN: Overview連接3種數(shù)據(jù)庫:% rman TARGET SYS/oracletrgt CATALOG rman/catcatdb -rman用戶需要RECOVERY_CATALOG_OWNER 角色% rman TARGET SYS/oracletrgt NOCATALOG -目標(biāo)數(shù)據(jù)庫用戶需要sysdba權(quán)限,因?yàn)槭悄J(rèn),所以不用額外注明as sysdba。NOCATALOG 是默認(rèn)形式,一旦使用了這種形

4、式,就不能在連接catalog了。% rman TARGET / CATALOG rman/catcatdb AUXILIARY SYS/oracleauxdb或者:% rmanRMAN CONNECT TARGET SYS/oracletrgtRMAN CONNECT CATALOG rman/catcatdb連接RAC(3個(gè)instance):% rman TARGET SYS/oracletrgt2 CATALOG rman/catcatdb CONFIGURE DEFAULT DEVICE TYPE TO sbt;CONFIGURE DEVICE TYPE sbt PARALLELIS

5、M 3;CONFIGURE CHANNEL 1 DEVICE TYPE sbt CONNECT = SYS/oracletrgt1;CONFIGURE CHANNEL 2 DEVICE TYPE sbt CONNECT = SYS/oracletrgt2;CONFIGURE CHANNEL 3 DEVICE TYPE sbt CONNECT = SYS/oracletrgt3;BACKUP DATABASE;3. Quick Start to Recovery Manager參考?/rdbms/demo/*.rcv RMAN基本命令(NOCATALOG mode)1. Connecting t

6、o the Target Database% rman target sys/admindonnydb22. 可以在rman中操作數(shù)據(jù)庫RMAN STARTUP MOUNT3. 產(chǎn)生schema reportsRMAN report schema;4. 備份數(shù)據(jù)庫有2中方式:full(all blocks. datafiles, controlfile, parameter file) 和 incremental(only the blocks that have changed since a previous backup)Full Backup:RMAN BACKUP DATABASE;

7、默認(rèn)device type 是disk,除非用configure 配置其到tape創(chuàng)建一個(gè)邏輯對象backup set, 包括多個(gè)backup pieceIncremental BackupRMAN BACKUP INCREMENTAL LEVEL 1 DATABASE;差異增量,累計(jì)增量。RMAN compares the current datafiles to a base backup, also called a level 0 backup, to determine which blocks to back up.0級增量和全備份不同,前者可以作為其他增量備份的基礎(chǔ)備份,而后者不

8、行。可能會發(fā)現(xiàn)有:no parent backup or copy of datafile 1 found;這說明datafile 1還沒有0級備份,rman會自動創(chuàng)建。5. 備份一個(gè)表空間RMAN BACKUP TABLESPACE SYSTEM;6. 備份歸檔日志RMAN BACKUP ARCHIVELOG ALL DELETE INPUT;因?yàn)閛racle不能直接將日志歸檔到tape,所以用rman將歸檔從disk備份到tape。如果指明delete input, rman會為每一個(gè)log seq num 備份一個(gè)copy,并且刪除disk上的文件。7. 拷貝數(shù)據(jù)文件datafilesR

9、MAN copy datafile 4 to d:oracleoradatadonnydb2bakhehe.dbf; 不用在關(guān)閉狀態(tài)嗎?這樣的拷貝是一致的嗎?8. Listing Backups and CopiesRMAN list backup;RMAN list copy;9. 檢測是否可以restore the backup, 而不用真正的restoreRMAN restore database validate;如果不報(bào)錯(cuò),就可以了。10. Restoring and Recovering the DatabaseRMAN RESTORE DATABASE;RMAN RECOVER

10、DATABASE;RMAN ALTER DATABASE OPEN;11. Restoring and Recovering a TablespaceRMAN SQL ALTER TALBESPACE tools OFFLINE IMMEDIATE;RMAN RESTORE TABLESPACE tools;RMAN RECOVER TABLESPACE tools;RMAN SQL ALTER TABLESPACE tools ONLINE;12. 查看RMAN 配置RMAN show all;返回到默認(rèn)配置,執(zhí)行CONFIGURE . CLEAR使用單獨(dú)的Recovery Catalog,

11、還是Nocatalog 模式(默認(rèn)模式,記錄在目標(biāo)數(shù)據(jù)庫controlfile 中)?當(dāng)管理多個(gè)數(shù)據(jù)庫時(shí),建議使用catalog。要注意平時(shí)對catalog的備份。好處如下:You can store RMAN scripts in the recovery catalog. When restoring and recovering to a time when the database files that exist in the database are different from the files recorded in the mounted control file, the

12、 recovery catalog specifies which files that are needed. Without a catalog, you must first restore a control file backup that lists the correct set of database files. If the control file is lost and must be restored from backup, and if persistent configurations have been made to automate the tape ch

13、annel allocation, these configurations are still available when the database is not mounted.RMAN periodically migrates information from the control file to the recovery catalog. 在哪里配置?4. Recovery Manager Architecture1. Overview of RMAN ArchitectureThe RMAN client application directs database server

14、sessions to perform all backup and recovery tasks.If more than one channel is allocated, then RMAN can execute certain commands in parallel so that all of the channels target database sessions are concurrently executing an RPC call. 2. RMAN Command Interface 存儲script:REPLACE SCRIPT b_whole_l0 # back

15、 up whole database and archived logs BACKUP INCREMENTAL LEVEL 0 TAG b_whole_l0 FILESPERSET 6 DATABASE PLUS ARCHIVELOG;執(zhí)行:RUN EXECUTE SCRIPT b_whole_10 ;查看:SQL SELECT * FROM rman.RC_STORED_SCRIPT;3. RMAN Repository 注冊DB:在catalog中注冊數(shù)據(jù)庫,registration。注冊多個(gè)數(shù)據(jù)庫時(shí),要求數(shù)據(jù)庫有不同的DBID,但允許有相同name的數(shù)據(jù)庫。如果通過os拷貝形成的新數(shù)據(jù)庫

16、,則與原來的db有相同的dbid。這是可以使用rman 的duplicate 命令注冊新db,或者使用DBNEWID改變dbid.同步recovery catalog:RMAN會自動檢測并執(zhí)行full / partial 同步。也可以執(zhí)行命令:RESYNC CATALOG;至少每CONTROL_FILE_RECORD_KEEP_TIME天,執(zhí)行一次。因?yàn)榭刂莆募牟糠中畔⑹侵芷诒籸eused,超過這個(gè)周期,控制文件中的部分信息有可能會被覆蓋??刂莆募杏袃刹糠謨?nèi)容:circular reuse records:Log history Archived redo logs Backups Off

17、line ranges for datafilesnoncircular reuse records:比如datafiles, online redo logs, and redo threads.對于Recovery Without a Catalog:建議Enable the control file autobackup feature,景象控制文件,Keep all Recovery Manager backup logs5. RMAN Concepts I: Channels, Backups, and Copies1. RMAN Automatic and Manual Chann

18、el Allocation什么是channel:Rman channel 代表傳輸?shù)侥硞€(gè)device type的數(shù)據(jù)流stream以及相應(yīng)的server session,每個(gè)channel對應(yīng)一個(gè)server session。根據(jù)如下配置自動分配channel:CONFIGURE DEVICE TYPE (DISK) PARALLELISM (3) -每次分配幾個(gè)channel;CONFIGURE DEFAULT DEVICE TYPE TO (DISK or SBT) 默認(rèn)device typeCONFIGURE CHANNEL DEVICE TYPE (DISK RATE 5M FORMA

19、T=?/oradata/%U MAXOPENFILES=20;) 模版CONFIGURE CHANNEL 3 DEVICE TYPE DISK MAXPIECESIZE = 900K; -某個(gè)channel的特別設(shè)置RMAN SHOW DEVICE TYPE; -查看或手工分配:RUN ALLOCATE CHANNEL c1 DEVICE TYPE sbt; ALLOCATE CHANNEL c2 DEVICE TYPE sbt; BACKUP DATAFILE 5,6;返回到默認(rèn)值:CONFIGURE DEVICE TYPE DISK CLEAR;2. Backup Sets邏輯概念,可以包

20、括1個(gè)或多個(gè)backup pieces(os 文件)。壓縮特點(diǎn):即只備份HWM以下的block,當(dāng)然數(shù)據(jù)文件鏡像是備份全部。BACKUP DATABASE;BACKUP TABLESPACE users, tools;BACKUP (SPFILE) (CURRENT CONTROL FILE);-備份spfile/controlfileBACKUP BACKUPSET 12;-備份backupsetBACKUP DATAFILECOPY /tmp/system01.dbf;-備份數(shù)據(jù)文件鏡像-備份歸檔日志:RMAN BACKUP ARCHIVELOG ALL DELETE INPUT;因?yàn)閛r

21、acle不能直接將日志歸檔到tape,所以用rman將歸檔從disk備份到tape。如果指明delete input, rman會為每一個(gè)log seq num 備份一個(gè)copy,并且刪除disk上的文件。Delete all input, like rman會刪除disk上符合條件的歸檔copy。恢復(fù)的時(shí)候,rman會自動將需要?dú)w檔從tape上restore到disk.-9i rman會搜索不同的achieve distinction, 如果有損壞,則備份其他目錄相應(yīng)文件:BACKUP ARCHIVELOG FROM SEQUENCE 121 UNTIL SEQUENCE 125;-如果不指

22、定until的話,rman會自動swich 當(dāng)前在線日志,并且backup 歸檔。實(shí)際上rman 執(zhí)行了ALTER SYSTEM ARCHIVE LOG CURRENT- plus archievelog 表示備份的數(shù)據(jù)文件可以被archivelog 恢復(fù)到一致狀態(tài),過程,類似于熱備:Runs ALTER SYSTEM ARCHIVE LOG CURRENTRuns BACKUP ARCHIVELOG ALL. Backs up the files specified in the BACKUP command. Runs ALTER SYSTEM ARCHIVE LOG CURRENT. B

23、acks up any remaining archived redo logs generated during backup.-如果設(shè)置了backup optimization, rman會跳過已經(jīng)備份的archivelogs- Multiplexed(多元)Backup Sets同時(shí)備份多個(gè)數(shù)據(jù)文件,并且混合在只含有一個(gè)backup piece的backup set中。FILESPERSET:一個(gè)backup set中包含幾個(gè)數(shù)據(jù)文件MAXOPENFILES:rman可以同時(shí)最多read幾個(gè)數(shù)據(jù)文件- Duplexed(復(fù)式的) Backup SetsBACKUP DEVICE TYPE

24、 DISK COPIES 3 DATAFILE 7 FORMAT /tmp/%U,?/oradata/%U,?/%U;復(fù)制3個(gè)copy,但是屬于同一個(gè)backup set-Parallelization of BackupsBACKUP (DATAFILE 1,2,3 FILESPERSET = 1 CHANNEL ORA_DISK_1) -3個(gè)backup sets (DATAFILECOPY /tmp/system01.dbf, /tmp/tools01.dbf FILESPERSET = 2 CHANNEL ORA_DISK_2) -1個(gè)backup sets (ARCHIVELOG F

25、ROM SEQUENCE 100 UNTIL SEQUENCE 102 THREAD 1 FILESPERSET = 3 CHANNEL ORA_DISK_3); -1個(gè)backup sets- Backups of Backup SetsBACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL; BACKUP BACKUPSET COMPLETED BEFORE SYSDATE-7 DELETE INPUT;- backup piece/sets的文件名,大小, I/O Rate自動生成或者,F(xiàn)ORMAT = /tmp/users_%u%p%c;MAXPIE

26、CESIZE限制每個(gè)piece的最大sizeMAXSETSIZE限制每個(gè)SET的最大sizeRate: 每秒讀取的bytes- 備份類型Full backup: 不是增量備份,只備份HWM之下的block。歸檔和控制文件備份所有blocks。區(qū)別于whole備份和0級備份(區(qū)別僅在于full不會被包括在增量策略中)。不影響其他的增量備份。Incremental Backups:只備份上一次增量備份后改變的blocks。需要一個(gè)full backup or incremental level 0 backup.Rman使用增量備份恢復(fù)的時(shí)候,不需要restore a base increment

27、al backup。比如可以restore一個(gè)non-incremental的image copies, rman可以用增量備份恢復(fù)文件。使用增量備份的原因:) 節(jié)省空間,網(wǎng)絡(luò)帶寬) 可以恢復(fù)通過nologging建立的對象(對比變化的數(shù)據(jù)塊)。) 減小noarchivelog數(shù)據(jù)庫的備份大小,不必每次都作whole備份。只能在正常關(guān)閉后作備份。增量備份種類:n級增量備份以下兩種情況) 差異增量(differential):備份最近一次n級或者更低級備份以來改變的blocks) 積累增量(cumulative):備份最近一次n-1級或者更低級備份以來改變的blocks。更傾向于這種備份,因?yàn)榛?/p>

28、復(fù)的時(shí)候只需要應(yīng)用到少量的增量備份集。原理:因?yàn)樵隽總浞菀残枰x取所有blocks以決定備份哪些blocks(通過比較當(dāng)前block的scn與父備份的scn作判斷),所以花費(fèi)的時(shí)間和full backup相當(dāng)。策略:比如full or level 0 backup monthly, level 1 weekly, level 2 daily.這樣每次恢復(fù)最多只需要一天的redo. 可以在有50數(shù)據(jù)塊改變后,作一次level 0;SELECT FILE#, INCREMENTAL_LEVEL, COMPLETION_TIME, BLOCKS, DATAFILE_BLOCKS FROM V$BAC

29、KUP_DATAFILE WHERE INCREMENTAL_LEVEL 0 AND BLOCKS / DATAFILE_BLOCKS .5 ORDER BY COMPLETION_TIME;比如只作了level1, 當(dāng)最近依次level 1的大小是level 0的50,則作一次level 0;Online:在線備份,不需要使用ALTER TABLESPACE BEGIN BACKUP命令。Rman使用不同的方法保證一致性。Closed: mounted but not open。分為一致和不一致兩種。Consistent: 正常關(guān)閉后,mount時(shí)作的備份Inconsistent: open

30、或者非正常關(guān)閉后,mount時(shí)作的備份。需要恢復(fù)到一致狀態(tài)。備份如下類型文件:Database, tablespace(除了locally-manged temporary tablespace),datefiles, cotrolfiles, archived logs, server parameter file, backup sets不備份如下類型文件:Online redo logs, Transported tablespaces before they have been made read/write, Client-side initialization parameter

31、files or noncurrent server parameter fileslocally-manged temporary tablespace3. backup errorNOT BACKED UP SINCE使得備份從出錯(cuò)處繼續(xù)。SET MAXCORRUPT允許最大的壞塊數(shù)。Rman將備份時(shí)碰到的壞塊reformat header并寫入backup set,同時(shí)在controfile中記錄。可以通過V$BACKUP_CORRUPTION and V$COPY_CORRUPTION查到。4. Control File and Server Parameter File 自動備份如果

32、CONFIGURE CONTROLFILE AUTOBACKUP on, 則在以下情況下自動備份:) 執(zhí)行backup or copy ) 在run中出現(xiàn)backup or copy) 當(dāng)數(shù)據(jù)庫結(jié)構(gòu)改變。建議CONFIGURE CONTROLFILE AUTOBACKUP FOR DEVICE TYPE DISK改變成非disk type) 備份datefile 1的時(shí)候?恢復(fù):RESTORE CONTROLFILE FROM AUTOBACKUP5. Backup 保留策略O(shè)bsolete means not needed, whereas expired means not found.C

33、ONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; 天內(nèi)保證恢復(fù)保證存在這樣的backup: SYSDATE - (SELECT CHECKPOINT_TIME FROM V$DATAFILE) = 7(互斥)CONFIGURE RETENTION POLICY TO REDUNDANCY 2;CONFIGURE RETENTION POLICY TO NONE; 關(guān)閉REPORT OBSOLETE 顯示過期備份DELETE OBSOLETE刪除過期備份(可以在每周的自動script中運(yùn)行)防止被標(biāo)記為obsolete:# exemp

34、ts the backup from retention policy until last day of 2002,不包括logBACKUP DATABASE KEEP UNTIL TIME TO_DATE(31-DEC-2002, dd-mon-yyyy) NOLOGS;# alters status of backup set 231 from KEEP to NOKEEP,可以被obsoleteCHANGE BACKUPSET 231 NOKEEP;# specifies that this backup and the logs required to recover it are indefinitely exempt # from the retention policy,不保留logs,說明備份一定是一致的備份。BACKUP TABLESPACE users KEEP FOREVER NOLOGS;6. Backup Optimization啟動備份優(yōu)化后,如果發(fā)現(xiàn)相同的文件已經(jīng)備份過,在不影響

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論