知识要点
基本恢复
可以脱机的,在线恢复
linux>rm -f /u01/app/oracle/oradata/sky2/users01.dbf
RMAN>sql “alter tablespace users offline immeidiate”;
RMAN>restore tablespace users;
RMAN>recover tablespace users;
RMAN>sql “alter tablespace users online”;
不能脱机的,在mount阶段恢复
linux>rm -f /u01/app/oracle/oradata/sky2/undotbs01.db
RMAN> shutdown immediate
RMAN> startup mount;
RMAN>restore datafile ‘/u01/app/oracle/oradata/sky2/undotbs01.dbf’;
RMAN>recover datafile ‘/u01/app/oracle/oradata/sky2/undotbs01.dbf’;
RMAN>alter database open;
从指定文件恢复
RMAN>restore tablespace users from tag=’TAG20170703T163702’;
RMAN>recover tablespace users;
基于时间的恢复
设定日期格式
sqlplus>alter system set nls_date_format=’yyyy-mm-dd:hh24:mi:ss’ scope=spfile;数据库要处于mount阶段基于时间恢复,恢复到指定的时间,之后变化的数据就恢复不回去了,基本都不在本机做
run{
allocate channel a1 type disk;
allocate channel a2 type disk;
set until time = ‘2017-07-04:09:45:49’;
restore database;
recover database;
alter database open resetlogs;
release channel a1;
release channel a2;
}
数据文件重命名
重命名之后然后在从新数据文件恢复
run{
allocate channel a1 type disk;
sql ‘alter tablespace users offline’;
set newname for datafile ‘/u01/app/oracle/oradata/sky2/users01.dbf’ to ‘/u01/app/oracle/oradata/sky2/users.dbf’;
restore tablespace users;
switch datafile ‘/u01/app/oracle/oradata/sky2/users.dbf’;
recover tablespace users;
sql ‘alter tablespace users online’;
release channel a1;
}
恢复控制文件和参数文件
RMAN>restore controlfile from ”; RMAN>restore spfile from ”; RMAN>restore spfile to pfile ”;