1、恢复参数文件
设置环境变量:
export ORACLE_SID=hncdfhq
登录RMAN:
rman target /
在RMAN里把数据库起到nomount状态:
startup nomount;
设置DBID:
set dbid=3950123605
恢复spfile:
restore spfile from '/oradata2/backup/c-3950123605-20140616-05';
关闭数据库:
shutdown immediate;
把数据库起到nomount状态:
startup nomount;
2、恢复控制文件
通过spfile创建pfile
SQL> create pfile from spfile;
修改参数文件中控制文件的路径
关闭数据库
删除spfile或者重命名为别的名字
启动数据库到nomount状态
通过pfile创建spfile
关闭数据库
启动数据库到nomount状态
RMAN> restore controlfile from '/oradata2/backup/ctl_HNCDFHQ_20140616_195_1';
RMAN> alter database mount;
3、恢复数据文件
如果备份不在备份时所在的目录,在新的目录。
可以用此命令注册到控制文件。
RMAN> catalog start with '/oradata1/backup';
SQL> col name for a40
SQL> col file# for 999
SQL> set pagesize 999
SQL> select file#,name from v$datafile;
原来路径为 /oradata2/hncdfhq
现在要更改的路径为 /oradata2/oracle
run
{
ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
ALLOCATE CHANNEL dev2 DEVICE TYPE DISK;
set newname for datafile 1 to '/oradata2/oracle/system01.dbf';
set newname for datafile 2 to '/oradata2/oracle/undotbs01.dbf';
set newname for datafile 3 to '/oradata2/oracle/sysaux01.dbf';
set newname for datafile 4 to '/oradata2/oracle/users01.dbf';
set newname for datafile 5 to '/oradata2/oracle/rbsg_spc01.dbf';
set newname for datafile 6 to '/oradata2/oracle/rbsg_spc02.dbf';
set newname for datafile 7 to '/oradata2/oracle/rbsg_spc03.dbf';
set newname for datafile 8 to '/oradata2/oracle/rbsg_spc04.dbf';
set newname for datafile 9 to '/oradata2/oracle/rbsg_spc05.dbf';
set newname for datafile 10 to '/oradata2/oracle/rbsg_spc06.dbf';
set newname for datafile 11 to '/oradata2/oracle/rbsg_spc07.dbf';
set newname for datafile 12 to '/oradata2/oracle/rbsg_spc08.dbf';
set newname for datafile 13 to '/oradata2/oracle/rbsg_spc09.dbf';
set newname for datafile 14 to '/oradata2/oracle/rbsg_spc10.dbf';
set newname for datafile 15 to '/oradata2/oracle/rbsg_spc11.dbf';
set newname for datafile 16 to '/oradata2/oracle/data_spc01.dbf';
set newname for datafile 17 to '/oradata2/oracle/data_spc02.dbf';
set newname for datafile 18 to '/oradata2/oracle/data_spc03.dbf';
set newname for datafile 19 to '/oradata2/oracle/data_spc04.dbf';
set newname for datafile 20 to '/oradata2/oracle/data_spc05.dbf';
set newname for datafile 21 to '/oradata2/oracle/data_spc06.dbf';
set newname for datafile 22 to '/oradata2/oracle/data_spc07.dbf';
set newname for datafile 23 to '/oradata2/oracle/data_spc08.dbf';
set newname for datafile 24 to '/oradata2/oracle/data_spc09.dbf';
set newname for datafile 25 to '/oradata2/oracle/data_spc10.dbf';
set newname for datafile 26 to '/oradata2/oracle/indx_spc01.dbf';
set newname for datafile 27 to '/oradata2/oracle/indx_spc02.dbf';
set newname for datafile 28 to '/oradata2/oracle/indx_spc03.dbf';
set newname for datafile 29 to '/oradata2/oracle/indx_spc04.dbf';
set newname for datafile 30 to '/oradata2/oracle/indx_spc05.dbf';
restore database;
switch datafile all;
}
RMAN>recover database;
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/oradata2/hncdfhq/redo01.log
/oradata2/hncdfhq/redo02.log
/oradata2/hncdfhq/redo03.log
SQL> alter database rename file '/oradata2/hncdfhq/redo01.log' to '/oradata2/oracle/redo01.log';
SQL> alter database rename file '/oradata2/hncdfhq/redo02.log' to '/oradata2/oracle/redo02.log';
SQL> alter database rename file '/oradata2/hncdfhq/redo03.log' to '/oradata2/oracle/redo03.log';
更改临时表空间的位置
SQL> select ts.name,tf.name from v$tablespace ts ,v$tempfile tf
2 where ts.ts#=tf.ts#;
用操作系统命令移动文件
SQL> alter database rename file '/oradata2/hncdfhq/temp01.dbf' to '/oradata2/oracle/temp01.dbf';
SQL> alter database rename file '/oradata2/hncdfhq/temp_spc01.dbf' to '/oradata2/oracle/temp_spc01.dbf';
SQL> recover database using backup controlfile until cancel;
--选择redo的绝对路径,一个一个试,有多少组redo,就试多少次
SQL> alter database open resetlogs;