记录一个大致过程。
C:>sqlplus sys/system@test as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:08:22 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 167772160 bytes
Fixed Size 1247900 bytes
Variable Size 88081764 bytes
Database Buffers 75497472 bytes
Redo Buffers 2945024 bytes
数据库装载完毕。
数据库已经打开。
SQL> alter database backup controlfile to 'c:control01.ctl';
数据库已更改。
SQL> alter system set control_files='+DG' scope=spfile;
系统已更改。
SQL> alter system set db_recovery_file_dest='+DG';
系统已更改。
SQL> SHOW PARAMETER DB_RECOVERY
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +DG
db_recovery_file_dest_size big integer 2G
SQL> SHOW PARAMETER DB_NAME
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string TEST
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> exit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开
C:>rman target sys/system@test
恢复管理器: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:11:40 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已连接到目标数据库 (未启动)
RMAN> startup nomount
Oracle 实例已启动
系统全局区域总计 167772160 字节
Fixed Size 1247900 字节
Variable Size 88081764 字节
Database Buffers 75497472 字节
Redo Buffers 2945024 字节
RMAN> restore controlfile from 'c:control01.ctl';
启动 restore 于 11-10月-09
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=156 devtype=DISK
通道 ORA_DISK_1: 已复制控制文件副本
输出文件名=+DG/test/controlfile/current.271.699995579
完成 restore 于 11-10月-09
RMAN> alter database mount;
数据库已装载
释放的通道: ORA_DISK_1
RMAN> backup as copy database format '+DG';
启动 backup 于 11-10月-09
启动 implicit crosscheck backup 于 11-10月-09
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=152 devtype=DISK
完成 implicit crosscheck backup 于 11-10月-09
启动 implicit crosscheck copy 于 11-10月-09
使用通道 ORA_DISK_1
完成 implicit crosscheck copy 于 11-10月-09
搜索恢复区域中的所有文件
正在编制文件目录...
没有为文件编制目录
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件 fno=00001 name=C:ORADATATESTSYSTEM01.DBF
输出文件名 = +DG/test/datafile/system.272.699995623 标记 = TAG20091011T191342 re
cid = 1 时间戳 = 699995675
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:55
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件 fno=00002 name=C:ORADATATESTUNDOTBS01.DBF
输出文件名 = +DG/test/datafile/undotbs1.273.699995679 标记 = TAG20091011T191342
recid = 2 时间戳 = 699995699
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:25
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件 fno=00003 name=C:ORADATATESTSYSAUX01.DBF
输出文件名 = +DG/test/datafile/sysaux.274.699995705 标记 = TAG20091011T191342 re
cid = 3 时间戳 = 699995722
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:25
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件 fno=00004 name=C:ORADATATESTUSERS01.DBF
输出文件名 = +DG/test/datafile/users.275.699995729 标记 = TAG20091011T191342 rec
id = 4 时间戳 = 699995733
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:07
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件 fno=00005 name=C:ORADATATESTTEST.DBF
输出文件名 = +DG/test/datafile/test.276.699995737 标记 = TAG20091011T191342 reci
d = 5 时间戳 = 699995738
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:03
完成 backup 于 11-10月-09
RMAN-06497: 警告: 控制文件不是当前版本, 控制文件自动备份将被跳过
RMAN>
RMAN> recover database;
启动 recover 于 11-10月-09
使用通道 ORA_DISK_1
正在开始介质的恢复
存档日志线程 1 序列 22 已作为文件 C:ORADATATESTREDO01.LOG 存在于磁盘上
存档日志文件名 =C:ORADATATESTREDO01.LOG 线程 =1 序列 =22
介质恢复完成, 用时: 00:00:03
完成 recover 于 11-10月-09
RMAN> run{
2> switch tempfile 1 to '+DG';
3> }
临时文件 1 在控制文件中已重命名为 +DG
RMAN> EXIT
恢复管理器完成。
C:>sqlplus sys/system@test as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:18:35 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
C:ORADATATESTREDO01.LOG
C:ORADATATESTREDO02.LOG
C:ORADATATESTREDO03.LOG
SQL> alter database rename file 'C:ORADATATESTREDO01.LOG' to '+DG';
数据库已更改。
SQL> alter database rename file 'C:ORADATATESTREDO02.LOG' to '+DG';
数据库已更改。
SQL> alter database rename file 'C:ORADATATESTREDO03.LOG' to '+DG';
数据库已更改。
SQL> EXIT
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开
C:>rman target sys/system@test
恢复管理器: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:21:16 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已连接到目标数据库: TEST (DBID=1997875194, 未打开)
RMAN> exit
恢复管理器完成。
C:>sqlplus sys/system@test as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:21:32 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DG
+DG
+DG
SQL> exit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开
C:>rman target sys/system@test
恢复管理器: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:21:42 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已连接到目标数据库: TEST (DBID=1997875194, 未打开)
RMAN> alter database open resetlogs;
使用目标数据库控制文件替代恢复目录
数据库已打开
RMAN>
RMAN> exit
恢复管理器完成。
C:>sqlplus sys/system@test as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:24:08 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
--迁移之后居然发现数据文件没有使用asm中的而是继续使用了文件系统下的
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
C:ORADATATESTSYSTEM01.DBF
C:ORADATATESTUNDOTBS01.DBF
C:ORADATATESTSYSAUX01.DBF
C:ORADATATESTUSERS01.DBF
C:ORADATATESTTEST.DBF
SQL> exit
从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开
C:>sqlplus sys/system@test as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期日 10月 11 19:26:44 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 167772160 bytes
Fixed Size 1247900 bytes
Variable Size 88081764 bytes
Database Buffers 75497472 bytes
Redo Buffers 2945024 bytes
数据库装载完毕。
数据库已经打开。
--重启动之后问题依旧,仔细检查步骤,发现在执行backup as copy database format '+DG';
之后居然忘了之行:
switch database to copy;
--晕死了...
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
C:ORADATATESTSYSTEM01.DBF
C:ORADATATESTUNDOTBS01.DBF
C:ORADATATESTSYSAUX01.DBF
C:ORADATATESTUSERS01.DBF
C:ORADATATESTTEST.DBF
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DG/test/onlinelog/group_1.277.699996111
+DG/test/onlinelog/group_2.278.699996117
+DG/test/onlinelog/group_3.279.699996125
SQL>
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string +DG/test/controlfile/current.2
71.699995579
SQL> show parameter db_re
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +DG
db_recovery_file_dest_size big integer 2G
db_recycle_cache_size big integer 0
--无奈,只能通过重建controlfile来补救一下了...
SQL> alter database backup controlfile to trace;
数据库已更改。
SQL> shutdown immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup nomount
ORACLE 例程已经启动。
Total System Global Area 167772160 bytes
Fixed Size 1247900 bytes
Variable Size 88081764 bytes
Database Buffers 75497472 bytes
Redo Buffers 2945024 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS NOARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '+DG/test/onlinelog/group_1.277.699996111' SIZE 50M,
9 GROUP 2 '+DG/test/onlinelog/group_2.278.699996117' SIZE 50M,
10 GROUP 3 '+DG/test/onlinelog/group_3.279.699996125' SIZE 50M
11 -- STANDBY LOGFILE
12 DATAFILE
13 '+dg/test/datafile/SYSTEM.272.699995623',
14 '+dg/test/datafile/SYSAUX.274.699995705',
15 '+dg/test/datafile/TEST.276.699995737',
16 '+dg/test/datafile/UNDOTBS1.273.699995679',
17 '+dg/test/datafile/USERS.275.699995729'
18 CHARACTER SET ZHS16GBK
19 ;
CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS NOARCHIVELOG
*
第 1 行出现错误:
ORA-01503: CREATE CONTROLFILE ??
ORA-01189: ????????????? RESETLOGS
ORA-01517: ????: '+DG/test/onlinelog/group_1.277.699996111'
SQL> alter session set nls_language=american;
Session altered.
SQL> /
Session altered.
SQL> CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS NOARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '+DG/test/onlinelog/group_1.277.699996111' SIZE 50M,
9 GROUP 2 '+DG/test/onlinelog/group_2.278.699996117' SIZE 50M,
10 GROUP 3 '+DG/test/onlinelog/group_3.279.699996125' SIZE 50M
11 -- STANDBY LOGFILE
12 DATAFILE
13 '+dg/test/datafile/SYSTEM.272.699995623',
14 '+dg/test/datafile/SYSAUX.274.699995705',
15 '+dg/test/datafile/TEST.276.699995737',
16 '+dg/test/datafile/UNDOTBS1.273.699995679',
17 '+dg/test/datafile/USERS.275.699995729'
18 CHARACTER SET ZHS16GBK
19 ;
CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS NOARCHIVELOG
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-01189: file is from a different RESETLOGS than previous files
ORA-01517: log member: '+DG/test/onlinelog/group_1.277.699996111'
SQL> /
CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS NOARCHIVELOG
*
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-01189: file is from a different RESETLOGS than previous files
ORA-01517: log member: '+DG/test/onlinelog/group_1.277.699996111'
--由于数据文件和redo不是来自同一个版本,显然日志更新,所以无法使用noresetlogs创建controlfile
SQL> CREATE CONTROLFILE REUSE DATABASE "TEST" RESETLOGS NOARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '+DG/test/onlinelog/group_1.277.699996111' SIZE 50M,
9 GROUP 2 '+DG/test/onlinelog/group_2.278.699996117' SIZE 50M,
10 GROUP 3 '+DG/test/onlinelog/group_3.279.699996125' SIZE 50M
11 -- STANDBY LOGFILE
12 DATAFILE
13 '+dg/test/datafile/SYSTEM.272.699995623',
14 '+dg/test/datafile/SYSAUX.274.699995705',
15 '+dg/test/datafile/TEST.276.699995737',
16 '+dg/test/datafile/UNDOTBS1.273.699995679',
17 '+dg/test/datafile/USERS.275.699995729'
18 CHARACTER SET ZHS16GBK
19 ;
Control file created.
SQL> alter database open resetlogs;
Database altered.
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DG/test/datafile/users.275.699995729
+DG/test/datafile/undotbs1.273.699995679
+DG/test/datafile/test.276.699995737
+DG/test/datafile/sysaux.274.699995705
+DG/test/datafile/system.272.699995623
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DG/test/onlinelog/group_3.279.699996125
+DG/test/onlinelog/group_2.278.699996117
+DG/test/onlinelog/group_1.277.699996111
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string +DG/test/controlfile/current.2
71.699995579
SQL>show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string E:oracleproduct10.2.0db_1databaseSPFILETEST.ORA
SQL>
--处理spfile,把spfile也放入asm中管理
--===========================
ASMCMD> mkdir PARAMETER
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETER/
ASMCMD> pwd
+dg/test
ASMCMD>
--===========================
SQL> create pfile from spfile;
File created.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup pfile='E:oracleproduct10.2.0db_1databaseinittest.ora'
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1247900 bytes
Variable Size 92276068 bytes
Database Buffers 71303168 bytes
Redo Buffers 2945024 bytes
数据库装载完毕。
数据库已经打开。
SQL> create spfile='+dg/test/parameter/spfile.ora' from pfile;
文件已创建。
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
--编辑$ORACLE_HOME/database/inittest.ora文件,其内容为:
spfile='+dg/test/parameter/spfile.ora'
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 167772160 bytes
Fixed Size 1247900 bytes
Variable Size 92276068 bytes
Database Buffers 71303168 bytes
Redo Buffers 2945024 bytes
数据库装载完毕。
数据库已经打开。
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DG/test/parameter/spfile.ora
SQL>
oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html