探索Oracle之資料庫升級七 11gR2 to 12c 升級完成後插入PDB
探索Oracle之資料庫升級七
11gR2 to 12c 升級完成後插入PDB
前言:
從Oracle 12c開始,引入了容器資料庫的概念,可以實現資料庫插拔操作,如下圖:
現在我們就來看看如何將11.2.0.4的資料庫插入到12c的CDP裡面去,讓其成為一個PDB
資料庫。
一、檢視資料庫資訊:
-
SQL> col BANNER format a80
-
SQL> set line 300
-
SQL> select * from v$version;
-
-
BANNER CON_ID
-
-------------------------------------------------------------------------------- ----------
-
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
-
PL/SQL Release 12.1.0.1.0 - Production 0
-
CORE 12.1.0.1.0 Production 0
-
TNS for Linux: Version 12.1.0.1.0 - Production 0
-
NLSRTL Version 12.1.0.1.0 - Production
-
-
SQL> select cdb,name,dbid from v$database;
-
-
CDB NAME DBID
-
--- --------- ----------
- NO WOO 4199532651
從這裡我們可以看到實際上通過升級之後上來的資料庫還是一個non-CDB,並非CDB資料庫,那麼這個時候我們需要在這個none-CDB庫中生成使用者PDB的XML檔案,再建立CDB資料庫進行插入進去。
二、檢視錶空間及資料檔案資訊:
-
SQL> select * from v$tablespace;
-
-
TS# NAME INC BIG FLA ENC CON_ID
-
---------- ------------------------------ --- --- --- --- ----------
-
0 SYSTEM YES NO YES 0
-
1 SYSAUX YES NO YES 0
-
2 UNDOTBS1 YES NO YES 0
-
4 USERS YES NO YES 0
-
3 TEMP NO NO YES 0
-
-
SQL> set line 300
-
SQL> col file_name format a40
-
SQL> col tablespace_name format a10
-
SQL> select tablespace_name,file_name from dba_data_files;
-
-
TABLESPACE FILE_NAME
-
---------- ----------------------------------------
-
USERS /DBData/woo/woo/users01.dbf
-
UNDOTBS1 /DBData/woo/woo/undotbs01.dbf
-
SYSAUX /DBData/woo/woo/sysaux01.dbf
- SYSTEM /DBData/woo/woo/system01.dbf
三、建立用於生成PDB的XML檔案
-
SQL> shutdown immediate
-
Database closed.
-
Database dismounted.
-
ORACLE instance shut down.
-
SQL> startup mount
-
ORACLE instance started.
-
-
Total System Global Area 2772574208 bytes
-
Fixed Size 2292240 bytes
-
Variable Size 2533361136 bytes
-
Database Buffers 218103808 bytes
-
Redo Buffers 18817024 bytes
-
Database mounted.
-
-
SQL> alter database open read only;
-
Database altered.
-
-
SQL> exec dbms_pdb.describe(pdb_descr_file => \'/home/oracle/woo_ora11g.xml\');
-
PL/SQL procedure successfully completed.
-
-
SQL> host ls -rtl /home/oracle/woo*.xml
-
-rw-r--r-- 1 oracle oinstall 4147 Nov 27 19:17 /home/oracle/woo_ora11g.xml
-
-
SQL> shutdown immediate
-
Database closed.
-
Database dismounted.
- ORACLE instance shut down.
四、檢查升級後的資料庫是否適合以PDB的方式插入到CDB中
-
SQL> set serveroutput on;
-
SQL> declare
-
2 compat boolean := FALSE;
-
3 begin
-
4 compat := dbms_pdb.check_plug_compatibility(pdb_descr_file => \'/home/oracle/woo_ora11g.xml\');
-
5 if compat
-
6 then
-
7 dbms_output.put_line(\'YES\');
-
8 else
-
9 dbms_output.put_line(\'No\');
-
10 end if;
-
11 end;
-
12 /
-
-
No
-
- PL/SQL procedure successfully completed.
因為是第一次插入,所以執行結果顯示為NO,可以忽略繼續插入。
五、建立CDB資料庫
5.1 執行dbca建立cdb資料庫
5.2 指定需要建立的cdb資料庫名稱
5.3 建立CDB前檢查
5.4 Summar 點選Finish開始建立
5.5 現在正在開始建立
5.6 至此已經建立完成,告訴我們CDB資料庫的資訊
5.7 點選Close 關閉建立頁面
六、檢視當前pdb資訊
-
[oracle@db01 ~]$ export ORACLE_SID=woo12c
-
SQL> show pdbs;
-
-
CON_ID CON_NAME OPEN MODE RESTRICTED
-
---------- ------------------------------ ---------- ----------
-
2 PDB$SEED READ ONLY NO
-
3 PDB01 READ WRITE NO
-
-
SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
-
-
CON_ID DBID NAME OPEN_MODE
-
---------- ---------- ------------------------------ ----------
-
2 4107385256 PDB$SEED READ ONLY
- 3 3926295770 PDB01 READ WRITE
-
SQL> CREATE PLUGGABLE DATABASE woo_ora11g USING \'/home/oracle/woo_ora11g.xml\';
- Pluggable database created.
將Non-CDB插入到CDB中成為一個PDB輸出的Alert 日誌。
-
CREATE PLUGGABLE DATABASE woo_ora11g USING '/home/oracle/woo_ora11g.xml'
Thu Nov 27 23:45:05 2014
****************************************************************
Pluggable Database WOO_ORA11G with pdb id - 4 is created as UNUSABLE.
If any errors are encountered before the pdb is marked as NEW,
then the pdb must be dropped
****************************************************************
Deleting old file#1 from file$
Deleting old file#2 from file$
Deleting old file#3 from file$
Deleting old file#4 from file$
Deleting old file#5 from file$
Adding new file#13 to file$(old file#1)
Adding new file#14 to file$(old file#2)
Adding new file#15 to file$(old file#4)
Marking tablespace #2 invalid since it is not present in the describe file
Marking tablespace #5 invalid since it is not present in the describe file
Successfully created internal service woo_ora11g at open
ALTER SYSTEM: Flushing buffer cache inst=0 container=4 local
****************************************************************
Post plug operations are now complete.
Pluggable database WOO_ORA11G with pdb id - 4 is now marked as NEW.
****************************************************************
Completed: CREATE PLUGGABLE DATABASE woo_ora11g USING '/home/oracle/woo_ora11g.xml'
九、插入完成後檢視pdbs資訊
-
SQL> show pdbs
-
-
CON_ID CON_NAME OPEN MODE RESTRICTED
-
---------- ------------------------------ ---------- ----------
-
2 PDB$SEED READ ONLY NO
-
3 PDB01 READ WRITE NO
-
4 WOO_ORA11G MOUNTED
-
SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
-
-
CON_ID DBID NAME OPEN_MODE
-
---------- ---------- ------------------------------ ----------
-
2 4107385256 PDB$SEED READ ONLY
-
3 3926295770 PDB01 READ WRITE
-
4 4199532651 WOO_ORA11G MOUNTED
-
-
第一次no-cdb plug cdb是mount狀態,需要將其open;
-
SQL> alter pluggable database open;
-
Pluggable database altered.
-
-
SQL> show pdbs;
-
-
CON_ID CON_NAME OPEN MODE RESTRICTED
-
---------- ------------------------------ ---------- ----------
-
2 PDB$SEED READ ONLY NO
-
3 PDB01 MOUNTED
- 4 WOO_ORA11G READ WRITE YES
插入完成之後需要執行noncdb_to_pdb指令碼,修復原non-cdb 和新的pdb不相容的問題:
十、執行noncdb_pdb指令碼-
SQL> alter session set container=WOO_ORA11G;
-
Session altered.
-
-
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
-
-
………
-
-
#### 遇到warning,指令碼會自動忽略錯誤,繼續執行。在最後指令碼編譯的時候會修復這些問題。
-
-
更新完之後需要同步pdb資訊
-
SQL> show pdbs
-
-
CON_ID CON_NAME OPEN MODE RESTRICTED
-
---------- ------------------------------ ---------- ----------
-
4 WOO_ORA11G MOUNTED
-
SQL> alter pluggable database open restricted;
-
-
Pluggable database altered.
-
-
SQL> show pdbs
-
-
CON_ID CON_NAME OPEN MODE RESTRICTED
-
---------- ------------------------------ ---------- ----------
-
4 WOO_ORA11G READ WRITE YES
-
SQL> exec dbms_pdb.sync_pdb();
-
-
PL/SQL procedure successfully completed.
-
-
SQL> alter pluggable database close immediate;
-
-
Pluggable database altered.
-
-
SQL> alter pluggable database open;
-
- Pluggable database altered.
十一、至此no-cdb plug to cdb 成功
-
SQL> show pdbs;
-
-
CON_ID CON_NAME OPEN MODE RESTRICTED
-
---------- ------------------------------ ---------- ----------
-
2 PDB$SEED READ ONLY NO
-
3 PDB01 MOUNTED
-
4 WOO_ORA11G READ WRITE NO
- SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29320885/viewspace-1380685/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 12c系列(九) | 通過unplug與plug方式升級pdb資料庫Oracle資料庫
- 【資料庫升級】Oracle指令碼升級12c CDB to 19c CDB資料庫Oracle指令碼
- 資料庫升級之-Dataguard滾動升級資料庫
- Oracle 12c升級指南Oracle
- 資料庫升級之-XTTS資料庫TTS
- 資料庫升級之-資料泵資料庫
- oracle資料庫11.2.0.3升級到11.2.0.4Oracle資料庫
- 靜默方式安裝、升級oracle(三): 升級資料庫軟體及資料庫Oracle資料庫
- android資料庫如何進行版本升級?架構之資料庫框架升級Android資料庫架構框架
- oracle 升級12c引數樣例Oracle
- Oracle 12C升級到18COracle
- Oracle 11g升級到12COracle
- 資料庫升級和工具資料庫
- Oracle 12.2新特性: PDB級閃回資料庫(Flashback PDB)Oracle資料庫
- oracle 10 rac 升級 10.2.0.1升級到10.2.0.5Oracle
- Oracle資料庫升級或資料遷移的方法探討Oracle資料庫
- 靜默方式安裝、升級oracle(二): 建立資料庫Oracle資料庫
- oracle資料庫升級的時候oracle universal installer has detected........Oracle資料庫
- oracle 12c non-cdb升級成cdb模式Oracle模式
- 故障分析 | MySQL 資料庫升級後,資料庫怎麼卡住了MySql資料庫
- 【ERP升級】確保正確升級,完成收益最大化
- oracle升級後資料檔案路徑變為大寫Oracle
- Quantinuum完成硬體升級
- 【OCM】Oracle 12C OCMU 12c OCM升級考試大綱Oracle
- 13 使用SQL Apply 升級資料庫SQLAPP資料庫
- 12. Oracle版本、補丁及升級——12.3. 升級Oracle
- 如何讓MacOSX快速完成升級Mac
- 核心升級,資料先行 —— SNP中國賦能企業破解資訊化升級轉型後顧之憂
- 自定義開發資料庫升級程式資料庫
- Oracle 12c升級需遵循的簡單步驟NFOracle
- 【RMAN】Oracle11g透過rman升級到12cOracle
- iOS 資料庫升級資料遷移解決方案iOS資料庫
- 資料庫升級-物理重新整理資料字典資料庫
- Oracle 10.2.0.5升級至11.2.0.4Oracle
- A Oracle Data Guard Broker 升級和降級Oracle
- 靜默升級oracle 11g (從11.2.0.1升級到11.2.0.4)Oracle
- 【Oracle升級】Oracle指令碼升級11g to 19c non-CDBOracle指令碼
- Visual Studio 2019 升級16.8之後(升級.Net 5),RazorTagHelper任務意外失敗
- phpStudy2018 升級資料庫 MySQL5.7PHP資料庫MySql