不彻底恢复:将数据库恢复到过去的某个时间点或者SCN点
1、实验环境
1.开归档
2.实验操做
create table scott.lxtb3 tablespace lxtb as select * from scott.emp;
insert into scott.lxtb3 select * from scott.emp where rownum <=3;
select count(1) from scott.lxtb3;
3.利用LOGMNR挖掘日志,找到对应操做的时间点和SCN
4.RMAN热备全库
2、备份恢复实验
1.不彻底恢复至某DML语句前
DML-查日志(v$log,v$logfile,v$archived_log)-logmnr找到操做的时间点和SCN-查数据文件-关库-RMAN不彻底恢复至指定SCN;
7159512 2015-11-05 14:04:21
RMAN> startup mount;
run{
set until scn 7159512;
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
alter database open resetlogs;
}
2.不彻底恢复至某DDL语句
DDL-查日志(v$log,v$logfile,v$archived_log)-logmnr找到操做的时间点和SCN-查数据文件-关库-RMAN不彻底恢复至指定时间点;
7159731 2015-11-05 14:16:42
RMAN> startup mount;
run{
set until time '2015-11-05 14:16:42';
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
alter database open resetlogs;
}
3.基于cancel不彻底恢复(容易出问题,实验前从新备份)
3DML-查当前日志序列值,最近归档,数据文件-断电-删全部数据文件,最近一部分归档日志,联机日志组因此成员-启
查-设置sequence还原恢复数据库-若是没法恢复,下降sequence值再执行恢复(可用归档加1的sequence值)
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
}
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/11/2015 02:53:12
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 13 lowscn 7196169 found to restore
RMAN-06025: no backup of log thread 1 seq 12 lowscn 7196139 found to restore
run{
set until sequence 13;
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
alter database open resetlogs;
}
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/11/2015 02:54:43
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 12 lowscn 7196139 found to restore
--再设成12,会用12之前的日志恢复,直到找到能够恢复的状态,恢复到12前的状态
run{
set until sequence 12;
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
alter database open resetlogs;
}
--人工辅助恢复
SQL> recover database until cancel;
ORA-00279: change 3654542 generated at 07/31/2015 09:52:56 needed for thread 1
ORA-00289: suggestion : /u01/arc_dir/1_4_886492614.dbf
ORA-00280: change 3654542 for thread 1 is in sequence #4
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
若是:
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 2 was not restored from a sufficiently old backup
ORA-01110: data file 2: '/u01/app/oracle/oradata/ipemsdb/datafile/o1_mf_undotbs1_bvodsj2v_.dbf'
--下降sequence后再人工辅助
SQL> recover database until cancel;
Media recovery cancelled.
SQL> alter database open resetlogs;sql
4.基于旧的控制文件恢复
备份-备份控制文件-3DML-删表空间和数据文件-查看表空间,数据文件信息,日志信息,归档信息-
logmnr分析drop时间-断电-rman-启nomount-还原控制文件-启mount-rman不彻底恢复-若是还不行recover until timme
using backup controlfile-auto-再恢复-给联机日志-open resetlogs
有未提交的操做表空间不能删除,删除表空间时系统会自动备份控制文件,全部注意控制文件的选择,表空间给恢复回来了
但是表没了。。。
RMAN> startup nomount
RMAN> restore controlfile from '/u01/app/backdir/rman/controlfile/c-2694191837-20150731-1f'; --转备份的
RMAN> alter database mount;
RMAN> report schema; --确认有须要的表空间
7201268 2015-11-11 04:11:40
run{
set until time '2015-11-11 04:11:40';
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
alter database open resetlogs;
}
run{
set until time '2015-11-11 04:11:40';
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
}数据库
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/31/2015 11:45:52
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 3658130服务器
recover database until time '2015-07-31 12:57:50' using backup controlfile;
auto
再次执行给日志
alter database open resetlogs;oracle
3、catalog库建立维护
恢复目录自己有一组视图,用于存放目标数据库与备份信息,能够保留更多的备份信息与方便的管理多个目标数据库
做用:记录rman生成备份的备份相关信息目标库控制文件信息,10G90,11G142保存多个表;
备份信息集中管理;
执行脚本
建立:另一台服务器,查表空间,数据文件信息,
建表空间,用户,密码文件,启动监听
建立表空间rc_data,一个库20M,参照库的多找设定表空间大小,
create tablespace rc_data datafile '/u01/app/oracle/oradata/ipemsdb/datafile/rc_data01.dbf' size 30M ;
建立user rc_damin
create user rc_admin identified by rc_admin default tablespace rc_data;
grant connect,resource to rc_admin;
赋权限角色recovery_catalog_owner
grant RECOVERY_CATALOG_OWNER to rc_admin;
alter user sys identified by oracle;
[oracle@redhat4_200 dbs]$ orapwd
[oracle@redhat4_200 dbs]$ orapwd file=orapwipemsdb password=oracle entries=3 force=y
[oracle@redhat4_200 dbs]$ sqlplus sys/oracle as sysdba
登录测试:
启监听 启动另外服务监听
联本机oracle 连动态的 互联
先联本机,再联对方机器
[oracle@redhat4 ~]$ sqlplus sys/oracle@ipemsdb as sysdba
[oracle@redhat4 ~]$ sqlplus sys/oracle@jg200 as sysdba
[oracle@redhat4_200 dbs]$ sqlplus sys/oracle@ipemsdb2 as sysdba
[oracle@redhat4_200 dbs]$ sqlplus sys/oracle@jg100 as sysdbaapp
[oracle@redhat4 ~]$ rman target sys/oracle@ipemsdb
[oracle@redhat4 ~]$ rman catalog rc_admin/rc_admin@jg200
RMAN> create catalog;
[oracle@redhat4 ~]$ rman target sys/oracle@ipemsdb catalog rc_admin/rc_admin@jg200
RMAN> register database;
SQL> conn rc_admin/rc_admin
Connected.
SQL> select * from tab;
SQL> select * from rc_database;
SQL> select file#,name from rc_datafile;ide
rman target sys/oracle@
rmna catalog rc_admin/rc_admin@
rc_admin 登录,查表
建立:
create catalog;
select * from rc_database;
rman target sys/oracle@ catalog rc_damin/rc_admin@
注册:
register database;
相关表及执行脚本:
rc_database;
rc_datfile;
rc_stored_script;
rc_stored_script_line;
print cript
run{execute script name}
恢复目录支持以下的命令
{CREATE|UPGRADE|DROP} CATALOG
{CREATE|DELETE|REPLACE|PRINT}
LIST INCARNATION
REGISTER DATABASE
REPORT SCHEMA AT TIME
RESET DATABASE
RESYNC CATALOG
RESYNC CATALOG命令
Resync能够同步数据库与恢复目录之间的信息,在实际状况下,rman通常能够自动同步。在以下状况下
须要同步数据库物理结构的改变;数据文件增长或者是改变大小;表空间删除;回滚段的建立与删除;每产生10个归档日志
RESET DATABASE命令
目标数据库resetlogs以后,须要从新设置恢复目录。Reset命令就用来从新设置恢复目录。
指定备份文件所在目录,此命令用于扫描整个目录的备份片或者归档日志文件等
catalog start with '/u02/database/SY5221_RMAN/20121013'; 测试