近期,某用户将报表业务转移到DATAGUARD的备机上运行,发现程序有报错临时表空间的信息;经排查为ADG备机上,没有临时表空间的文件问题~用户困惑;
在正常的RMAN备份恢复过程中,只恢复数据文件,不恢复临时表空间的文件。临时表空间的文件信息仅为数据字典中的一条记录,在数据库OPEN过程中会自动创建;
那么在DATAGUARD环境下,备库的TEMP文件会怎么样呢?
1.首先明确一点,在主库添加tempfile时,没有REDO产生,所以不会同步到DG备库(dba_temp_files中也查不到)
2.当每一次DG搭建时,此时从主库创建的STANDBY CONTROLFILE,控制文件中包含有tempfile文件名,在DG备库数据库OPEN时会自动创建(read only时)
那么如果主、备库环境DG在正常同步运行,此时备库跑报表业务需要用到TEMP表空间,并且空间不足需要扩容,怎么处理呢? 很简单,直接在备机OPEN READ ONLY状态下,添加TEMP文件即可。
MOS有几篇文档讲了这个问题,如下:
Temporary Datafile created in Primary is missing in the Standby Database (Doc ID 834174.1)
Data Guard Physical Standby - Managing temporary tablespace tempfiles (Doc ID 1514588.1)
如下相关日志:
1.temp文件自动创建的日志
Dictionary check beginning
Errors in file /oracle/diag/rdbms/orclstd/orcl/trace/orcl_dbw0_4599.trc:
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '/oradata/orcl/temp01.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /oracle/diag/rdbms/orclstd/orcl/trace/orcl_dbw0_4599.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: '/oradata/orcl/temp01.dbf'
File 201 not verified due to error ORA-01157
Dictionary check complete
Re-creating tempfile /oradata/orcl/temp01.dbf
Database Characterset is AL32UTF8
Sun Aug 22 13:06:59 2021
Using STANDBY_ARCHIVE_DEST parameter default value as /oracle/arch/orcl
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Physical standby database opened for read only access.
Completed: alter database open read only
2.DG备机添加TEMPFILE日志‘
SQL> alter database open;
Database altered.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/oradata/orcl/temp01.dbf
SQL> select FILE_NAME from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/oradata/orcl/temp01.dbf
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select FILE_NAME from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/oradata/orcl/temp01.dbf
SQL> alter tablespace temp add tempfile '/oradata/orcl/temp02.dbf' size 5M autoextend on;
Tablespace altered.
SQL> select FILE_NAME from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/oradata/orcl/temp01.dbf
/oradata/orcl/temp02.dbf
SQL> select open_mode,name,db_unique_name,force_logging,log_mode,DATABASE_ROLE,dbid,userenv('language') lang,to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') currt_time from v$database;
OPEN_MODE NAME DB_UNIQUE_NAME FOR LOG_MODE
-------------------- --------- ------------------------------ --- ------------
DATABASE_ROLE DBID LANG
---------------- ---------- ----------------------------------------------------
CURRT_TIME
-------------------
READ ONLY WITH APPLY ORCL orcl YES ARCHIVELOG
PHYSICAL STANDBY 1602987508 AMERICAN_AMERICA.AL32UTF8
2022/04/25 09:43:02
|