oracle rman catalog
建立使用帶catalog的rman
大致步驟
1、 設定歸檔模式
2、 建立rman使用的表空間,建議300m
3、 建立rman使用的使用者並授權
4、 備份控制檔案,
alter database backup controlfile to trace
create pfile from spfile;
alter system set log_archive_dest_1='location=/archiverman' scope=spfile;
shutdown
startup mount
alter database archivelog;
alter database open;
create tablespace tbs_rman datafile '/opt/oracle/oradata/dba/tbs_rman.dbf' size 230m;
create user rman identified by rman default tablespace tbs_rman temporary tablespace temp;
grant recovery_catalog_owner to rman;
alter user rman quota unlimited on tbs_rman;
select * from session_privs;
select * from seesion_roles;
rman catalog
create catalog tablespace tbs_rman;
connect target
register database;
list backuoset; /*檢視備份集
list incarnation /*檢視化身
report schema; /*檢視庫結構
crosscheck backupset; /*檢視備份的有效性,EXPIRED
delete expired backupset;/*刪除過期的備份集
crosscheck copy; /*檢查copy
delete expired copy; /*刪除過期的copy
validate backupset; /*檢驗備份集是否能用。
delete expired backupset /*刪除過期的備份
crosscheck copy of archivelog all;
show all;
RMAN> configure controlfile autobackup on;
rman 可以做full,增量備份,備份單獨資料檔案等功能。
fullbackup 1
run{
2> allocate channel d1 device type disk; format'/opt/oracle/spfile.bak';
3> backup as compressed backupset
4> format '/opt/oracle/oradata/bak/full_%d%U'
5> tag='fullbak' including current controlfile;
6> channel=d1
7> database plus archivelog delete input;
8> }
fullbackup 2
RMAN> run {
2> allocate channel d1 device type disk;
3> backup as compressed backupset
4> format '/opt/oradata/oradata/rman/full_%d%U'
5> tag='fullbak'
6> channel=d1
7> database plus archivelog delete input;
8> }
incremental level=0
RMAN> run{
2> allocate channel d1 device type disk;
3> backup as compressed backupset
4> format='/opt/oradata/oradata/inc1_%d_%U'
5> tag='inc0'
6> incremental level=0
7> database;
8> }
bakcup datafile
RMAN> run{
2> allocate channel d1 device type disk;
3> backup as compressed backupset
4> format='/opt/oradata/oradata/df_%d_%U'
5> tag='dfile'
6> channel=d1
7> datafile 1;
8> }
backup arch from scn
run{
allocate channel d1 device type disk;
backup
format='/opt/oradtata/oradata/arch_%d_%U'
tag='arch'
channel=d1
archivelog from scn 1219672 ;
}
copy database
run{
allocate channel d1 device type disk;
backup as copy
format='/opt/oradata/oradata/copy_%d_%U'
tag='copybak'
database;
}
恢復規則:
nomount狀態:controlfile,all database file
mount狀態:system tablespace& online redo log file
mount、open狀態:non-system tbs & undo tbs
1、模擬丟失一個非system資料檔案。
刪除資料檔案,在資料庫裡alter database dataifle 4 online; 在rman 裡 report schema 可以看到file id
在rman裡輸入命令去恢復:
run{
allocate channel d1 devcie type disk;
sql "alter database datafile 4 offline"; ### 不執行這個,就會報獨佔錯誤。
restore datafile 4;
recover dataifle 4;
sql "alter database datafile 4 online";
}
2 模擬丟失undo資料檔案(undo不能offline,read-only)
sqlplus :
alter database offline;
alter database online;
rman:
run{
allocate channel d1 device type disk;
restore datafile 2;
recover datafile 2;
}
sql:select * from v$datafile;
recover datafile 2;
3 模擬系統表空間丟失:
首先把資料庫切換到mount狀態:
sql>startup mount force;
rman>run{
allocate channel d1 device type disk;
restore datafile 1;
recover datafile 1;
sql "alter database open";
}
4 控制檔案丟失:
sql:startup nomount force;
rman
run{
allocate channel d1 device type disk;
restore controlfile;
sql "alter database mount";
recover database;
sql "alter database open noresetlogs";
}
一個可以自動執行的指令碼:
[oracle@rac01 ~]$ ls
database fullbak.rcv full.sh
[oracle@rac01 ~]$ more full.sh
export ORACLE_BASE=/u01
export ORACLE_HOME=/u01/app/oracle
export ORACLE_SID=rac01
rman cmdfile = /home/oracle/fullbak.rcv
[oracle@rac01 ~]$ more fullbak.rcv
connect target /
run{
allocate channel d1 device type disk;
backup as compressed backupset
format '/u01/oradata/full_%d%U'
tag='fullbak'
channel=d1
database plus archivelog delete input;
}
[oracle@rac01 ~]$
大資料量的資料庫可能會碰到這樣的問題:由於某些原因造成本來該早上8點之前完成的備份沒有完成,結果造成正常業務造成很大影響。但是又不可能每天晚上看著本該自動執行的備份。
剛剛發現,原來rman有個duration引數可以使rman在指定時間無論完成與否都中止備份。
引用官方文件裡的例子:
For example, run the following command at 2:00 a.m. to specify that the backup
should run until 6:00 a.m.:
BACKUP
DURATION 4:00
TABLESPACE users;
繼續擴充套件 引數paptial和filesperset
BACKUP
DURATION 4:00 PARTIAL
TABLESPACE users
FILESPERSET 1;
上面的例子指定:每個檔案對應備份集,並且4小時備份如果沒有完成rman不會提示錯誤,而是提示哪個檔案還沒有備份,這樣一來可以手動將未備份的檔案重新備份。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/309902/viewspace-1048138/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 備份恢復篇之RMAN catalogOracle
- 揭秘ORACLE備份之----RMAN之五(CATALOG)Oracle
- Oracle Rman Catalog的建立方法和備份原理Oracle
- 備份恢復Lesson 04.Using the RMAN Recovery Catalog
- ORACLE rman與RMAN-00054&ORA-09945Oracle
- 【RMAN】Oracle rman 常用命令參考Oracle
- Oracle 19C DELETE_CATALOG_ROLE角色Oracledelete
- Oracle RMAN恢復測試Oracle
- Oracle RMAN備份實戰Oracle
- Oracle OCP(60):RMAN 備份Oracle
- Oracle 11G RAC複製備庫RMAN-03002 RMAN-05501 RMAN-03015 RMAN-03009 RMAN-10038Oracle
- 【RMAN】Oracle使用rman將11.2.0.4資料庫遷移至Oracle12c命令參考Oracle資料庫
- oracle手工建庫後rman無法啟用(RMAN-04015)Oracle
- Oracle rman duplicate遷移測試Oracle
- Oracle RMAN 表空間恢復Oracle
- 【RMAN】Oracle11g透過rman升級到12cOracle
- 2012-06-03 20:40 catalog start with rman備份集直接匯入控制檔案中
- Converting Oracle Database from Linux to Windows using RMANOracleDatabaseLinuxWindows
- oracle 12c rman備份pdbOracle
- 分享Oracle Rman的備份指令碼Oracle指令碼
- Oracle 12c RMAN全攻略Oracle
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- oracle rman 刪除過期的歸檔Oracle
- Oracle 12c系列(八)|RMAN (FROM SERVICE)Oracle
- ORACLE DG從庫 Rman備份恢復Oracle
- Oracle RMAN備份以及壓縮原理分析Oracle
- oracle10g RMAN增量備份策略Oracle
- 【Oracle19c】Oracle19c rman使用簡單測試Oracle
- Windows Server 2019 Oracle 19c RMAN Back DetailsWindowsServerOracleAI
- Oracle 12C新特性-RMAN恢復表Oracle
- Oracle RMAN 連線資料庫認證方法Oracle資料庫
- oracle資料庫使用rman備份指令碼Oracle資料庫指令碼
- Oracle 12C RMAN Cross-Platform Transport of PDBsOracleROSPlatform
- rman oracle11g_單機實用配置Oracle
- Oracle使用RMAN從Windows遷移資料到LinuxOracleWindowsLinux
- Oracle ADG環境下的RMAN備份策略Oracle
- Oracle Rman多通道故障轉移問題分析Oracle
- Oracle9i RMAN 的優缺點及RMAN 備份及恢復步驟Oracle
- rman duplicate建立異地auxiliary Database oracle_11g oracle_sid不同UXDatabaseOracle