oracle 12C 单实例PDB插入到RAC环境下出现的问题

前言

本文记录在oracle 12C,通过pdb插拔的方式将单实例转换为rac环境出现的问题。

undo表空间被占用

问题描述

在迁移过程中,由于修改过源pdb的默认undo表空间,导致插入到rac环境的时候,出现undo表空间被占用的情况。

注:这里,使用的是local undo的模式

问题重现

切换至测试pdb
1
2
SQL> alter session set container = TEST;
Session altered.
查询默认undo表空间,及数据文件位置
1
2
3
4
5
6
7
8
9
SQL> select tablespace_name,
file_name,
AUTOEXTENSIBLE,
bytes / 1024 / 1024 size_mb
from dba_data_files
where tablespace_name like '%UNDO%';
TABLESPACE_NAME FILE_NAME AUTOEXTEN SIZE_MB
--------------- --------------------------------------------------- --------- ----------
UNDOTBS1 /u01/app/oracle/oradata/SRMCLOUD/test/undotbs01.dbf YES 1515
修改默认undo表空间
1
2
3
4
5
6
7
8
9
10
11
12
13
SQL> create undo tablespace undotbs2 datafile '/u01/app/oracle/oradata/SRMCLOUD/test/undotbs02.dbf' size 100m autoextend on;
Tablespace created.
SQL> alter system set undo_tablespace='UNDOTBS2' scope=both;
System altered.
SQL> drop tablespace UNDOTBS1 including contents and datafiles;
Tablespace dropped.
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
temp_undo_enabled boolean FALSE
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS2
切换回CDB
1
SQL> alter session set container = CDB$ROOT
拔出测试PDB
1
2
3
4
5
6
SQL> alter pluggable database TEST close immediate;
Pluggable database altered.
SQL> alter pluggable database TEST unplug into '/u01/app/oracle/oradata/SRMCLOUD/test.xml';
Pluggable database altered.
SQL> drop pluggable database TEST KEEP DATAFILES;
Pluggable database dropped.
在rac下插入pdb
1
2
SQL> CREATE PLUGGABLE DATABASE test USING '/u01/app/oracle/test.xml' SOURCE_FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/SRMCLOUD/test/', '/u01/app/oracle/test/') MOVE FILE_NAME_CONVERT = ('/u01/app/oracle/test/', '+DATA/srmcloud/test/');
Pluggable database created.
启动新插入的pdb
1
2
3
4
5
6
SQL> alter pluggable database TEST open instances=all;
alter pluggable database TEST open instances=all
*
ERROR at line 1:
ORA-65107: Error encountered when processing the current task on instance:1
ORA-30013: undo tablespace 'UNDOTBS2' is currently in use
问题描述2

以上就重现了错误过程。

刚开始只是以为更改了默认undo表空间的名称,导致在插入oracle rac环境下的时候,oracle自动添加新的undo失败。(oracle 12c rac下,每个实例上的pdb使用的是不同的undo表空间)

针对以上猜想,尝试更改undo表空间为默认的名称后,重新插入,仍然失败

1
2
3
4
5
6
SQL> alter pluggable database TEST open instances=all;
alter pluggable database TEST open instances=all
*
ERROR at line 1:
ORA-65107: Error encountered when processing the current task on instance:1
ORA-30013: undo tablespace 'UNDOTBS1' is currently in use
发现原因

通过对比修改前与修改后的拔出文件test.xml发现,修改后比修改前,在拔出文件中多了一行如下参数

1
<spfile>*.undo_tablespace='UNDOTBS1'</spfile>

由于这个参数的原因,导致pdb在插入的时候,统一把undo表空间指向为’UNDOTBS1’导致的。

解决方法就是,删除这一行数据即可。

问题解决
1
2
SQL> alter pluggable database TEST open instances=all;
Pluggable database altered.