oracle之rman備份
本文中目錄資料庫和目標資料庫在不同的伺服器上,目錄資料庫sid=orcl2,目標資料庫sid=orcl
一 恢復目錄資料庫建立
1 資料庫安裝本文不作詳細敘述
2 建立表空間cattabs,大小為50MB
create tablespace cattabs datafile '/u01/app/oracle/oradata/orcl2/catdata01.dbf' size 50m autoextend on next 50m maxsize unlimited
3 建立儲存目錄的使用者
create user rman identified by rman
default tablespace cattabs
temporary tablespace temp;
alter user rman quota unlimited on cattabs;
4 為rman使用者授權,必須授予recovery_catalog_owner許可權
grant connect,resource to rman;
grant recovery_catalog_owner to rman;
5 啟動rman,在目錄與rman直接建立連線
rman
connect catalog rman/rman
6 建立恢復目錄
create catalog tablespace cattabs;
7 與目標資料庫建立連線
connect target sys@orcl
8 註冊目標資料庫
register database;
9 手動同步目標資料庫和目錄資料庫控制檔案
resync catalog;
10 帶catalog連線目標資料庫
rman target sys@orcl catalog rman/rman@orcl2
二 備份
備份指令碼
cat orabackup.sh
#!/bin/bash
TMP=/tmp;export TMP
TMPDIR=$TMP;export TMPDIR
ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME
ORACLE_SID=orcl;export ORACLE_SID
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
RMAN_LOG=${ORACLE_BASE}/flash_recovery_area/ORCL2/rman.log
SCRIPTS_PATH=${ORACLE_BASE}/backups/
TARGET_USER=sys
TARGET_PASSWORD=sys
CATALOG_USER=rman
CATALOG_PASSWORD=rman
WEEK=`date +%w`
#週日0級備份,週一週二週四週五週六2級備份,週三1級備份
case $WEEK in
0)
SCRIPTS_FILE=rman_level_0
;;
1|2|4|5|6)
SCRIPTS_FILE=rman_level_2
;;
3)
SCRIPTS_FILE=rman_level_1
;;
esac
nohup rman target ${TARGET_USER}/${TARGET_PASSWORD}@orcl catalog ${CATALOG_USER}/${CATALOG_PASSWORD}@orcl2 log=${RMAN_LOG} cmdfile=${SCRIPTS_PATH}${SCRIPTS_FILE} >/dev/null 2>&1 &
全備
cat rman_full
run{
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup full tag 'full' format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/full_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
0級備份
cat rman_level_0
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 0
tag 'inc0'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc0_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
1級備份
cat rman_level_1
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 1
tag 'inc1'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc1_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
2級備份
cat rman_level_2
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 2
tag 'inc2'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc2_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
一 恢復目錄資料庫建立
1 資料庫安裝本文不作詳細敘述
2 建立表空間cattabs,大小為50MB
create tablespace cattabs datafile '/u01/app/oracle/oradata/orcl2/catdata01.dbf' size 50m autoextend on next 50m maxsize unlimited
3 建立儲存目錄的使用者
create user rman identified by rman
default tablespace cattabs
temporary tablespace temp;
alter user rman quota unlimited on cattabs;
4 為rman使用者授權,必須授予recovery_catalog_owner許可權
grant connect,resource to rman;
grant recovery_catalog_owner to rman;
5 啟動rman,在目錄與rman直接建立連線
rman
connect catalog rman/rman
6 建立恢復目錄
create catalog tablespace cattabs;
7 與目標資料庫建立連線
connect target sys@orcl
8 註冊目標資料庫
register database;
9 手動同步目標資料庫和目錄資料庫控制檔案
resync catalog;
10 帶catalog連線目標資料庫
rman target sys@orcl catalog rman/rman@orcl2
二 備份
備份指令碼
cat orabackup.sh
#!/bin/bash
TMP=/tmp;export TMP
TMPDIR=$TMP;export TMPDIR
ORACLE_BASE=/u01/app/oracle;export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME
ORACLE_SID=orcl;export ORACLE_SID
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
RMAN_LOG=${ORACLE_BASE}/flash_recovery_area/ORCL2/rman.log
SCRIPTS_PATH=${ORACLE_BASE}/backups/
TARGET_USER=sys
TARGET_PASSWORD=sys
CATALOG_USER=rman
CATALOG_PASSWORD=rman
WEEK=`date +%w`
#週日0級備份,週一週二週四週五週六2級備份,週三1級備份
case $WEEK in
0)
SCRIPTS_FILE=rman_level_0
;;
1|2|4|5|6)
SCRIPTS_FILE=rman_level_2
;;
3)
SCRIPTS_FILE=rman_level_1
;;
esac
nohup rman target ${TARGET_USER}/${TARGET_PASSWORD}@orcl catalog ${CATALOG_USER}/${CATALOG_PASSWORD}@orcl2 log=${RMAN_LOG} cmdfile=${SCRIPTS_PATH}${SCRIPTS_FILE} >/dev/null 2>&1 &
全備
cat rman_full
run{
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup full tag 'full' format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/full_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
0級備份
cat rman_level_0
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 0
tag 'inc0'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc0_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
1級備份
cat rman_level_1
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 1
tag 'inc1'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc1_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
2級備份
cat rman_level_2
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 7;
allocate channel ch1 type disk;
backup incremental level 2
tag 'inc2'
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/rman_inc2_%T%t'
database include current controlfile;
sql 'alter system archive log current';
backup archivelog all
format '/u01/app/oracle/flash_recovery_area/ORCL/backupset/log/db_arch_%T_%U'
delete all input;
delete noprompt obsolete;
release channel ch1;
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27181165/viewspace-775866/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 揭秘ORACLE備份之----RMAN之五(CATALOG)Oracle
- Oracle 備份恢復篇之RMAN catalogOracle
- Oracle RMAN備份實戰Oracle
- Oracle OCP(60):RMAN 備份Oracle
- oracle 12c rman備份pdbOracle
- 分享Oracle Rman的備份指令碼Oracle指令碼
- ORACLE DG從庫 Rman備份恢復Oracle
- Oracle RMAN備份以及壓縮原理分析Oracle
- oracle10g RMAN增量備份策略Oracle
- 【RMAN】RMAN備份至ASMASM
- 【RMAN】Oracle12c之後,rman備份Dataguard備端恢復可能出現邏輯錯誤Oracle
- oracle資料庫使用rman備份指令碼Oracle資料庫指令碼
- Oracle ADG環境下的RMAN備份策略Oracle
- RMAN備份概述
- 【RMAN】RMAN的備份保留策略
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- Oracle Rman Catalog的建立方法和備份原理Oracle
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- RMAN備份進度
- rman 備份指令碼指令碼
- RMAN的備份原理
- oracle資料庫備份之exp增量備份Oracle資料庫
- Oracle9i RMAN 的優缺點及RMAN 備份及恢復步驟Oracle
- rman 增量備份恢復
- RMAN備份恢復技巧
- 【rman備份策略】實驗
- 【RMAN】Oracle中如何備份控制檔案?備份控制檔案的方式有哪幾種?Oracle
- Oracle 備份恢復之 FlashbackOracle
- Oracle RMAN備份為什麼會大量使用temp表空間?Oracle
- Windows oracle 11g rman備份恢復到linux系統WindowsOracleLinux
- 【RMAN】同時建立多個備份(建立多重備份)
- 【RMAN】在備庫執行rman備份時報錯RMAN-06820 ORA-17629
- RMAN備份詳解(轉載)
- [20190522]rman備份問題.txt
- RMAN 備份相關的概念
- 使用RMAN備份資料庫資料庫
- RMAN備份異機恢復
- ORACLE NBU調取oracle rman指令碼備份歸檔不自動刪除歸檔Oracle指令碼
- Oracle 12C RMAN備份佔用大量臨時表空間Oracle