Chinaunix首页 | 论坛 | 博客
  • 博客访问: 25225
  • 博文数量: 18
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 180
  • 用 户 组: 普通用户
  • 注册时间: 2015-11-02 14:00
文章分类

全部博文(18)

文章存档

2016年(4)

2015年(14)

我的朋友

分类: Oracle

2015-11-04 17:15:52

将non-cdb库转换为pdb库实验

一、环境说明

NON-CDB库 : test 
CDB库         : cdbtest
操作系统     : red hat linux 6.5 
数据库版本  :   oracle 12.1.0.2

二、转换步骤

2.1  以sysdba用户使用sqlplus连接数据库

点击(此处)折叠或打开
  1. [oracle@test ~]$ export ORACLE_SID=test
  2. [oracle@test ~]$ ps -ef|grep pmon
  3. oracle 23464 1 0 16:36 ? 00:00:01 ora_pmon_cdbtest
  4. oracle 27360 1 0 19:20 ? 00:00:00 ora_pmon_test
  5. oracle 29194 29156 0 19:40 pts/2 00:00:00 grep pmon
  6. [oracle@test ~]$ export ORACLE_SID=test
  7. [oracle@test ~]$ sqlplus / as sysdba

  8. SQL*Plus: Release 12.1.0.2.0 Production on Tue Nov 3 19:40:44 2015

  9. Copyright (c) 1982, 2014, Oracle. All rights reserved.


  10. Connected to:
  11. Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
  12. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

  13. SQL> select name,cdb from v$database;

  14. NAME     CDB
  15. --------- ---
  16. TEST     NO

2.2 关闭non-cdb库,并以open read only模式打开

点击(此处)折叠或打开
  1. SQL> shutdown immediate;
  2. Database closed.
  3. Database dismounted.
  4. ORACLE instance shut down.
  5. SQL> startup mount
  6. ORACLE instance started.

  7. Total System Global Area 1073741824 bytes
  8. Fixed Size         2932632 bytes
  9. Variable Size         436207720 bytes
  10. Database Buffers     629145600 bytes
  11. Redo Buffers         5455872 bytes
  12. Database mounted.
  13. SQL> alter database open read only;

  14. Database altered.

2.3 生成转换成pdb库的xml文件

点击(此处)折叠或打开

  1. SQL> exec dbms_pdb.describe(pdb_descr_file=>'/soft/test.xml');

  2. PL/SQL procedure successfully completed.

2.4 关闭non-cdb库

点击(此处)折叠或打开

  1. SQL> shutdown immediate;
  2. Database closed.
  3. Database dismounted.
  4. ORACLE instance shut down.

2.5 连接到cdb容器库

点击(此处)折叠或打开

  1. [oracle@test ~]$ export ORACLE_SID=cdbtest
  2. [oracle@test ~]$ sqlplus / as sysdba

  3. SQL*Plus: Release 12.1.0.2.0 Production on Tue Nov 3 19:59:20 2015

  4. Copyright (c) 1982, 2014, Oracle. All rights reserved.


  5. Connected to:
  6. Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
  7. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

  8. SQL> select name,cdb from v$database;

  9. NAME     CDB
  10. --------- ---
  11. CDBTEST YES
  12. SQL> show pdbs        
  13. CON_ID CON_NAME                       OPEN MODE  RESTRICTED
  14. ---------- ------------------------------ ---------- ----------
  15. 2 PDB$SEED                       READ ONLY  NO
  16. 3 PDB                            READ WRITE NO

2.6  使用生成好的xml文件创建pdb库

点击(此处)折叠或打开

  1. SQL> create pluggable database test using '/soft/test.xml' nocopy tempfile reuse;

  2. Pluggable database created.

  3. SQL> show pdbs

  4.     CON_ID CON_NAME             OPEN MODE RESTRICTED
  5. ---------- ------------------------------ ---------- ----------
  6.      2 PDB$SEED             READ ONLY NO
  7.      3 PDB                 READ WRITE NO
  8.      4 TEST              MOUNTED

2.7 将新增加的pdb库test打开

点击(此处)折叠或打开

  1. SQL> alter pluggable database test open;

  2. Warning: PDB altered with errors.
此时pdb打开时会报一个警告。原因是没有执行noncdb_to_pdb.sql脚本,也可以查询PDB_PLUG_IN_VIOLATIONS视图有详细警告信息

点击(此处)折叠或打开

  1. SQL> set linesize 200
  2. SQL> col time for a35
  3. SQL> col name for a10
  4. SQL> col cause for a25
  5. SQL> select time,name,cause,status from PDB_PLUG_IN_VIOLATIONS;

  6. TIME                 NAME CAUSE             STATUS
  7. ----------------------------------- ---------- ------------------------- ---------
  8. 03-NOV-15 04.39.40.398903 PM     PDB Parameter         RESOLVED
  9. 03-NOV-15 04.39.40.398903 PM     PDB Parameter         RESOLVED
  10. 03-NOV-15 04.39.40.398903 PM     PDB Parameter         RESOLVED
  11. 03-NOV-15 04.39.40.398903 PM     PDB Parameter         RESOLVED
  12. 03-NOV-15 04.39.40.398903 PM     PDB Parameter         RESOLVED
  13. 03-NOV-15 04.39.40.398903 PM     PDB Parameter         RESOLVED
  14. 03-NOV-15 04.39.40.398903 PM     PDB Parameter         RESOLVED
  15. 03-NOV-15 04.44.23.213235 PM     PDB Database CHARACTER SET     RESOLVED
  16. 03-NOV-15 08.06.46.273088 PM     TEST Parameter         RESOLVED
  17. 03-NOV-15 08.06.46.273088 PM     TEST Service Name Conflict     RESOLVED
  18. 03-NOV-15 08.06.46.273088 PM     TEST Parameter         RESOLVED

  19. TIME                 NAME CAUSE             STATUS
  20. ----------------------------------- ---------- ------------------------- ---------
  21. 03-NOV-15 08.06.46.281358 PM     TEST Non-CDB to PDB         PENDING
  22. 03-NOV-15 08.06.46.440296 PM     TEST SQL Patch         PENDING
  23. 13 rows selected.

2.8  连接新转换的pdb库test实例 执行noncdb_to_pdb转换脚本

点击(此处)折叠或打开

  1. SQL> conn sys/oracle@192.168.2.240:1521/test as sysdba
  2. Connected.
  3. SQL> exit
  4. Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
  5. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
  6. [oracle@test ~]$ sqlplus /nolog

  7. SQL*Plus: Release 12.1.0.2.0 Production on Tue Nov 3 20:33:55 2015

  8. Copyright (c) 1982, 2014, Oracle. All rights reserved.

  9. SQL> conn sys/oracle@192.168.2.240:1521/test as sysdba
  10. Connected.
  11. SQL> @?/rdbms/admin/noncdb_to_pdb.sql
这个脚本执行时间比较长,大约需30分钟左右。

2.9 启动pdb并检查状态

点击(此处)折叠或打开

  1. [oracle@test ~]$ sqlplus / as sysdba

  2. SQL*Plus: Release 12.1.0.2.0 Production on Tue Nov 3 21:00:51 2015

  3. Copyright (c) 1982, 2014, Oracle. All rights reserved.


  4. Connected to:
  5. Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
  6. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

  7. SQL> show pdbs

  8.     CON_ID CON_NAME             OPEN MODE RESTRICTED
  9. ---------- ------------------------------ ---------- ----------
  10.      2 PDB$SEED             READ ONLY NO
  11.      3 PDB                 READ WRITE NO
  12.      4 TEST              READ WRITE YES
  13. SQL> alter pluggable database test close;

  14. Pluggable database altered.

  15. SQL> show pdbs

  16.     CON_ID CON_NAME             OPEN MODE RESTRICTED
  17. ---------- ------------------------------ ---------- ----------
  18.      2 PDB$SEED             READ ONLY NO
  19.      3 PDB                 READ WRITE NO
  20.      4 TEST              MOUNTED
  21. SQL> alter pluggable database test open;

  22. Warning: PDB altered with errors.
至此test库已由non-cdb转换为pdb库,打开test库的时候有警告错误信息。

2.10 分析最后的警告信息,查看PDB_PLUG_IN_VIOLATIONS视图的错误信息

点击(此处)折叠或打开

  1. ***************************************************************
  2. WARNING: Pluggable Database TEST with pdb id - 4 is
  3.          altered with errors or warnings. Please look into
  4.          PDB_PLUG_IN_VIOLATIONS view for more details.
  5. ***************************************************************

点击(此处)折叠或打开

  1. SQL> select time,name,cause,message ,status from PDB_PLUG_IN_VIOLATIONS where status='PENDING';
  2. TIME                 NAME CAUSE         MESSAGE         STATUS
  3. ----------------------------------- ---------- -------------------- -------------------------------------------------- ----------
  4. 03-NOV-15 09.01.35.208293 PM     TEST SQL Patch     PSU bundle patch 5 (Database Patch Set Update : 12 PENDING
  5.                                  .1.0.2.5 (21359755)): Installed in the CDB but not
  6.                                  in the PDB.

2.11 升级psu补丁

点击(此处)折叠或打开

  1. [oracle@test OPatch]$ datapatch -verbose
  2. SQL Patching tool version 12.1.0.2.0 on Tue Nov 3 21:30:12 2015
  3. Copyright (c) 2015, Oracle. All rights reserved.

  4. Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_31165_2015_11_03_21_30_12/sqlpatch_invocation.log

  5. Connecting to database...OK
  6. Note: Datapatch will only apply or rollback SQL fixes for PDBs
  7.        that are in an open state, no patches will be applied to closed PDBs.
  8.        Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
  9.        (Doc ID 1585822.1)
  10. Bootstrapping registry and package to current versions...done
  11. Determining current state...done

  12. Current state of SQL patches:
  13. Bundle series PSU:
  14.   ID 5 in the binary registry and ID 5 in PDB CDB$ROOT, ID 5 in PDB PDB$SEED, ID 5 in PDB PDB

  15. Adding patches to installation queue and performing prereq checks...
  16. Installation queue:
  17.   For the following PDBs: CDB$ROOT PDB$SEED PDB
  18.     Nothing to roll back
  19.     Nothing to apply
  20.   For the following PDBs: TEST
  21.     Nothing to roll back
  22.     The following patches will be applied:
  23.       21359755 (Database Patch Set Update : 12.1.0.2.5 (21359755))

  24. Installing patches...
  25. Patch installation complete. Total patches installed: 1

  26. Validating logfiles...
  27. Patch 21359755 apply (pdb TEST): SUCCESS
  28.   logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/21359755/19194568/21359755_apply_CDBTEST_TEST_2015Nov03_21_37_44.log (no errors)
  29. SQL Patching tool complete on Tue Nov 3 21:37:50 2015

2.12 将test库关闭并重新打开,确认是否还有警告信息

点击(此处)折叠或打开

  1. SQL> show pdbs

  2.     CON_ID CON_NAME             OPEN MODE RESTRICTED
  3. ---------- ------------------------------ ---------- ----------
  4.      2 PDB$SEED             READ ONLY NO
  5.      3 PDB                 READ WRITE NO
  6.      4 TEST              READ WRITE YES
  7. SQL> alter pluggable database test close immediate;

  8. Pluggable database altered.

  9. SQL> alter pluggable database test open;

  10. Pluggable database altered.

  11. SQL> select status,action from PDB_PLUG_IN_VIOLATIONS;

  12. STATUS     ACTION
  13. --------- -------------------------------------------------------
  14. RESOLVED Please check the parameter in the current CDB
  15. RESOLVED Please check the parameter in the current CDB
  16. RESOLVED Please check the parameter in the current CDB
  17. RESOLVED Please check the parameter in the current CDB
  18. RESOLVED Please check the parameter in the current CDB
  19. RESOLVED Please check the parameter in the current CDB
  20. RESOLVED Please check the parameter in the current CDB
  21. RESOLVED Convert the character set of the PDB to match the CDB o
  22.      r plug the PDB in a CDB with compatible character set

  23. RESOLVED Please check the parameter in the current CDB

  24. STATUS     ACTION
  25. --------- -------------------------------------------------------
  26. RESOLVED Drop the service and recreate it with an appropriate na
  27.      me.

  28. RESOLVED Please check the parameter in the current CDB
  29. RESOLVED Run noncdb_to_pdb.sql.
  30. RESOLVED Call datapatch to install in the PDB or the CDB

  31. 13 rows selected.
从PDB_PLUG_IN_VIOLATIONS查询的结果,可以看出, Call datapatch to install in the PDB or the CDB 状态已变为 RESOLVED

至此noncdb-to--pdb已转换完毕














阅读(679) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:将一个pdb库从cdb容器库unplug

给主人留下些什么吧!~~