溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

發(fā)布時間:2021-08-30 12:50:40 來源:億速云 閱讀:165 作者:chen 欄目:關(guān)系型數(shù)據(jù)庫

這篇文章主要介紹“Oracle 12c nocdb怎么轉(zhuǎn)換成cdb”,在日常操作中,相信很多人在Oracle 12c nocdb怎么轉(zhuǎn)換成cdb問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”O(jiān)racle 12c nocdb怎么轉(zhuǎn)換成cdb”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

Oracle 12c nocdb轉(zhuǎn)換成cdb

環(huán)境說明:

OS:Oracle Linux Server release 6.3

DB:Oracle 12.2.0.1.0

DBName:dapuchai

場景:

Oracle 11.2.0.4.0升級到Oracle 12.2.0.1.0,默認是no-cdb模式,升級后根據(jù)需要將no-cdb轉(zhuǎn)換成cdb里,即將之前的11.2.0.4.0數(shù)據(jù)完全遷移到PDB(Creating a PDB Using a Non-CDB);

實施方案:

一:連接non-CDB(dapuchai),生成XML格式數(shù)據(jù)庫描述文件

二:DBCA新建cdb數(shù)據(jù)庫(cjcdb)

三:Plug in the non-CDB (cjcpdb)

四:執(zhí)行noncdb_to_pdb.sql

五:驗證數(shù)據(jù)

參考:https://docs.oracle.com/database/121/ADMIN/cdb_plug.htm#ADMIN13598

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

一: 連接non-CDB(dapuchai),生成XML格式數(shù)據(jù)庫描述文件

Connect to the non-CDB, and run the DBMS_PDB.DESCRIBE procedure to construct an XML file that describes the non-CDB.

[root@cjc ~]# ps -ef|grep pmon

oracle    2677     1  0 22:35 ?        00:00:00 ora_pmon_dapuchai

root      3057  2634  0 22:37 pts/1    00:00:00 grep pmon

SQL> select name,cdb from v$database;

NAME         CDB

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

DAPUCHAI  NO

SQL> show pdbs

SQL> show con_id

CON_ID

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

0

SQL> shutdown immediate

---只讀方式打開dapuchai數(shù)據(jù)庫

SQL> startup open read only;

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

NAME         OPEN_MODE              CDB

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

DAPUCHAI  READ ONLY                NO

---生成xml格式的數(shù)據(jù)庫描述文件

SQL> BEGIN

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

END;  2    3 

  4  /

PL/SQL procedure successfully completed.

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

二:DBCA新建cdb數(shù)據(jù)庫(cjcdb)

[oracle@cjc ~]$ dbca

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

三:Plug in the non-CDB (cjcpdb)

[oracle@cjc oracle12]$ ps -ef|grep pmon

oracle    3106     1  0 22:38 ?        00:00:00 ora_pmon_dapuchai

oracle    4326     1  0 23:05 ?        00:00:00 ora_pmon_cjcdb

oracle    5651  3249  0 23:16 pts/1    00:00:00 grep pmon

[oracle@cjc ~]$ export ORACLE_SID=cjcdb

[oracle@cjc ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Jan 13 23:18:52 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show pdbs

    CON_ID CON_NAME                            OPEN MODE  RESTRICTED

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

          2 PDB$SEED                       READ ONLY  NO

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

NAME         OPEN_MODE              CDB

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

CJCDB        READ WRITE               YES

[oracle@cjc oradata]$ mkdir cjcpdb

[oracle@cjc oradata]$ cd cjcpdb/

[oracle@cjc cjcpdb]$ pwd

/u01/app/oracle12/oradata/cjcpdb

SQL> select name from v$dbfile;

NAME

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

/u01/app/oracle12/oradata/cjcdb/users01.dbf

/u01/app/oracle12/oradata/cjcdb/undotbs01.dbf

/u01/app/oracle12/oradata/cjcdb/system01.dbf

/u01/app/oracle12/oradata/cjcdb/sysaux01.dbf

/u01/app/oracle12/oradata/cjcdb/pdbseed/system01.dbf

/u01/app/oracle12/oradata/cjcdb/pdbseed/sysaux01.dbf

/u01/app/oracle12/oradata/cjcdb/pdbseed/undotbs01.dbf

7 rows selected.

SQL> create pluggable database cjcpdb using '/home/oracle/20200113.xml' copy FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/dapuchai/', '/u01/app/oracle12/oradata/cjcpdb/');

Pluggable database created.

---數(shù)據(jù)文件遷移完成

[oracle@cjc cjcpdb]$ pwd

/u01/app/oracle12/oradata/cjcpdb

[oracle@cjc cjcpdb]$ ll -rth

total 2.5G

-rw-r----- 1 oracle oinstall  58M Jan 13 23:26 temp01.dbf

-rw-r----- 1 oracle oinstall  11M Jan 13 23:26 ogg_temtbs01.dbf

-rw-r----- 1 oracle oinstall  11M Jan 13 23:26 ogg_tbs01.dbf

-rw-r----- 1 oracle oinstall  11M Jan 13 23:26 cjc_tbs01a.dbf

-rw-r----- 1 oracle oinstall  16M Jan 13 23:26 users01.dbf

-rw-r----- 1 oracle oinstall 446M Jan 13 23:26 undotbs01.dbf

-rw-r----- 1 oracle oinstall 1.2G Jan 13 23:26 system01.dbf

-rw-r----- 1 oracle oinstall 881M Jan 13 23:26 sysaux01.dbf

SQL> show pdbs

    CON_ID CON_NAME                            OPEN MODE  RESTRICTED

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

          2 PDB$SEED                       READ ONLY  NO

          3 CJCPDB                            MOUNTED

四:執(zhí)行noncdb_to_pdb.sql

虛擬機內(nèi)存只分配4G,并且是機械硬盤,腳本執(zhí)行了1小時;

切換到PDB并執(zhí)行腳本

SQL> alter session set container=cjcpdb;

SQL> @?/rdbms/admin/noncdb_to_pdb.sql

......

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

......

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

......

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

---啟動pdb

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         3 CJCPDB                         MOUNTED

SQL> alter pluggable database cjcpdb open;

Pluggable database altered.

告警日志查看pdb啟動過程;

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

五:驗證數(shù)據(jù)

[oracle@cjc ~]$ cd /u01/app/oracle12/product/12.2.0.1/db_1/network/admin/

[oracle@cjc admin]$ vi tnsnames.ora

......

CJCPDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = cjc)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = CJCPDB)

    )

  )

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

---修改環(huán)境變量,指定cdb實例

[oracle@cjc ~]$ vi .bash_profile

......

#export ORACLE_SID=dapuchai

export ORACLE_SID=cjcdb

......

[oracle@cjc ~]$ source .bash_profile

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

---關(guān)掉no-cdb

Oracle 12c nocdb怎么轉(zhuǎn)換成cdb

到此,關(guān)于“Oracle 12c nocdb怎么轉(zhuǎn)換成cdb”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細節(jié)

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

AI