Create a rman recovery catalog in woods database, the recovery catalog store in tablespace RC_DATA with a file size 200m,
make sure the recovery catalog owner is RC_ADMIN password is same as username,
register the woods3、woods4 database with the catalog on woods,
backup woods3 database in ‘/u01/app/oracle/backup’ and keep forver
Turn on Flashback Database for woods database
Configure a flash recovery area of 4GB;
Put your flash recovery area in /home/oracle/flash;
Configure the flashback retention 48 hours
user scott create table a from table scott.emp
drop table a
user scott create table a from table scott.dept
drop table a
flashback table earlier a
flashback table later a rename to b
create a guaranteed restore point before_truncate;
truncate table hr.job_history
use flashback database to restore the hr.job_history table rows;
(1)Configure rman options for the woods database
1.1 turn backup optimazation on
1.2 set you default channel to write to /home/oracle/backup
1.3 turn on controlfile autobackup to write to /home/oracle/backup/control
1.4 configure retention window of 7 days
1.5 reduce the overheads of fast incremental backups to a minimum on the database
(2) Perform backup
2.1 perform a backup use default channel with compression algorithm ‘HIGH’
2.2 include all datafile in the backup
2.3 include current controlfile and spfile
2.4 include all archive logs than remive originals
2.5 section size 100m
2.6 backup TAG is "Q107"
删除了一个控制文件、删除了sys表空间文件、删除了一个redo文件
rman target /
startup nomount;
alter database mount;
list failure; (列出错误)
advise failure;(给出指导建议)
repair failure preview;(看一下脚本的内容)
repair failure;(进行修复)
创建表空间和用户 SQL> create tablespace RC_DATA datafile '/u01/app/oracle/oradata/woods/rc_data.dbf' size 200m ; SQL> create user RC_ADMIN identified by RC_ADMIN temporary tablespace temp default tablespace RC_DATA quota unlimited on RC_DATA; SQL> grant recovery_catalog_owner to RC_ADMIN;
创建catalog和注册 [oracle@ocm ~]$ rman catalog RC_ADMIN/RC_ADMIN; RMAN> create catalog; recovery catalog created
[oracle@ocm2 ~]$ rman target / catalog RC_ADMIN/RC_ADMIN@woods RMAN> register database; database registered in recovery catalog starting full resync of recovery catalog full resync complete |
备份: woods3要是归档的 /u01/app/oracle/backup路径要建 RMAN> backup database format '/u01/app/oracle/backup/%U' keep forever; |
(1)
[oracle@ocm ~]$ mkdir -p /home/oracle/flash SQL> alter system set db_recovery_file_dest_size=4g; SQL> alter system set db_recovery_file_dest='/home/oracle/flash'; SQL> alter system set db_flashback_retention_target=2880; SQL> shutdown immediate; SQL> startup mount; SQL> alter database flashback on; SQL> alter database open ; |
(2)
SQL> create table a as select * from emp; SQL> drop table a; SQL> create table a as select * from emp; SQL> drop table a; SQL> select OBJECT_NAME,DROPTIME from recyclebin; OBJECT_NAME DROPTIME ------------------------------ ------------------- BIN$MPC6Jqj5WOLgU6ABqMDTKw==$0 2016-04-20:13:49:16 BIN$MPC6Jqj6WOLgU6ABqMDTKw==$0 2016-04-20:13:49:22
SQL> flashback table "BIN$MPC6Jqj5WOLgU6ABqMDTKw==$0" to before drop; SQL> flashback table " BIN$MPC6Jqj6WOLgU6ABqMDTKw==$0" to before drop rename to b; |
(3)
SQL> create restore point before_truncate guarantee flashback database;
Restore point created.
SQL> select count(*) from hr.job_history;
COUNT(*) ---------- 10
SQL> truncate table hr.job_history;
Table truncated.
SQL> select count(*) from hr.job_history;
COUNT(*) ---------- 0
SQL> shutdown immediate; SQL> startup mount; SQL> flashback database to restore point before_truncate;
Flashback complete.
SQL> alter database open; alter database open * ERROR at line 1: ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open RESETLOGS;
Database altered.
SQL> select count(*) from hr.job_history;
COUNT(*) ---------- 10 |
(4).
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
TO_CHAR(SYSDATE,'YY ------------------- 2016-04-20 14:12:09
SQL> select count(*) from hr.job_history;
COUNT(*) ---------- 10
SQL> truncate table hr.job_history;
Table truncated.
SQL> select count(*) from hr.job_history;
COUNT(*) ---------- 0
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started.
Total System Global Area 1121554432 bytes Fixed Size 1344428 bytes Variable Size 771755092 bytes Database Buffers 335544320 bytes Redo Buffers 12910592 bytes Database mounted. SQL> flashback database to timestamp to_timestamp('2016-04-20 14:12:09','yyyy-mm-dd hh24:mi:ss');
Flashback complete.
SQL> alter database open; alter database open * ERROR at line 1: ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open RESETLOGS;
Database altered.
SQL> select count(*) from hr.job_history;
COUNT(*) ---------- 10 |
(1)
RMAN> CONFIGURE BACKUP OPTIMIZATION on; RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; [oracle@ocm ~]$ mkdir -p /home/oracle/backup
RMAN> CONFIGURE channel DEVICE TYPE DISK format '/home/oracle/backup/%U';
[oracle@ocm backup]$ mkdir -p /home/oracle/backup/control/ RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/backup/control/%F'; RMAN> CONFIGURE RETENTION POLICY TO recovery window of 7 days;
[oracle@ocm backup]$ mkdir -p /u01/app/oracle/tracking SQL> alter database enable block change tracking using file '/u01/app/oracle/tracking';
|
(2)
RMAN> CONFIGURE COMPRESSION ALGORITHM 'HIGH' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; RMAN> backup database section size 100m plus archivelog delete all input tag "Q107"; |
模拟错误
[oracle@ocm ~]$ rm /u01/app/oracle/oradata/woods/redo03.log [oracle@ocm ~]$ rm /u01/app/oracle/oradata/woods/system01.dbf [oracle@ocm ~]$ rm /u01/app/oracle/oradata/woods/control01.ctl |
[oracle@ocm ~]$ rman target / RMAN> startup nomount; RMAN> alter database mount;
using target database control file instead of recovery catalog RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 04/20/2016 15:55:36 ORA-00205: error in identifying control file, check alert log for more info
RMAN> list failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 1482 CRITICAL OPEN 20-APR-16 Control file /u01/app/oracle/oradata/woods/control01.ctl is missing
RMAN> advise failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 1482 CRITICAL OPEN 20-APR-16 Control file /u01/app/oracle/oradata/woods/control01.ctl is missing
analyzing automatic repair options; this may take some time allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=20 device type=DISK analyzing automatic repair options complete
Mandatory Manual Actions ======================== no manual actions available
Optional Manual Actions ======================= no manual actions available
Automated Repair Options ======================== Option Repair Description ------ ------------------ 1 Use a multiplexed copy to restore control file /u01/app/oracle/oradata/woods/control01.ctl Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/woods/woods/hm/reco_1736238564.hm
RMAN> repair failure preview;
Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/woods/woods/hm/reco_1736238564.hm
contents of repair script: # restore control file using multiplexed copy restore controlfile from '/u01/app/oracle/fast_recovery_area/woods/control02.ctl'; sql 'alter database mount';
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/woods/woods/hm/reco_1736238564.hm
contents of repair script: # restore control file using multiplexed copy restore controlfile from '/u01/app/oracle/fast_recovery_area/woods/control02.ctl'; sql 'alter database mount';
Do you really want to execute the above repair (enter YES or NO)? yes executing repair script
Starting restore at 20-APR-16 using channel ORA_DISK_1
channel ORA_DISK_1: copied control file copy output file name=/u01/app/oracle/oradata/woods/control01.ctl output file name=/u01/app/oracle/fast_recovery_area/woods/control02.ctl Finished restore at 20-APR-16
sql statement: alter database mount released channel: ORA_DISK_1 repair failure complete
RMAN> alter database open;
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 04/20/2016 15:58:17 ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: '/u01/app/oracle/oradata/woods/system01.dbf'
RMAN> list failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 1551 CRITICAL OPEN 20-APR-16 System datafile 1: '/u01/app/oracle/oradata/woods/system01.dbf' is missing 1545 CRITICAL OPEN 20-APR-16 Redo log group 3 is unavailable 1548 HIGH OPEN 20-APR-16 Redo log file /u01/app/oracle/oradata/woods/redo03.log is missing
RMAN> advise failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 1551 CRITICAL OPEN 20-APR-16 System datafile 1: '/u01/app/oracle/oradata/woods/system01.dbf' is missing 1545 CRITICAL OPEN 20-APR-16 Redo log group 3 is unavailable 1548 HIGH OPEN 20-APR-16 Redo log file /u01/app/oracle/oradata/woods/redo03.log is missing
analyzing automatic repair options; this may take some time allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=20 device type=DISK analyzing automatic repair options complete
Not all specified failures can currently be repaired. The following failures must be repaired before advise for others can be given.
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 1545 CRITICAL OPEN 20-APR-16 Redo log group 3 is unavailable 1548 HIGH OPEN 20-APR-16 Redo log file /u01/app/oracle/oradata/woods/redo03.log is missing
Mandatory Manual Actions ======================== no manual actions available
Optional Manual Actions ======================= 1. If file /u01/app/oracle/oradata/woods/redo03.log was unintentionally renamed or moved, restore it
Automated Repair Options ======================== Option Repair Description ------ ------------------ 1 Clear redo log group 3 Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/woods/woods/hm/reco_1082024053.hm
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/woods/woods/hm/reco_1082024053.hm
contents of repair script: # clear redo log group sql "begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/woods/woods/hm/reco_2663588251.hm'' ); end;";
Do you really want to execute the above repair (enter YES or NO)? yes executing repair script
sql statement: begin sys.dbms_ir.execsqlscript(filename => ''/u01/app/oracle/diag/rdbms/woods/woods/hm/reco_2663588251.hm'' ); end; repair failure complete
RMAN> alter database open;
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 04/20/2016 16:00:13 ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: '/u01/app/oracle/oradata/woods/system01.dbf'
RMAN> list failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 1551 CRITICAL OPEN 20-APR-16 System datafile 1: '/u01/app/oracle/oradata/woods/system01.dbf' is missing
RMAN> advise failure;
List of Database Failures =========================
Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 1551 CRITICAL OPEN 20-APR-16 System datafile 1: '/u01/app/oracle/oradata/woods/system01.dbf' is missing
analyzing automatic repair options; this may take some time using channel ORA_DISK_1 analyzing automatic repair options complete
Mandatory Manual Actions ======================== no manual actions available
Optional Manual Actions ======================= 1. If file /u01/app/oracle/oradata/woods/system01.dbf was unintentionally renamed or moved, restore it
Automated Repair Options ======================== Option Repair Description ------ ------------------ 1 Restore and recover datafile 1 Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/woods/woods/hm/reco_151033871.hm
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/woods/woods/hm/reco_151033871.hm
contents of repair script: # restore and recover datafile restore datafile 1; recover datafile 1; sql 'alter database datafile 1 online';
Do you really want to execute the above repair (enter YES or NO)? yes executing repair script
Starting restore at 20-APR-16 using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set …… Finished recover at 20-APR-16
sql statement: alter database datafile 1 online repair failure complete
Do you want to open the database (enter YES or NO)? yes database opened |