首页 > 数据库 > Oracle > 备份与恢复--一个表空间能否被多个数据库读写?
SQL> SELECT NAME FROM V$DATABASE;
NAME
---------
ORCL
SQL> alter tablespace users read write;
alter tablespace users read write
*
ERROR at line 1:
ORA-01256: error in locking database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'
再看看目标库的情况
SQL> SELECT NAME FROM V$DATABASE;
NAME
---------
JOLLY
SQL> alter tablespace users read write;
Tablespace altered.
SQL> select owner,table_name from all_tables where tablespace_name='TEST';
OWNER TABLE_NAME
------------------------------ ------------------------------
JGLU TEST1
SQL> insert into jglu.test1 select * from dba_objects where rownum<100;
99 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from jglu.test1;
COUNT(*)
----------
298
在目标数据库可以将表空间置为读写状态,而且可以顺利的写入数据。
在源库是否能看到目标库的修改数据?答案是不能
ORCL set sqlp 'ORCL>'
ORCL> select count(*) from jglu.test1;
COUNT(*)
----------
199
对于只读的表空间,Oracle肯定认为数据没有发生改变,现在得到的结果应该是从内存的CACHE返回的。尝
试将表空间置为OFFLINE,在置于ONLINE状态,使得内存中的CACHE过期,但是操作发现报错:
ORCL>alter tablespace users offline;
Tablespace altered.
ORCL>alter tablespace users online;
alter tablespace users online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'
看来目标数据库的独占锁导致了这个问题,那么先在目标数据库中将表空间置回只读状态:
SQL> set sqlp 'JOLLY>'
JOLLY>alter tablespace users read only;
Tablespace altered.
在源库再来online
ORCL>alter tablespace users online;
alter tablespace users online
*
ERROR at line 1:
ORA-01190: control file or data file 4 is from before the last RESETLOGS
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'
尝试recover,但是失败
ORCL>recover tablespace users;
ORA-00283: recovery session canceled due to errors
ORA-19909: datafile 4 belongs to an orphan incarnation
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'
尝试重建控制文件也无法恢复此表空间,因为此表空间的数据文件被两个数据库同时打开,而且目标数据库可以使用读写方式打开,但是这个数据文件对于源数据库来说已经发生了改变,在恢复时找到她原始的incarnation,一旦数据库重新加载这个文件就会出现异常。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/271283/viewspace-1016383/ ,如需转载,请注明出处,否则将追究法律责任。