oracle 12c non-cdb升級成cdb模式

水逸冰發表於2019-07-02

oracle 12c non-cdb升級成cdb模式


相同主機下,有一個non-cdb資料庫,再建立一個cdb的例項。

SQL> select name,cdb from v$database;


NAME                        CDB

--------------------------- ---------

EID                         NO


1 row selected.


關閉資料庫並以read only模式開啟

16:50:58 SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

16:51:39 SQL> startup open read only;

ORACLE instance started.


Total System Global Area 1426063360 bytes

Fixed Size                  8620704 bytes

Variable Size             486540640 bytes

Database Buffers          922746880 bytes

Redo Buffers                8155136 bytes

Database mounted.

Database opened.


SQL> select name,open_mode,cdb from v$database;


NAME                        OPEN_MODE                                                    CDB

--------------------------- ------------------------------------------------------------ ---------

EID                         READ ONLY                                                    NO


1 row selected.


生成xml格式的資料庫描述檔案

SQL> BEGIN

  2    DBMS_PDB.DESCRIBE(pdb_descr_file => '/home/oracle/EID.xml');

  3  END;

  4  /


PL/SQL procedure successfully completed.


關閉資料庫

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.


連線到cdb資料庫

SQL> CREATE PLUGGABLE DATABASE mpdb01 USING '/home/oracle/EID.xml'

  2  COPY

  3  FILE_NAME_CONVERT = ('/u02/app/oracle/oradata/EID/', '/u02/app/oracle/oradata/mcdb/mpdb01/');


Pluggable database created.


SQL> show pdbs  


    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

         2 PDB$SEED                       READ ONLY  NO

         3 MPDB01                         MOUNTED

SQL> alter session set container=MPDB01;


Session altered.


執行如下命令。注意該命令會清空shared pool,所以生產環境要注意。

sql> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql


SQL> alter pluggable database MPDB01 open;


Pluggable database altered.



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31480688/viewspace-2649370/,如需轉載,請註明出處,否則將追究法律責任。

相關文章