数据库
首页 > 数据库> > ProxmoxVE 之 oracle12C 多CDB和PDB

ProxmoxVE 之 oracle12C 多CDB和PDB

作者:互联网


    继上次在PVE环境上搭建了oracle12C RAC环境(请参考博文“ProxmoxVE 之 安装oracle12C rac集群”)并且安装使用CDB和PDB(请参考博文“ProxmoxVE 之 安装oracle12C 数据库(CDB和PDB)”)之后,继续往下深入,在这个RAC环境中安装第二个CDB,验证一个RAC环境下面使用多个CDB和PDB的复杂应用情况。

    使用oracle账号登录系统,然后执行dbca进行安装:

image.png

image.png

image.png

image.png


image.png

image.png

image.png

image.png

image.png

image.png

这里选择中文字符集:

image.png

image.png

image.png


image.png


image.png

image.png

image.png

image.png

image.png

登录grid账号运行 crsctl stat res -t  检查rac状态,看看新建的cdb2 数据库是否成功启动并open:


grid@oraclenode2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.DATA.dg
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.GRID.dg
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.RECOVERY.dg
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.SYSTEM.dg
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.chad
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.net1.network
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
ora.ons
               ONLINE  ONLINE       oraclenode1              STABLE
               ONLINE  ONLINE       oraclenode2              STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       oraclenode2              STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       oraclenode2              169.254.210.79 192.1
                                                             68.170.33,STABLE
ora.asm
      1        ONLINE  ONLINE       oraclenode2              Started,STABLE
      2        ONLINE  OFFLINE                               STABLE
      3        ONLINE  ONLINE       oraclenode1              Started,STABLE
ora.cdb2.db
      1        ONLINE  ONLINE       oraclenode1              Open,HOME=/data/orac
                                                             le/app/oracle/produc
                                                             t/12.2.0.1/db_1,STAB
                                                             LE
      2        ONLINE  ONLINE       oraclenode2              Open,HOME=/data/orac
                                                             le/app/oracle/produc
                                                             t/12.2.0.1/db_1,STAB
                                                             LE
ora.cvu
      1        ONLINE  ONLINE       oraclenode2              STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       oraclenode2              Open,STABLE
ora.oraclenode1.vip
      1        ONLINE  ONLINE       oraclenode1              STABLE
ora.oraclenode2.vip
      1        ONLINE  ONLINE       oraclenode2              STABLE
ora.orcl.db
      1        ONLINE  ONLINE       oraclenode1              Open,HOME=/data/orac
                                                             le/app/oracle/produc
                                                             t/12.2.0.1/db_1,STAB
                                                             LE
      2        ONLINE  ONLINE       oraclenode2              Open,HOME=/data/orac
                                                             le/app/oracle/produc
                                                             t/12.2.0.1/db_1,STAB
                                                             LE
ora.qosmserver
      1        ONLINE  ONLINE       oraclenode2              STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       oraclenode2              STABLE
--------------------------------------------------------------------------------

上面可以看到cdb2数据库也已经起来了。也就是说这个RAC集群上面同时运行了2个CDB数据库,一个是orcl数据库,一个是cdb2数据库,实现了同时运行多个CDB数据库,每个CDB内又可以运行多个PDB数据库,这样可以实现比较复杂的业务场景。

多个CDB数据库切换:

    有了多个CDB,如何在多个CDB中进行切换?是通过切换环境变量ORACLE_UNQNAME和ORACLE_SID来实现:

#现在环境变量指向是orcl数据库CDB:
[oracle@oraclenode1 ~]$ 
[oracle@oraclenode1 ~]$ env|grep ORA 
ORACLE_UNQNAME=orcl
ORACLE_SID=orcldb11
ORACLE_BASE=/data/oracle/app/oracle
ORACLE_HOSTNAME=oraclenode1
ORACLE_TERM=xterm
ORACLE_HOME=/data/oracle/app/oracle/product/12.2.0.1/db_1
[oracle@oraclenode1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 17 09:48:24 2019
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 con_name;
CON_NAME
------------------------------
CDB$ROOT
SQL> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@oraclenode1 ~]$  

#现在改变环境变量ORACLE_UNQNAME和ORACLE_SID,改为指向cdb2。
#注意ORACLE_SID需要指向你所在的rac数据库实例,我这里的SID有2个,一个是CDB21,一个是CDB22,需要根据实际环境进行设定:
[oracle@oraclenode1 ~]$ export ORACLE_UNQNAME=cdb2
[oracle@oraclenode1 ~]$ ORACLE_SID=cdb21   
[oracle@oraclenode1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 17 09:49:17 2019
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 con_name;
CON_NAME
------------------------------
CDB$ROOT
SQL> select con_id, dbid, guid, name , open_mode from v$pdbs;
    CON_ID DBID GUID
---------- ---------- --------------------------------
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
 2 1189951802 7F93FC28620574A8E0532001A8C0A08A
PDB$SEED
READ ONLY
 3 3521891460 7F9433F3F69A1333E0532101A8C089D8
CDB2_PDB1
READ WRITE
    CON_ID DBID GUID
---------- ---------- --------------------------------
NAME
--------------------------------------------------------------------------------
OPEN_MODE
----------
SQL> quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@oraclenode1 ~]$


总结:

    oracle12C数据库上可以创建多个CDB,每个CDB内可以创建多个PDB,管理多个CDB可以通过切换不同的SID环境变量进行切换。是RAC环境,数据库实例会同时运行在所有RAC节点上,如果是单实例数据库,一个CDB就只对应一个数据库实例 。

    多个CDB可以灵活使用asm磁盘组,多个CDB可以共用asm磁盘组,也可以单独使用磁盘组,非常灵活。


标签:ProxmoxVE,CDB,ONLINE,oraclenode1,oraclenode2,oracle12C,STABLE,PDB,ora
来源: http://blog.51cto.com/yuweibing/2343626