ITPub博客

首页 > 数据库 > Oracle > 数据库恢复&迁移

数据库恢复&迁移

原创 Oracle 作者:bingmin259 时间:2015-05-23 20:59:01 0 删除 编辑
------------------------------------------
----backup database
The following example creates a level 0 incremental backup to serve as a base for an incremental backup strategy:
    BACKUP INCREMENTAL LEVEL 0 DATABASE;

The following example creates a level 1 cumulative incremental backup:
    BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;

The following example creates a level 1 differential incremental backup:
    BACKUP INCREMENTAL LEVEL 1 DATABASE;
-------------------------------------------
建立文件目录
mkdir -p /opt/oracle/admin/{adump,bdump,cdump,dump,pfile}
export ORACLE_SID=orcl;
rman target /

show all;
1.设置dbid

set dbid=12345;

2.启动到nomount状态
startup force nomount;

3.还原spfile文件
restore spfile from '/backup/C-2054617943-20110715-00';
restore spfile to 'path/spfile' from 'path/spfilebackup';

4.还原控制文件    
restore CONTROLFILE from 'path/filename';

5.启动到mount状态
alter database mount;

6.加载备份目录
CATALOG START WITH '/tmp/test';
CATALOG START WITH '/disk2/archlog' NOPROMPT;

7.列出备份集,找到控制文件识别的最大SCN号
list backup;

8.列出数据文件
report schema;

9.修改文件路径并还原数据库
RMAN> RESTORE DATABASE PREVIEW SUMMARY;  #还原预览

run  {
set newname for datafile 1 to '/oradata/orcl/SYSTEM01.DBF';
set newname for datafile 2 to '/oradata/orcl/UNDOTBS01.DBF';
set newname for datafile 3 to '/oradata/orcl/SYSAUX01.DBF';
set newname for datafile 4 to '/oradata/orcl/USERS01.DBF';
restore database;
switch datafile all;
}

10.确认logfile文件位置
SQL> select member from v$Logfile;

11.修改logfile文件路径
SQL> alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO01.LOG' to 'G:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO01.LOG';

SQL> alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO02.LOG' to 'G:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO02.LOG';

SQL> alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO03.LOG' to 'G:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO03.LOG';

SQL> alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\TEMP01.DBF' to 'G:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\TEMP01.DBF';

13.修复数据库文件
SQL> recover database until scn scn#;
或者:
SQL> recover database  until cancel using backup CONTROLFILE;
###输入CANCEL

或者:
SQL> RECOVER DATABASE UNTIL CHANGE RECOVERY_SCN + 1 USING BACKUP CONTROLFILE;

14.以resetlog方式打开数据库(只有mount状态下备份的数据文件才能做完全恢复)
SQL> alter database open resetlogs;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23604335/viewspace-1668847/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-03-27

  • 博文量
    9
  • 访问量
    18468