Wednesday, April 30, 2008

Temporary file problem for RMAN refresh (clone)

After using RMAN backup clone(refresh) a database, the temporary files don't work appropriatedly.

SQL> select file_name, tablespace_name from dba_temp_files;select file_name, tablespace_name from dba_temp_files *ERROR at line 1:ORA-01187: cannot read from file 1025 because it failed verification testsORA-01110: data file 1025: '/dcps01/oradata/fake/temp01.dbf'

Cause: This is because the previous temparary datafiles are there when refreshing. Note it's not a problem if the regular datafiles are there. RMAN will just overwrite existing datafiles. But for the temporay files, RMAN will skip it and give the above error.

Solution: Drop the temporary file and recreate them.

SQL> select name from v$tempfile;
NAME--------------------------------------------------------------------------------/dcps01/oradata/fake/temp01.dbf/dcps01/oradata/fake/pstemp01.dbf
SQL> alter database tempfile '/dcps01/oradata/fake/temp01.dbf' drop including datafiles;
Database altered.
SQL> alter database tempfile '/dcps01/oradata/fake/pstemp01.dbf' drop including datafiles;
Database altered.
SQL> alter tablespace temp add tempfile '/dcps01/oradata/fake/temp01.dbf' size 500M autoextend on next 100M maxsize 2048M;alter tablespace temp add tempfile '/dcps01/oradata/fake/temp01.dbf' size 500M autoextend on next 100M maxsize 2048M*ERROR at line 1:ORA-01119: error in creating database file '/dcps01/oradata/fake/temp01.dbf'ORA-27038: created file already existsAdditional information: 1
SQL> !rm /dcps01/oradata/fake/temp01.dbf
SQL> !rm /dcps01/oradata/fake/pstemp01.dbf
SQL> /
Tablespace altered.
SQL> alter tablespace pstemp add tempfile '/dcps01/oradata/fake/pstemp01.dbf' size 2048M;
Tablespace altered.
SQL> select file_name, bytes/1024/1024, tablespace_name from dba_temp_files;
FILE_NAME BYTES/1024/1024---------------------------------------- ---------------TABLESPACE_NAME------------------------------/dcps01/oradata/fake/temp01.dbf 500TEMP
/dcps01/oradata/fake/pstemp01.dbf 2048PSTEMP
SQL>

No comments: