1. 程式人生 > >RMAN配置

RMAN配置

ase 策略 lock lec ble dev goback ear span

$ rman target / rman target [email protected]

RMAN> show all;查看系統裏所有備份的配置

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP On;打開控制文件自動備份

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP clear; 恢復默認

RMAN> backup tablespace users;

RMAN> list backup;

SQL> desc v$backup_set 瀏覽器中也可以查看

自動通道管理:

RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2;

RMAN> backup tablespace users, example;

$ mkdir /home/oracle/disk1 /home/oracle/disk2

RMAN> configure channel 1 device type disk to destination ‘/home/oracle/disk1‘;

RMAN> configure channel 2 device type disk to destination ‘/home/oracle/disk2‘;

RMAN> backup tablespace users, example;

恢復默認

RMAN> CONFIGURE DEVICE TYPE DISK clear;

RMAN> CONFIGURE CHANNEL 1 device type disk clear;

RMAN> CONFIGURE CHANNEL 2 device type disk clear;

手動通道管理:

RMAN> run {

allocate channel c1 device type disk to destination ‘/home/oracle/disk1‘;

allocate channel c2 device type disk to destination ‘/home/oracle/disk2‘;

backup tablespace users, example;

backup (tablespace users channel c1)(tablespace example channel c2);

}

backup section size 500M datafile 1;

指定備份格式:

RMAN> backup tablespace users;生成標準備份集

RMAN> backup as compressed backupset tablespace users;生成壓縮備份集

RMAN> backup as copy tablespace users;生成鏡像文件備份集

RMAN> list backup of tablespace users;查看備份信息

RMAN> list copy of tablespace users;

備份的加密:

RMAN備份

不歸檔 歸檔

online offline online offline

完全部分完全部分完全部分完全部分

shutdown nomount mount open

Backup 備份 datafile 數據文件 tablespace表空間 database數據庫

備份數據文件:

SQL> select file_id, file_name from dba_data_files;

RMAN> backup datafile 4;

RMAN> backup datafile 4, 5;

RMAN> backup datafile ‘/u01/app/oracle/oradata/orcl/users01.dbf‘;

RMAN> backup tablespace users;

RMAN> backup tablespace users, example;逗號分隔

RMAN> backup database;

RMAN> list backup;

desc v$backup_set,瀏覽器查看備份

增量備份:

RMAN> backup incremental level 0 tablespace users;incremental 增量的 level固定的後面一定要跟上

RMAN> list backup of tablespace users;

SQL> create table t1(x int) tablespace users;

SQL> insert into t1 values (1);

SQL> commit;

RMAN> backup incremental level 1 tablespace users;

RMAN> backup incremental level 1 tablespace users;

SQL> create table t2(x int) tablespace users;

SQL> insert into t2 values (1);

SQL> commit;

RMAN> backup incremental level 1 cumulative tablespace users;

RMAN> list backup of tablespace users;

開啟塊跟蹤:

SQL> alter database enable block change tracking using file ‘/home/oracle/blk_trk.chg‘;

需要重新連接會話

SQL> select * from v$block_change_tracking;

SQL> select DATAFILE_BLOCKS, BLOCKS_READ, BLOCKS, USED_CHANGE_TRACKING from v$backup_datafile where INCREMENTAL_LEVEL>0;

SQL> create table t3(x int) tablespace users;

SQL> insert into t3 values (1);

SQL> commit;

RMAN> backup incremental level 1 tablespace users;

SQL> select DATAFILE_BLOCKS, BLOCKS_READ, BLOCKS, USED_CHANGE_TRACKING from v$backup_datafile where INCREMENTAL_LEVEL>0;

SQL> alter database disable block change tracking; 關閉

增量更新:

SQL> create table t1(x int) tablespace users;

SQL> insert into t1 values (1);

SQL> commit;

RMAN> backup incremental level 1 for recover of copy with tag ‘update_copy‘ tablespace users; 第一次創建的是0級備份

RMAN> list copy; 記錄timescn

SQL> insert into t1 values (2);

SQL> commit;

RMAN> backup incremental level 1 for recover of copy with tag ‘update_copy‘ tablespace users; 2次創建的是1級備份

RMAN> list backup; backupset格式

RMAN>recover copy of tablespace users with tag ‘update_copy‘;恢復

RMAN> list copy; timescn更新

腳本形式:

RMAN> run {

backup incremental level 1 for recover of copy with tag ‘update_copy‘ tablespace users;

recover copy of tablespace users with tag ‘update_copy‘;

}

備份歸檔日誌:

RMAN> list archivelog all;

RMAN> backup archivelog all delete all input;

RMAN>list archivelog all; 查看所有歸檔日誌

RMAN> list backup;

備份的維護:

查看:

RMAN> list backup;

RMAN> list copy;

RMAN> list backup of tablespace users;

RMAN> list backup of datafile 4;

RMAN> list archivelog all;

檢查備份:

RMAN> delete backup; 刪除備份 report:報告

RMAN> delete copy;

RMAN> list backup; list copy;

RMAN> report need backup; 根據策略檢查

RMAN> backup tablespace users;

RMAN> report need backup;

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

RMAN> report need backup;

RMAN> CONFIGURE RETENTION POLICY clear;

RMAN> report obsolete;

刪除備份:

RMAN> delete backupset of tablespace users;

RMAN> delete backupset 1234;

RMAN> backup tablespace users;

RMAN> backup tablespace users;

RMAN> show all;

RMAN> delete obsolete;

crosscheck:

RMAN> delete backup;

RMAN> backup tablespace users;

RMAN> list backup of tablespace users;

$ mv /u01/app/oracle/fast_recovery_area/ORCL/backupset/… 改名

RMAN> restore datafile 4; 報錯

RMAN> crosscheck backup;

RMAN> list backup of tablespace users; 報廢狀態

RMAN> list expired backup;

$ mv /u01/app/oracle/fast_recovery_area/ORCL/backupset/… 恢復原名

RMAN> crosscheck backup;

RMAN> list backup of tablespace users; 可用狀態

RMAN> delete expired backup;

catalog:

$ cp /u01/app/oracle/fast_recovery_area/ORCL/backupset/… 復制

RMAN> delete backup;

RMAN> list backup; backupset消失

$ mv /u01/app/oracle/fast_recovery_area/ORCL/backupset/… 恢復原名

RMAN> catalog recovery area noprompt;

RMAN> list backup; backupset恢復

RMAN配置