SYS@PROD>@/home/Oracle/con.sql
Control file created.
7,重建后数据库其实已经mount了,这时再打开数据库
SYS@PROD>alter database open;
Database altered.
8,查看表空间状态(没有异常)
SYS@PROD>select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS ONLINE
SYSAUX ONLINE
TEMP01 ONLINE
TEMP02 ONLINE
USERS ONLINE
TOOLS ONLINE
OLTP READ ONLY
MSSM ONLINE
9,将表空间置成read write出现报错,显示read only表空间的名字不对应
SYS@PROD>alter tablespace oltp read write;
alter tablespace oltp read write
*
ERROR at line 1:
ORA-01135: file 6 accessed for DML/query is offline
ORA-01111: name for data file 6 is unknown - rename to correct file
ORA-01110: data file 6: '/u01/app/oracle/product/10.2.1/db_1/dbs/MISSING00006'
10,查看文件位置确认,果然oltp表空间的位置改变了,这就是重建脚本中没有涉及只读表空间导致的后果,此时只需重新命名就行了
SYS@PROD>select file_name , tablespace_name from dba_data_files;
FILE_NAME TABLESPACE_NAME
------------------------------------------------------------ ---------------
/u01/app/oracle/oradata/PROD/disk1/mssm_01.dbf MSSM
/u01/app/oracle/oradata/PROD/disk1/tools_01.dbf TOOLS
/u01/app/oracle/oradata/PROD/disk1/users_01.dbf USERS
/u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf SYSAUX
/u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf UNDOTBS
/u01/app/oracle/oradata/PROD/disk1/system01.dbf SYSTEM
/u01/app/oracle/product/10.2.1/db_1/dbs/MISSING00006 OLTP
11,重新命名只读表空间
SYS@PROD>alter tablespace oltp rename datafile '/u01/app/oracle/product/10.2.1/db_1/dbs/MISSING00006' to '/u01/app/oracle/oradata/PROD/disk1/oltp_01.dbf';
Tablespace altered.
12,重新置为读写,重命名后的oltp表空间其实是出于offline状态的,直接read write还会报错的:
SYS@PROD>alter tablespace oltp read write;
alter tablespace oltp read write
*
ERROR at line 1:
ORA-01135: file 6 accessed for DML/query is offline
ORA-01110: data file 6: '/u01/app/oracle/oradata/PROD/disk1/oltp_01.dbf'
13,先online,再次尝试read write。
SYS@PROD>alter tablespace oltp online;
Tablespace altered.
SYS@PROD>alter tablespace oltp read write;
Tablespace altered.
成功完成oltp表空间的读写处理,可见如果需要使用trace脚本重建控制文件一定记住将只读表空间的信息加入其中,这样可以省去后续的步骤。
