我们知道在Oracle10gR2以前的版本中,如果使用RMAN恢复数据库,临时表空间的临时文件是不会自动恢复的。这曾经引发了一系列的麻烦,很多DBA在恢复完成之后忘记添加临时文件,经常到应用出错时才能发现。
如果临时丢失了临时表空间的临时文件,或者在恢复后没有向数据库追加临时文件,那么在警告日志文件中可能会收到如下错误信息:
Wed Nov 24 03:15:32 2004 Errors in file /opt/oracle/admin/wapdb/bdump/wapdb_dbw0_3411.trc: ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ORA-01110: data file 201: '/opt/oracle/oradata/wapdb/temp01.dbf' ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
所以我们需要养成的一个好习惯是,在完成重要操作后(特别是恢复操作等),应当及时仔细检查警告日志文件,如果其中存在问题或错误信息,就应当及时解决这些问题。
解决这个问题很简单,只需要为临时表空间增加一个临时文件即可。
通常我们通过转储控制文件就可以获得相关的命令信息,转储控制文件的创建语句可以使用如下命令:
SQL> alter database backup controlfile to trace; Database altered.
在user_dump_dest目录下我们可以找到刚生成的跟踪文件:
SQL> show parameter user_dump NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ user_dump_dest string /opt/oracle/admin/cmwapdb/udump
跟踪文件中包含如下信息:
# Commands to add tempfiles to temporary tablespaces. # Online tempfiles have complete space information. # Other tempfiles may require adjustment. ALTER TABLESPACE TEMP ADD TEMPFILE '/opt/oracle/oradata/wapdb/temp01.dbf ' SIZE 3424M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 8192M; # End of tempfile additions.
通过这条命令就可以向临时表空间TEMP中增加临时文件。请注意这个语句中的MAXSIZE语句,通常为了防止临时表空间的过度扩展,可以为临时文件设置一个扩展上限,以避免因过分扩展而带来的空间问题。
当然,这种恢复后的手工添加显得还是有一点麻烦,从Oracle10gR2开始,在使用了RMAN恢复数据库之后,Oracle会自动重新创建临时文件,由于临时文件是Sparse File,所以创建会非常迅速,通常你不会感觉得到。
以下是一段恢复日志,其中记录了Oracle的恢复处理过程:
Thu Sep 14 22:52:06 2006 Successfully onlined Undo Tablespace 1. Dictionary check beginning Thu Sep 14 22:52:06 2006 Errors in file /opt/oracle/admin/order/bdump/order_dbw0_31025.trc: ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ORA-01110: data file 201: '/data1/oradata/ORDER/datafile/o1_mf_temp_28spyr8h_.tmp' ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory Additional information: 3 Thu Sep 14 22:52:06 2006 Errors in file /opt/oracle/admin/order/bdump/order_dbw0_31025.trc: ORA-01186: file 201 failed verification tests ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ORA-01110: data file 201: '/data1/oradata/ORDER/datafile/o1_mf_temp_28spyr8h_.tmp' Thu Sep 14 22:52:06 2006 File 201 not verified due to error ORA-01157 Thu Sep 14 22:52:06 2006 Dictionary check complete Thu Sep 14 22:52:06 2006 SMON: enabling tx recovery Thu Sep 14 22:52:06 2006 Re-creating tempfile /data1/oradata/ORDER/datafile/o1_mf_temp_28spyr8h_.tmp as /data1/oradata/ORDER/datafile/o1_mf_temp_2jlv4p90_.tmp Database Characterset is ZHS16GBK replication_dependency_tracking turned off (no async multimaster replication found) Starting background process QMNC QMNC started with pid=22, OS id=13671 Thu Sep 14 22:52:10 2006 LOGSTDBY: Validating controlfile with logical metadata Thu Sep 14 22:52:10 2006 LOGSTDBY: Validation complete Starting control autobackup Control autobackup written to DISK device handle '/opt/oracle/product/db10g/dbs/c-1341966532-20060914-03' Completed: alter database open resetlogs
这也是Oracle10gR2的一个细致改进
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。