ORACLE 資料庫 rman 全備份
阿新 • • 發佈:2019-01-27
環境:
源庫 10.17.80.190
目標庫 10.17.80.189
uid:ictdb
—-rman 異機備份過程———————————
【源庫】
1、準備:開啟歸檔模式
1、SQLPLUS / AS SYSDBA --登入資料庫 2、SQL>archive log list 檢視是否開啟歸檔模式 2、SQL> shutdown immediate; --關閉資料庫 3、SQL>startup mount; --將資料庫啟動到mount 狀態 4、SQL>alter database archivelog; --將資料庫置為歸檔模式 5、SQL>alter database open; --開啟資料庫 6、SQL>archive log list 檢視 7、SQL>alter system set log_archive_dest_1='location=/opt/oracle/archivelog' scope=spfile; 設定歸檔日誌目錄 --建立資料表(測試用的資料庫): create table mytables (name char(32),sex char(1),age int); insert into mytables values('tym','m','24'); insert into mytables values('tqq','f','25'); insert into mytables values('add','f','111'); insert into mytables values('from myoracle','f','0'); insert into mytables values('from 10.17.80.235','f','0');
2、備份:利用rman 備份控制檔案 ,全庫和歸檔日誌;
###CONFIGURE CONTROLFILE AUTOBACKUP ON;
run{
allocate channel d1 type disk;
allocate channel d2 type disk;
crosscheck backup;
crosscheck archivelog all;
sql 'alter system archive log current';
backup database format '/opt/oracle/rmanbackup/dbf/full__%d_%s_%p_%u.bak' ;
sql 'alter system archive log current';
backup current controlfile format '/opt/oracle/rmanbackup/control/control_%s_%p_%t';
backup archivelog all format '/opt/oracle/rmanbackup/dbf/archive_%t_%s' delete all input;
crosscheck backup;
release channel d2;
release channel d1;
}
3、遠端拷貝備份集到目標機
cd /opt/oracle/rmanbackup
scp -r * oracle@10.17.81.190:/opt/oracle/rmanbackup
【目標庫】
4 、圖形化介面建立跟源庫一樣的例項
root@oracle# xhost +
root@oracle# su - oracle
oracle@oracle$ export DISPLAY=:3.0
oracle@oracle$ dbca
然後安裝提示一步一步建立跟源庫一樣的例項
最後檢查相關目錄是否存在
配置系統環境 設定 $ORACLE_SID 跟源db的sid 一樣
5、建立密碼檔案: 認證的密碼檔案 (可選)
cd $ORACLE_HOME/bin
orapwd file=$ORACLE_HOME/dbs/orapwictdb password=oracle entries=8
cd $ORACLE_HOME/dbs
6、恢復引數檔案: 設定ORACLE_SID環境變數,設定DBID,在nomount狀態下,恢復引數檔案
RMAN>shutdown immediate;
RMAN>startup nomount;
RMAN>restore spfile to pfile '/opt/oracle/product/11gR1/db/dbs/initictdb.ora' from '/opt/oracle/rmanbackup/control/o1_mf_s_889366833_byf59l5x_.bkp';
7、恢復控制檔案: 設定ORACLE_SID環境變數,設定DBID,在nomount狀態下,恢復控制檔案
RMAN>restore controlfile from '/opt/oracle/rmanbackup/control/o1_mf_s_889366833_byf59l5x_.bkp';
8、註冊備份集
RMAN>startup mount;
RMAN>catalog start with "/opt/oracle/rmanbackup/dbf";
RMAN>catalog start with "/opt/oracle/rmanbackup/control";
9、恢復資料檔案: 設定ORACLE_SID環境變數,設定DBID,在mount 狀態下,恢復資料檔案;
RMAN>restore database;
RMAN>recover database;
RMAN>list incarnation;
會提示錯誤
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 18 and starting SCN of 7084319
解決:
RMAN> run {
set until scn 7084319 ;
restore database;
recover database;
alter database open resetlogs;
}
10、檢查資料是否恢復正常;