溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

oracle 12.2將共享undo轉(zhuǎn)為local undo的方法

發(fā)布時(shí)間:2020-08-11 16:17:07 來源:ITPUB博客 閱讀:225 作者:水逸冰 欄目:關(guān)系型數(shù)據(jù)庫(kù)

本文主要講述了:

1.關(guān)于undo表空間share和local的看法

2.修改undo為local undo的方法

3.修改PDB$SEED屬性的方法

4.關(guān)于local undo轉(zhuǎn)為share undo

一.概述

數(shù)據(jù)庫(kù)從12.2版本開始,實(shí)現(xiàn)了undo表空間在cdb和pdb層面的隔離;并且local undo也是一些新特征性的基礎(chǔ),比如pdb refresh和pdb閃回。12.1版本還無法實(shí)現(xiàn)。不過這種資源的隔離是不可避免的發(fā)展方向。undo在實(shí)現(xiàn)隔離之后,下一步redo的隔離也是有可能的。

cdb是local undo模式的時(shí)候,open的cdb和pdb都會(huì)有屬于自己的undo表空間。當(dāng)從一個(gè)share undo的cdb中拔插一個(gè)pdb到local undo模式的cdb中的時(shí)候,在這個(gè)pdb open的時(shí)候,會(huì)為這個(gè)pdb自動(dòng)創(chuàng)建undo表空間。

 

二.修改undo為local undo的方法

數(shù)據(jù)庫(kù)版本

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

 

查詢當(dāng)前數(shù)據(jù)庫(kù)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

 

可以看到當(dāng)前undo還是共享的,只在cdb中存在一個(gè)undo表空間。

 

大致步驟

1.關(guān)閉cdb實(shí)例

2.打開pdb到upgrade模式,startup upgrade

3.在CDB$ROOT中執(zhí)行:ALTER DATABASE LOCAL UNDO ON;

4.關(guān)閉cdb實(shí)例,然后重啟

 

 

下面是操作過程:

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

 

 

三.修改PDB$SEED屬性的方法

最開始的時(shí)候就提過了,當(dāng)從一個(gè)share undo的cdb中拔插一個(gè)pdb到local undo模式的cdb中的時(shí)候,在這個(gè)pdb open的時(shí)候,會(huì)為這個(gè)pdb自動(dòng)創(chuàng)建undo表空間。這里有兩個(gè)pdb是自動(dòng)開啟的,所以為這兩個(gè)pdb自動(dòng)創(chuàng)建了undo表空間。300M的大小是跟隨PDB$SEED中pdb的大小。如果想控制創(chuàng)建的undo表空間的配置,比如大小,可以在pdb$seed中修改undo表空間。

方法如下:

1.       cdb$root中執(zhí)行:

alter session set   "_oracle_script"=true;  --修改隱含參數(shù),就可以避免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

 

 

四.關(guān)于local undo轉(zhuǎn)為share undo

以上是oracle如何將共享undo變?yōu)閘ocal undo的方法。local undo轉(zhuǎn)為共享undo不符合發(fā)展潮流,方法大同小異,無非是之前命令改動(dòng)成alter database local undo off,詳細(xì)過程就不介紹了。但要注意的是當(dāng)oracle變成共享undo模式的時(shí)候,它會(huì)忽略之前l(fā)ocal模式時(shí)創(chuàng)建的本地udno表空間,oracle建議直接刪除這些local undo tablespace。


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI