Unplugging, Plugging, and Upgrading a PDB to a New

一 從早期版本CDB拔出早期版本PDB
1、在PDB上運行升級前信息工具。
例如,salespdbCDB中運行的名爲PDB 的位置$ORACLE_HOME_12.2:

$ORACLE_BASE/product/12.1.0/dbhome_1/jdk/bin/java -jar  /u01/app/oracle/product/19.3.0/dbhome_1/rdbms/admin/preupgrade.jar dir /tmp -c salespdb

Unplugging, Plugging, and Upgrading a PDB to a New
2、preupgrade_fixups.sql在您的源數據庫上運行
例如:

CONNECT / AS SYSDBA
SQL> ALTER SESSION SET CONTAINER=salespdb;
SQL> @/tmp/preupgrade_fixups.sql

3、遵循中列出的所有建議preupgrade.log
Unplugging, Plugging, and Upgrading a PDB to a New
4、Oracle APEX
在12.1.0.2.0中默認安裝,而在12.2.0.1.0未默認安裝,如果不進行APEX卸載,在12.2.0.1.0中plug 12.1.0.2.0版本的pdb將報如下ORA-65346錯誤:
Unplugging, Plugging, and Upgrading a PDB to a New
當然,如果您有使用到APEX,需要在12.2.0.1.0中安裝APEX,而無需卸載12.1.0.2.0中的APEX。
卸載方式:

SQL> select COMP_ID, STATUS from DBA_REGISTRY where COMP_ID='APEX'; 

COMP_ID                        STATUS
------------------------------ ----------------------
APEX                           VALID
$ cd $ORACLE_HOME/apex
$ sqlplus / as sysdba
SQL>@apxremov_con.sql

Unplugging, Plugging, and Upgrading a PDB to a New
Unplugging, Plugging, and Upgrading a PDB to a New
Unplugging, Plugging, and Upgrading a PDB to a New
5、關閉要拔出的PDB
例如,使用以下命令關閉PDB salespdb:

SQL> ALTER PLUGGABLE DATABASE salespdb CLOSE;

6、重新登錄到CDB$ROOT:

CONNECT / AS SYSDBA
SQL> ALTER SESSION SET CONTAINER=CDB$ROOT;

7、 使用以下SQL命令語法拔出早期版本的PDB,其中pdbPDB的名稱和pathPDB XML文件的位置:

ALTER PLUGGABLE DATABASE salespdb UNPLUG INTO '/home/oracle/salespdb.xml';

命令完成後,將顯示以下響應:
Unplugging, Plugging, and Upgrading a PDB to a New
8、刪除可插入數據庫salespdb,但保留數據文件。
Oracle建議您執行salespdb此過程後清除CDB視圖中的剩餘信息,並避免將來出現問題。作爲最佳實踐指南,請首先將PDB備份到目標CDB中,然後DROP在源上發出命令。
要刪除可插入數據庫,請輸入以下命令:

SQL> DROP PLUGGABLE DATABASE salespdb KEEP DATAFILES; 

Unplugging, Plugging, and Upgrading a PDB to a New
二 將早期版本的PDB插入更高版本的CDB
1、拷貝xml與數據文件
Unplugging, Plugging, and Upgrading a PDB to a New
Unplugging, Plugging, and Upgrading a PDB to a New
要將PDB從較早版本的CDB插入到較早版本的CDB,請使用以下CREATE PLUGGABLE DATABASE命令。
此過程示例說明了在使用Oracle管理的文件時如何插入PDB。有關插入PDB的更多信息,請參考《Oracle數據庫管理員指南》。
連接到更高版本的CDB。使用以下SQL命令插入早期版本的PDB,其中pdbPDB path是PDB的名稱,也是PDB XML文件所在的路徑:
2、創建pdb

CREATE PLUGGABLE DATABASE salespdb USING '/home/oracle/salespdb.xml' SOURCE_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/orcl/salespdb','/u01/app/oracle/oradata/ORCL/salespdb') nocopy tempfile reuse;

由於APEX導致
Unplugging, Plugging, and Upgrading a PDB to a New
解決方式:由於在unplugging 時沒有卸載APEX,後續可刪除xml文件中的
Unplugging, Plugging, and Upgrading a PDB to a New
不過後續會報很多錯誤。
命令完成後,將顯示以下響應:
Unplugging, Plugging, and Upgrading a PDB to a New
Unplugging, Plugging, and Upgrading a PDB to a New
三 將早期版本的PDB升級到更高版本
在UPGRADE模式下打開的PDB 使用Parallel Upgrade Utility來將較早發行的PDB升級到CDB的發行級別。
1、切換到升級PDB
例如,輸入以下命令以切換到PDB salespdb:

SQL> ALTER SESSION SET CONTAINER=salespdb;

2、在升級模式下打開PDB。

SQL> ALTER PLUGGABLE DATABASE OPEN UPGRADE;

Unplugging, Plugging, and Upgrading a PDB to a New
3、使用“並行升級實用程序”命令(catctl.pl或shell實用程序dbupgrade)升級PDB 。
升級PDB時,請使用通常與Parallel Upgrade Utility並行使用的命令。但是,您還可以添加選項以指定要升級的PDB。如以下示例所示,使用名爲的PDB大寫PDB的名稱: -c PDBnamesalespdb

$ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catctl.pl -d  \
$ORACLE_HOME/rdbms/admin -c 'salespdb' -l $ORACLE_BASE catupgrd.sql

Unplugging, Plugging, and Upgrading a PDB to a New
Unplugging, Plugging, and Upgrading a PDB to a New
Unplugging, Plugging, and Upgrading a PDB to a New
4、查看結果
日誌的默認文件路徑在path中,其中Oracle基本路徑,數據庫名稱以及升級的日期和時間。日期和時間字符串採用字符串格式YYYY MM DD HH MM SC,其中YYYY表示年,MM表示月,DD表示日,HH表示小時,MM表示分鐘,SC表示秒。 Oracle_base/cfgtoollogs/dbname/upgradedatetimeOracle_basedbnameupgradedatetime例如:
Unplugging, Plugging, and Upgrading a PDB to a New
5、登錄到SQL * Plus,然後打開PDB以執行升級後的修訂,並重新編譯INVALID數據庫中的對象:

SQL> STARTUP;
SQL> ALTER SESSION SET CONTAINER=salespdb;

6、使用該實用程序catcon.pl運行腳本postupgrade_fixups.sql:

@/tmp/postupgrade_fixups.sql

7、使用該實用程序從目錄catcon.pl運行:

@$ORACLE_HOME/rdbms/admin/utlrp.sql

該腳本將重新編譯INVALID數據庫中的對象,並將名稱爲的日誌文件放置在當前目錄中comp0.log。
Unplugging, Plugging, and Upgrading a PDB to a New

Unplugging, Plugging, and Upgrading a PDB to a New

Unplugging, Plugging, and Upgrading a PDB to a New

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章