rman資料備份恢復學習筆記
昨天對rman資料備份恢復進行了總結,
分享一下。
常用的一些命令
list backup;
list expired backup;
report schema;
report need backup days 3;
report need backup;
report obsolete;
configure channel device type
-壓縮備份
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO COMPRESSED BACKUPSET;
RMAN> backup database plus archivelog skip inaccessible delete input;
>delete noprompt backup;
.......
RMAN-06207: WARNING: 2 objects could not be deleted for DISK channel(s) due
RMAN-06208: to mismatched status. Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects
RMAN-06211: ==========================
RMAN-06212: Object Type Filename/Handle
RMAN-06213: --------------- ---------------------------------------------------
RMAN-06214: Backup Piece /u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP
RMAN-06214: Backup Piece /u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP
RMAN> crosscheck backup;
using channel ORA_DISK_1
using channel ORA_DISK_2
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP recid=26 stamp=794756167
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP recid=27 stamp=794756198
Crosschecked 2 objects
RMAN> delete noprompt backup;
using channel ORA_DISK_1
using channel ORA_DISK_2
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
26 26 1 1 EXPIRED DISK /u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP
27 27 1 1 EXPIRED DISK /u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP
deleted backup piece
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/DATAFILE_BACKUP recid=26 stamp=794756167
deleted backup piece
backup piece handle=/u01/app/backup/orcl/pri/orcl_1/LOG_BACKUP recid=27 stamp=794756198
Deleted 2 objects
--增量備份
RMAN> backup incremental level=0 database;
backup incremental level=1 database;
db block change tracking
1.
SQL> alter database enable block change tracking using file '/u01/app/oracle/change_tracking';
Database altered.
2.show parameter db_create_file_dest
SQL> alter system set db_create_file_dest='/u01/app/oracle';
System altered.
SQL> alter database enable block change tracking ;
Database altered.
-rw-r----- 1 oracle dba 11600384 Oct 16 11:16 o1_mf_87sn9vws_.chg
[oracle@oel1 changetracking]$ pwd
/u01/app/oracle/ORCL/changetracking
[oracle@oel1 changetracking]$
[[oracle@oel1 orcl2]$ ps -ef | grep ora_| grep ctw
oracle 27639 1 0 14:11 ? 00:00:00 ora_ctwr_orcl
--rman configuration
RMAN> configure channel 2 device type disk format '/u01/app/oracle/backupset/2%U';
new RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/u01/app/oracle/backupset/2%U';
new RMAN configuration parameters are successfully stored
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 5;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backupset/ctl/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/app/oracle/backupset/%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/u01/app/oracle/backupset/2%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE ON;
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default
RMAN> configure channel device type disk clear;
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/app/oracle/backupset/%U';
old RMAN configuration parameters are successfully deleted
RMAN> configure channel 1 device type disk format '/u01/app/oracle/backupset/1%U';
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/u01/app/oracle/backupset/1%U';
new RMAN configuration parameters are successfully stored
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 5;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backupset/ctl/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/u01/app/oracle/backupset/1%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/u01/app/oracle/backupset/2%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE ON;
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default
或者使用
configure channel device type disk format '/u01/app/oracle/backupset/3%U';
錢包
1.Mkdir $ORACLE_BASE/admin/a/wallet
2. alter system set encryption key identified by Oracle123; --- wallet password
開啟錢包
3.alter system set encryption wallet identified by oracle;
歸檔丟失 ,backup database plus archive log 失敗
RMAN-06059: expected archived log not found,
solution1:
--crosscheck archivelog all
--list expired archivelog all;
--delete expired archivelog all;
soution2:
RMAN> change archivelog all crosscheck;
solution3:
crosscheck copy;
恢復
刪除線上檔案11
rm ....
alter tablespace tbs5 offline immediate;
RMAN> restore datafile 11;
Starting restore at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00011 to /u01/app/oracle/oradata/orcl2/dbs05.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/3_37nnt9ro_1_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 10/16/2012 13:44:09
ORA-19870: error reading backup piece /u01/app/oracle/3_37nnt9ro_1_1
ORA-19573: cannot obtain exclusive enqueue for datafile 11
solution1:
RMAN> run{
2> sql 'alter tablespace tbs5 offline immediate';
3> restore tablespace tbs5;
4> recover tablespace tbs5;
5> sql 'alter tablespace tbs5 online
6> ';
7> }
sql statement: alter tablespace tbs5 offline immediate
Starting restore at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
skipping datafile 2; already restored to file /u01/app/oracle/oradata/orcl/tbs5.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 16-OCT-12
Starting recover at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 16-OCT-12
sql statement: alter tablespace tbs5 online
solution2:
SQL> shutdown immediate
ORA-01116: error in opening database file 11
ORA-01110: data file 11: '/u01/app/oracle/oradata/orcl2/dbs05.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1220336 bytes
Variable Size 188743952 bytes
Database Buffers 327155712 bytes
Redo Buffers 7168000 bytes
Database mounted.
SQL> alter system set encryption wallet open identified by oracle;
System altered.
RMAN> restore datafile 11;
Starting restore at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00011 to /u01/app/oracle/oradata/orcl2/dbs05.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/3_37nnt9ro_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/3_37nnt9ro_1_1 tag=TAG20121016T133239
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 16-OCT-12
RMAN> recover datafile 11;
Starting recover at 16-OCT-12
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 16-OCT-12
SQL> alter database open;
Database altered.
--全庫恢復
unable to find archive log
archive log thread=1 sequence=75
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/16/2012 14:07:03
RMAN-06054: media recovery requesting unknown log: thread 1 seq 75 lowscn 683408
solution:
RMAN> run{
2> set until logseq 75;
3> restore database;
4> recover database;
5> alter database open resetlogs;
6> }
壞塊備份
RMAN> run{
2> set maxcorrupt for datafile 1 to 100;
3> backup tablespace tbs5;
4> }
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23718752/viewspace-746648/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- rman備份恢復-rman恢復資料檔案測試
- mysql學習筆記之備份與恢復MySql筆記
- INNOBACKUPEX的全備和增量備份恢復學習筆記筆記
- 【備份恢復】RMAN catalog 恢復目錄資料庫資料庫
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- rman資料庫全庫備份與恢復資料庫
- 非RMAN熱備份資料庫和恢復資料庫
- Oracle資料庫備份與恢復之RMANOracle資料庫
- RMAN備份恢復原理
- 【備份恢復】從備份恢復資料庫資料庫
- RMAN備份恢復——RAC環境資料庫的備份(zt)資料庫
- RMAN備份恢復--RAC環境資料庫的備份(十)資料庫
- RMAN備份恢復——RAC環境資料庫的備份(一)資料庫
- rman備份恢復-rman入門
- Mysql 企業級備份與恢復(學習筆記七)MySql筆記
- rman 搭建,備份,恢復基礎練習
- [記錄]oracle RMAN 備份恢復總結Oracle
- 用 RMAN 備份異機恢復 遷移資料
- influxdb 筆記: 備份/恢復UX筆記
- RMAN備份與恢復之加密備份加密
- 【原】Oracle學習系列—資料庫備份—RMAN備份Oracle資料庫
- oracle實驗記錄 (恢復-rman增量備份)Oracle
- ORACLE利用STANDBY端RMAN備份進行資料恢復Oracle資料恢復
- rman恢復資料庫--用備份的控制檔案資料庫
- Oracle資料庫備份與恢復之RMAN2Oracle資料庫
- 【備份恢復】資料恢復指導資料恢復
- rman備份筆記筆記
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- CUUG筆記--oracle備份和恢復筆記Oracle
- 備份與恢復:polardb資料庫備份與恢復資料庫
- 【備份恢復】Oracle 資料備份與恢復微實踐Oracle
- rman恢復--歸檔模式有備份,丟失資料檔案的恢復模式
- rman恢復--歸檔模式無備份,丟失資料檔案的恢復模式
- RMAN備份恢復效能優化優化
- rman備份恢復命令之switch
- RMAN備份恢復整個庫
- oracle RMAN 備份恢復總結Oracle
- oracle RMAN 備份恢復總結Oracle