您好,登录后才能下订单哦!
本文主要讲述了:
1.关于undo表空间share和local的看法
2.修改undo为local undo的方法
3.修改PDB$SEED属性的方法
4.关于local undo转为share undo
数据库从12.2版本开始,实现了undo表空间在cdb和pdb层面的隔离;并且local undo也是一些新特征性的基础,比如pdb refresh和pdb闪回。12.1版本还无法实现。不过这种资源的隔离是不可避免的发展方向。undo在实现隔离之后,下一步redo的隔离也是有可能的。
cdb是local undo模式的时候,open的cdb和pdb都会有属于自己的undo表空间。当从一个share undo的cdb中拔插一个pdb到local undo模式的cdb中的时候,在这个pdb open的时候,会为这个pdb自动创建undo表空间。
数据库版本
SYS@cdbtest1(CDB$ROOT)> select banner from v$version where rownum=1;
BANNER -------------------------------------------------------------------------------- Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production |
查询当前数据库undo信息
SYS@cdbtest1(CDB$ROOT)> col PROPERTY_NAME for a25 SYS@cdbtest1(CDB$ROOT)> col PROPERTY_VALUE for a30 SYS@cdbtest1(CDB$ROOT)> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where property_name='LOCAL_UNDO_ENABLED';
PROPERTY_NAME PROPERTY_VALUE ------------------------- ------------------------------ LOCAL_UNDO_ENABLED FALSE
SYS@cdbtest1(CDB$ROOT)> set line 200 SYS@cdbtest1(CDB$ROOT)> col FILE_NAME for a50 SYS@cdbtest1(CDB$ROOT)> select a.con_id,a.tablespace_name,b.file_name from cdb_tablespaces a,CDB_DATA_FILES b where a.TABLESPACE_NAME=b.TABLESPACE_NAME and a.con_id=b.con_id and a.CONTENTS='UNDO';
CON_ID TABLESPACE_NAME FILE_NAME ---------- ------------------------------ -------------------------------------------------- 1 UNDOTBS1 /oradata/cdb/CDBTEST1/datafile/o1_mf_undotbs1_f7nz 8sl3_.dbf
|
可以看到当前undo还是共享的,只在cdb中存在一个undo表空间。
大致步骤
1.关闭cdb实例 2.打开pdb到upgrade模式,startup upgrade 3.在CDB$ROOT中执行:ALTER DATABASE LOCAL UNDO ON; 4.关闭cdb实例,然后重启 |
下面是操作过程:
SYS@cdbtest1(CDB$ROOT)> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SYS@cdbtest1(CDB$ROOT)> startup upgrade ORACLE instance started.
Total System Global Area 2214592512 bytes Fixed Size 8795040 bytes Variable Size 1845496928 bytes Database Buffers 352321536 bytes Redo Buffers 7979008 bytes Database mounted. Database opened. SYS@cdbtest1(CDB$ROOT)> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED MIGRATE YES 3 CLONEMING MOUNTED 4 MING MOUNTED SYS@cdbtest1(CDB$ROOT)> alter database local undo on;
Database altered.
SYS@cdbtest1(CDB$ROOT)> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SYS@cdbtest1(CDB$ROOT)> startup ORACLE instance started.
Total System Global Area 2214592512 bytes Fixed Size 8795040 bytes Variable Size 1845496928 bytes Database Buffers 352321536 bytes Redo Buffers 7979008 bytes Database mounted. Database opened.
SYS@cdbtest1(CDB$ROOT)> col PROPERTY_NAME for a25 SYS@cdbtest1(CDB$ROOT)> col PROPERTY_VALUE for a30 SYS@cdbtest1(CDB$ROOT)> select PROPERTY_NAME,PROPERTY_VALUE from database_properties where property_name='LOCAL_UNDO_ENABLED';
PROPERTY_NAME PROPERTY_VALUE ------------------------- ------------------------------ LOCAL_UNDO_ENABLED TRUE SYS@cdbtest1(CDB$ROOT)> select a.con_id,a.tablespace_name,b.file_name,b.bytes/1024/1024 M from cdb_tablespaces a,CDB_DATA_FILES b where a.TABLESPACE_NAME=b.TABLESPACE_NAME and a.con_id=b.con_id and a.CONTENTS='UNDO';
CON_ID TABLESPACE_NAME FILE_NAME M ---------- ------------------------------ -------------------------------------------------- ---------- 1 UNDOTBS1 /oradata/cdb/CDBTEST1/datafile/o1_mf_undotbs1_f7nz 835 8sl3_.dbf
3 UNDO_1 /oradata/cdb/CDBTEST1/64B070B959B22CC9E053023DA8C0 300 935F/datafile/o1_mf_undo_1_fxv9cmnl_.dbf
4 UNDO_1 /oradata/cdb/CDBTEST1/64AE1A20BB9C1B5FE053023DA8C0 300 6963/datafile/o1_mf_undo_1_fxv9cvrd_.dbf
|
最开始的时候就提过了,当从一个share undo的cdb中拔插一个pdb到local undo模式的cdb中的时候,在这个pdb open的时候,会为这个pdb自动创建undo表空间。这里有两个pdb是自动开启的,所以为这两个pdb自动创建了undo表空间。300M的大小是跟随PDB$SEED中pdb的大小。如果想控制创建的undo表空间的配置,比如大小,可以在pdb$seed中修改undo表空间。
方法如下:
1. cdb$root中执行:
alter session set "_oracle_script"=true; --修改隐含参数,就可以避免ORA-65017: seed pluggable database may not be dropped or altered ALTER PLUGGABLE DATABASE PDB$SEED OPEN READ WRITE FORCE ; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ WRITE NO
|
2. 切换到种子pdb
ALTER SESSION SET CONTAINER=PDB$SEED; |
3. 修改undo表空间
alter database datafile '/oradata/cdb/CDBTEST1/6498843CCFAD2D1FE053023DA8C0AC32/datafile/o1_mf_undotbs1_f7nz8x0z_.dbf' resize 300m; |
之前是210M,修改成300M。
4. 再将PDB$SEED修改回只读模式
SYS@cdbtest1(CDB$ROOT)> alter session set "_oracle_script"=true;
Session altered.
SYS@cdbtest1(CDB$ROOT)> alter pluggable database "pdb$seed" close immediate;
Pluggable database altered.
SYS@cdbtest1(CDB$ROOT)> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED MOUNTED 3 CLONEMING READ WRITE NO 4 MING READ WRITE NO SYS@cdbtest1(CDB$ROOT)> alter pluggable database "pdb$seed" open read only;
Pluggable database altered.
SYS@cdbtest1(CDB$ROOT)> sho pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 CLONEMING READ WRITE NO 4 MING READ WRITE NO
|
以上是oracle如何将共享undo变为local undo的方法。local undo转为共享undo不符合发展潮流,方法大同小异,无非是之前命令改动成alter database local undo off,详细过程就不介绍了。但要注意的是当oracle变成共享undo模式的时候,它会忽略之前local模式时创建的本地udno表空间,oracle建议直接删除这些local undo tablespace。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。