重庆思庄Oracle、Redhat认证学习论坛
标题: Oracle12.2新特性—Local UNDO 表空间 [打印本页]
作者: 郑全 时间: 2019-2-19 16:50
标题: Oracle12.2新特性—Local UNDO 表空间
一、简介:
①:在12C R1版本中undo只支持Global Shared Undo模式, 所有container共享一个UNDO表空间, 目前保留这种模式只是为了升级过渡,
②:在12C R2引入了PDB Local UNDO模式,每个container都有自己的UNDO 表空间, 对于RAC是每个实例每个container都有自己的UNDO表空间, 这也正是推荐的.在DBCA时会有local undo选项,且默认勾选。
local undo 模式的好处:
①:减少undo表空间的争用,同时方便拔插
②:只有使用local undo才支持下面的新特性: Refresh PDB, Flashback PDB ,( Hot Clone, Relocate PDB in open read/write mode)
③:point-in-time recovery PDB
--注意:如果要将local UNO 转为 shared UNO,数据库必须要以upgrade方式启动,否则会报错;
二、 local undo 转 shared undo :
①:查看local undo 是否开启:
(默认是开启 local undo,因为在安装的时候默认是勾选这个选项的)
SQL> col PROPERTY_NAME for a25;
SQL> col PROPERTY_VALUE for a25;
SQL> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where property_name='LOCAL_UNDO_ENABLED';
PROPERTY_NAME PROPERTY_VALUE
------------------------- -------------------------
LOCAL_UNDO_ENABLED TRUE
注意:在Oracle12.1版本中 undo只支持Global Shared Undo模式,不支持local undo选项
②:重启数据库,
以upgrade方式启动:
SQL> shutdown immediate
SQL> startup upgrade
SQL> alter database local undo off;
---改变local undo的模式,数据库必须以upgrade方式启动。
SQL> shutdown immediate
SQL> startup
SQL> col PROPERTY_NAME for a25;
SQL> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where property_name='LOCAL_UNDO_ENABLED';
PROPERTY_NAME PROPERTY_VALUE
------------------------- -------------------------
LOCAL_UNDO_ENABLED FALSE
---注意,从上一步查询得知,local_undo 已经关闭了;
③:把pdb中的undo表空间删除:
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 TESTPDB READ WRITE NO
SQL> alter session set container=testpdb ;
SQL> select tablespace_name from dba_tablespaces;
----查看现在的表空间,
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERSTEST
6 rows selected.
SQL> select name from v$datafile where name like '%undo%';
---查看可以得知,目前有两个undo表空间,一个是CDB的,一个是PDB自己的NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/orcl/undotbs01.dbf
/opt/oracle/oradata/orcl/testpdb/undotbs01.dbf
SQL> drop tablespace UNDOTBS1 including contents and datafiles;
---删除pdb中的undo表空间,(一定是进入到pdb在执行这条命令)
Tablespace dropped.
SQL> select name from v$datafile where name like '%undo%';
---此时查看undo表空间,就只剩下CDB中的一个了
NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/orcl/undotbs01.dbf
SQL> show con_name;
CON_NAME
------------------------------
TESTPDB
二、shared undo 转 local undo :
SQL> shutdown immediate
SQL> startup upgrade
---必须以upgrade启动数据库
SQL> alter database local undo on;
----开启local undo模式
SQL> shutdown immediate
SQL> startup
SQL> col PROPERTY_NAME for a25;
SQL> col PROPERTY_VALUE for a25;
SQL> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where property_name='LOCAL_UNDO_ENABLED';
PROPERTY_NAME PROPERTY_VALUE
------------------------- -------------------------
LOCAL_UNDO_ENABLED TRUE
SQL> alter pluggable database testpdb open;
SQL> alter session set container=testpdb;
SQL> select name from v$datafile where name like '%undo%';
NAME
-----------------------------------------------------------------------------------------------------------------------------------------
/opt/oracle/oradata/orcl/testpdb/system01_i1_undo.dbf
说明:
打开loacl undo后,自动为当前的PDB创建undo表空间,同时如果以前再新创建pdb,系统将自动创建自己的undo表空间。创建表空间的名字与大小由 PDB$SEED 中的配置信息决定的。
作者: 郑全 时间: 2019-9-4 18:21
12.1.0.2不支持本地undo
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE 12.1.0.2.0 Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production
SQL> alter database local undo on;
alter database local undo on
*
ERROR at line 1:
ORA-02231: missing or invalid option to ALTER DATABASE
SQL>
欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) |
Powered by Discuz! X3.2 |