用户创建表空间时误将数据文件放到了本地盘,重启数据库时一个实例启动不了,只能offline该表空间后启动数据库。现用户想知道怎样能把这个表空间数据文件中的数据恢复出来。
测试目的:验证RAC中误将数据文件创建在本地盘时的修复办法
环境说明:
两节点RAC,数据库名为db10g 版本10.2.0.5
使用了ASM作为共享存储解决方案。
1,场景准备
1)节点2:创建表空间test1,数据文件不放到ASM,而是放到本地盘:
SQL> create tablespace test1 datafile '/home/Oracle/test1.dbf' size 10m;
Tablespace created.
SQL> select name,status from v$datafile;
NAME STATUS
----------------------------------------------------------- -----------------------
+DG/db10g/datafile/system.256.821723567 SYSTEM
+DG/db10g/datafile/undotbs1.258.821723569 ONLINE
+DG/db10g/datafile/sysaux.257.821723569 ONLINE
+DG/db10g/datafile/users.259.821723569 ONLINE
+DG/db10g/datafile/undotbs2.264.821723755 ONLINE
/home/oracle/test1.dbf ONLINE
6 rows selected.
2)节点2:在表空间test1中创建表没问题
SQL> create table test1 (id int) tablespace test1;
Table created.
SQL> create table test2 tablespace test1 as select * from dba_tables;
Table created.
3)节点1:能查到表空间test1,但创建表报错
SQL> select name ,status from v$datafile;
NAME STATUS
--------------------------------------------------------- ------------------
+DG/db10g/datafile/system.256.821723567 SYSTEM
+DG/db10g/datafile/undotbs1.258.821723569 ONLINE
+DG/db10g/datafile/sysaux.257.821723569 ONLINE
+DG/db10g/datafile/users.259.821723569 ONLINE
+DG/db10g/datafile/undotbs2.264.821723755 ONLINE
/home/oracle/test1.dbf ONLINE
6 rows selected.
SQL> create table test1 (id int) tablespace test1;
create table test1 (id int) tablespace test1
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/home/oracle/test1.dbf'
4)重启数据库,会发现节点1实例起不来,因为节点1无法读取节点2本地盘上的/home/oracle/test1.dbf
[oracle@rac10g2 ~]$ srvctl stop database -d db10g
[oracle@rac10g2 ~]$ srvctl start database -d db10g
PRKP-1001 : Error starting instance db10g1 on node rac10g1
CRS-0215: Could not start resource 'ora.db10g.db10g1.inst'.
[oracle@rac10g2 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.db10g.db application ONLINE ONLINE rac10g1
ora....g1.inst application ONLINE OFFLINE
ora....g2.inst application ONLINE ONLINE rac10g2
ora....SM1.asm application ONLINE ONLINE rac10g1
ora....G1.lsnr application ONLINE ONLINE rac10g1
ora....0g1.gsd application ONLINE ONLINE rac10g1
ora....0g1.ons application ONLINE ONLINE rac10g1
ora....0g1.vip application ONLINE ONLINE rac10g1
ora....SM2.asm application ONLINE ONLINE rac10g2
ora....G2.lsnr application ONLINE ONLINE rac10g2
ora....0g2.gsd application ONLINE ONLINE rac10g2
ora....0g2.ons application ONLINE ONLINE rac10g2
ora....0g2.vip application ONLINE ONLINE rac10g2
2,处理过程
由于该过程中需要从本地盘把数据文件迁移到ASM共享存储,ASM文件的访问无法通过操作系统级别直接进行。