oracle active dataguard 环境下执行报错:ORA-25153: Temporary Tablespace is Empty

os: centos 7.6
db: oracle 19.3

oracle active dataguard 环境,在 primary 上创建永久表空间,临时表空间,用户.数据库切换后,发现新的priamry上报错,排查后发现是临时表空间没有临时数据文件.

SQL> set lines 200;
set pages 200;
col username format a30;
col default_tablespace format a30;
col temporary_tablespace format a30;
col local_temp_tablespace format a30;

SQL> 
SQL> 
SQL> select username,default_tablespace,temporary_tablespace,local_temp_tablespace
from dba_users
where username='PEIYONGBIN'
;  2    3    4  

USERNAME		       DEFAULT_TABLESPACE	      TEMPORARY_TABLESPACE	     LOCAL_TEMP_TABLESPACE
------------------------------ ------------------------------ ------------------------------ ------------------------------
PEIYONGBIN		       USER1		      TEMP1		     TEMP1

SQL> 

创建 USER1 的语句如下

SQL> create tablespace user1 datafile 
  '+DG_DATA01' size 209715200
  autoextend on next 20971520 maxsize 34359721984
  logging online permanent blocksize 8192
  extent management local autoallocate default 
  nocompress segment space management auto
  ;
 

创建 TEMP1 的语句如下

SQL> create temporary tablespace temp1 tempfile 
  '+DG_DATA01' size 209715200
  autoextend on next 20971520 maxsize 34359721984
  extent management local uniform size 1048576
 ; 
 

创建 PEIYONGBIN 的语句如下

SQL> drop user peiyongbin cascade;
SQL> create user peiyongbin identified by peiyongbin 
profile default 
default tablespace USER1
temporary tablespace TEMP1
local temporary tablespace TEMP1
account unlock;

alter user peiyongbin quota unlimited on USERS;

grant create session to peiyongbin;
grant connect, resource to peiyongbin;

数据库切换后,在新的primary上查看

SQL> set lines 200;
SQL> set pages 200;
SQL> col tablespace_name format a30;
SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
TEMP1
USERS
UNDO_2

7 rows selected.

SQL> col tablespace_name format a30;
col file_id format 99;
col file_name format a80;
SQL> 
SQL> select tablespace_name,file_id,file_name
from dba_temp_files
;

TABLESPACE_NAME 	       FILE_ID FILE_NAME
------------------------------ ------- --------------------------------------------------
TEMP				     3 +DG_DATA01/ORCL/8A10EB340F4E43C6E0536507000A77DB/TEMPFILE/temp.303.1010240159
					   

为什么没有 TEMP1 对应的数据文件.

查看 alert 日志时发现如下信息

PDB1(4):Database Characterset for PDB1 is AL32UTF8
PDB1(4):*********************************************************************
PDB1(4):WARNING: The following temporary tablespaces in container(PDB1)
PDB1(4):         contain no files.
PDB1(4):         This condition can occur when a backup controlfile has
PDB1(4):         been restored.  It may be necessary to add files to these
PDB1(4):         tablespaces.  That can be done using the SQL statement:
PDB1(4):
PDB1(4):         ALTER TABLESPACE <tablespace_name> ADD TEMPFILE
PDB1(4):
PDB1(4):         Alternatively, if these temporary tablespaces are no longer
PDB1(4):         needed, then they can be dropped.
PDB1(4):           Empty temporary tablespace: TEMP1
PDB1(4):*********************************************************************

那就手动添加该临时表空间对应的文件

SQL> alter session set container=pdb1;
SQL> alter tablespace TEMP1 add tempfile '+DG_DATA01' reuse; 
SQL>
SQL> set lines 200;
set pages 200;
col file# format 99;
col name format a100;
col con_id format 99;

alter session set container=CDB$ROOT;
select file#, name,con_id from v$tempfile order by file#;
select file#, name,con_id from v$datafile order by file#;

参考:
https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/CREATE-TABLESPACE.html#GUID-51F07BF5-EFAF-4910-9040-C473B86A8BF9

猜你喜欢

转载自blog.csdn.net/ctypyb2002/article/details/92694548
今日推荐