RMAN常用命令

531968912發表於2017-04-06

RMAN是Oracle資料庫備份管理中必須用到的管理工具。它的操作方式有很多種,我整理了一些常用的操作命令,彙總起來,以方便工作。

 

(miki西遊 @mikixiyou 文件,原文連結: http://mikixiyou.iteye.com/blog/1560754 )

1 、備份資料庫操作命令

簡潔版

  backup database plus archivelog format '/backup/rman/xx_%U.%T';

 

正規版

run {

allocate channel t1 type disk;

backup database format '/backup/rman/xx_%U.%T';

backup archivelog all delete input format '/backup/rman/xx_%U.%T';

sql 'alter system archive log current';

backup current controlfile format '/backup/rman/xx_%U.%T';

release channel t1;

}

 

加強版

 

run

{

delete noprompt obsolete;

allocate channel ch01 type disk rate 40M;

backup database filesperset 3 format '/backup/servdb_rman/db_%U.%T';

sql 'alter system archive log current';

backup archivelog like '+%' filesperset 20 format '/backup/servdb_rman/archivelog_%U.%T';

delete noprompt archivelog until time 'sysdate -1';

backup current controlfile format '/backup/servdb_rman/ctl_%U.%T' ;

release channel ch01;

}

 

2 、歸檔日誌單獨備份操作命令

 

不刪除歸檔日誌檔案

run {

allocate channel t1 type disk;

backup archivelog all format '/backup/servdb_rman/archivelog_%U.%T';

release channel t1;

}

 

刪除歸檔日誌檔案

run {

allocate channel t1 type disk;

backup archivelog all delete input format '/backup/servdb_rman/archivelog_%U.%T';

release channel t1;

}

 

不備份已經備份過一次的歸檔日誌檔案

run {

allocate channel t1 type disk;

backup archivelog all not backed up 1 times format '/backup/servdb_rman/archivelog_%U.%T';

release channel t1;

}

 

3 、還原和恢復資料庫操作命令

 

完全恢復

startup nomount;

run {

  allocate channel  t1 type disk;

  restore controlfile;

  restore archivelog all;

  alter database mount;

  restore database;

  recover database;

  release channel t1;

}

sql 'alter database open resetlogs';

 

不完全恢復,至某個時間點

startup nomount;

run {

  set until time ="to_date('2012-06-14 00:00:00','yyyy-mm-dd hh24:mi:ss')";

  allocate channel  t1 type disk;

  restore controlfile;

  restore archivelog all;

  alter database mount;

  restore database;

  recover database;

  release channel t1;

}

sql 'alter database open resetlogs';

 

RAC 環境中還原某幾個歸檔日誌檔案

run

{

allocate channel t1 type disk;

restore archivelog from logseq  5023 thread 1 until logseq  5036 thread 1;

releaase channel t1;

}

 

單例項環境中還原某幾個歸檔日誌檔案

run

{

allocate channel t1 type disk;

restore archivelog from logseq  5023 until logseq  5036;

releaase channel t1;

}

 

4 、註冊備份集到 CATALOG 操作命令

catalog start with '/backup/xxx.xxx';

 

5 、其他管理命令

list backupset;

list backup of database;

list backup of archivelog all;

report obsolete;

report obsolete redundancy = 2;

delete obsolete;

restore database validate; 

report unrecoverable;

report schema;

crosscheck backup; 

delete expired backup; 

rman target sys/*****@ora10 catalog rman/rman@dbarep

 

allocate channel for maintenance device type disk;

delete obsolete redundancy = 4 device type disk; 

delete obsolete redundancy = 2 device type disk;

 

delete noprompt archivelog until time "sysdate-5"

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25462274/viewspace-2136759/,如需轉載,請註明出處,否則將追究法律責任。

相關文章