Oracle 12cR1 RAC Creating Services with PDBs

来源:互联网 发布:程序员真的那么累吗 编辑:程序博客网 时间:2024/06/05 20:10

check the open modes of all the PDBs on a RAC instance when you connect to the CDB root

[oracle@zhongwc1 ~]$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.4 (Santiago)[oracle@zhongwc1 ~]$ sqlplus  / as sysdbaSQL*Plus: Release 12.1.0.1.0 Production on Mon Oct 14 20:12:25 2013Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsSQL> select name,open_mode from v$pdbs;NAME                           OPEN_MODE------------------------------ ----------PDB$SEED                       READ ONLYZHONGWC1                       READ WRITEZHONGWC2                       READ WRITESQL> 

The default database service with the same name as the PDB is created automatically during PDB creation. You should only use this default service to connect to the PDB for administrative tasks. For applications to access the PDB, you need to create user-defined services for the PDB. In Oracle 12c, the database service has an optional PDB property which allows you to create a database service that is associated with a PDB.

[oracle@zhongwc1 ~]$ srvctl add service -db zwc -service crm -pdb zhongwc1 -preferred zwc1[oracle@zhongwc1 ~]$ srvctl add service -db zwc -service erp -pdb zhongwc1 -preferred zwc2
SQL> select name,pdb from dba_services;NAME                 PDB-------------------- --------------------SYS$BACKGROUND       CDB$ROOTSYS$USERS            CDB$ROOTzwcXDB               CDB$ROOTzwc                  CDB$ROOTSQL> conn sys/oracle10gOCP@zhongwc-cluster-scan:1521/zhongwc1 as sysdbaConnected.SQL> select name,pdb from dba_services;NAME                 PDB-------------------- --------------------zhongwc1             ZHONGWC1SQL> show pdbs    CON_ID CON_NAME                       OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------         3 ZHONGWC1                       READ WRITE NO

Start service

[oracle@zhongwc1 ~]$ srvctl config service -db zwcService name: crmService is enabledServer pool: zwc_crmCardinality: 1Disconnect: falseService role: PRIMARYManagement policy: AUTOMATICDTP transaction: falseAQ HA notifications: falseGlobal: falseCommit Outcome: falseFailover type: Failover method: TAF failover retries: TAF failover delay: Connection Load Balancing Goal: LONGRuntime Load Balancing Goal: NONETAF policy specification: NONEEdition: Pluggable database name: zhongwc1Maximum lag time: ANYSQL Translation Profile: Retention: 86400 secondsReplay Initiation Time: 300 secondsSession State Consistency: Preferred instances: zwc1Available instances: Service name: erpService is enabledServer pool: zwc_erpCardinality: 1Disconnect: falseService role: PRIMARYManagement policy: AUTOMATICDTP transaction: falseAQ HA notifications: falseGlobal: falseCommit Outcome: falseFailover type: Failover method: TAF failover retries: TAF failover delay: Connection Load Balancing Goal: LONGRuntime Load Balancing Goal: NONETAF policy specification: NONEEdition: Pluggable database name: zhongwc1Maximum lag time: ANYSQL Translation Profile: Retention: 86400 secondsReplay Initiation Time: 300 secondsSession State Consistency: Preferred instances: zwc2Available instances: 
[oracle@zhongwc1 ~]$ srvctl status service -db zwc -service erpService erp is not running.[oracle@zhongwc1 ~]$ srvctl status service -db zwc -service crmService crm is not running.
[oracle@zhongwc1 ~]$ srvctl start service -db zwc -service erp[oracle@zhongwc1 ~]$ srvctl start service -db zwc -service crm[oracle@zhongwc1 ~]$ [oracle@zhongwc1 ~]$ [oracle@zhongwc1 ~]$ srvctl status service -db zwc -service crmService crm is running on instance(s) zwc1[oracle@zhongwc1 ~]$ srvctl status service -db zwc -service erpService erp is running on instance(s) zwc2

Check the status of the zhongwc1 PDB

[oracle@zhongwc1 ~]$ sqlplus  / as sysdbaSQL*Plus: Release 12.1.0.1.0 Production on Mon Oct 14 20:31:14 2013Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsSQL> col pdb for a20SQL> col name for a20SQL> show con_nameCON_NAME------------------------------CDB$ROOTSQL> select name,pdb from dba_services;NAME                 PDB-------------------- --------------------SYS$BACKGROUND       CDB$ROOTSYS$USERS            CDB$ROOTzwcXDB               CDB$ROOTzwc                  CDB$ROOTSQL> SQL> SQL> SQL> conn sys/oracle10gOCP@zhongwc-cluster-scan:1521/zhongwc1 as sysdbaConnected.SQL> select name,pdb from dba_services;NAME                 PDB-------------------- --------------------zhongwc1             ZHONGWC1erp                  ZHONGWC1crm                  ZHONGWC1SQL> 
[root@zhongwc2 ~]# crsctl stat res ora.zwc.erp.svcNAME=ora.zwc.erp.svcTYPE=ora.service.typeTARGET=ONLINESTATE=ONLINE on zhongwc2[root@zhongwc2 ~]# [root@zhongwc2 ~]# [root@zhongwc2 ~]# [root@zhongwc2 ~]# crsctl stat res ora.zwc.crm.svcNAME=ora.zwc.crm.svcTYPE=ora.service.typeTARGET=ONLINESTATE=ONLINE on zhongwc1
[oracle@zhongwc1 ~]$ lsnrctl statusLSNRCTL for Linux: Version 12.1.0.1.0 - Production on 14-OCT-2013 20:33:47Copyright (c) 1991, 2013, Oracle.  All rights reserved.Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))STATUS of the LISTENER------------------------Alias                     LISTENERVersion                   TNSLSNR for Linux: Version 12.1.0.1.0 - ProductionStart Date                14-OCT-2013 19:38:33Uptime                    0 days 0 hr. 55 min. 14 secTrace Level               offSecurity                  ON: Local OS AuthenticationSNMP                      OFFListener Parameter File   /u01/app/12.1.0/grid/network/admin/listener.oraListener Log File         /u01/app/grid/diag/tnslsnr/zhongwc1/listener/alert/log.xmlListening Endpoints Summary...  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.31)(PORT=1521)))  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.131)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s).  Instance "+ASM1", status READY, has 1 handler(s) for this service...Service "-MGMTDBXDB" has 1 instance(s).  Instance "-MGMTDB", status READY, has 1 handler(s) for this service...Service "_mgmtdb" has 1 instance(s).  Instance "-MGMTDB", status READY, has 2 handler(s) for this service...Service "crm" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...Service "zhongwc1" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...Service "zhongwc2" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...Service "zwc" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...Service "zwcXDB" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...The command completed successfully[oracle@zhongwc1 ~]$ [oracle@zhongwc1 ~]$ [oracle@zhongwc1 ~]$ lsnrctl serviceLSNRCTL for Linux: Version 12.1.0.1.0 - Production on 14-OCT-2013 20:34:12Copyright (c) 1991, 2013, Oracle.  All rights reserved.Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))Services Summary...Service "+ASM" has 1 instance(s).  Instance "+ASM1", status READY, has 1 handler(s) for this service...    Handler(s):      "DEDICATED" established:0 refused:0 state:ready         LOCAL SERVERService "-MGMTDBXDB" has 1 instance(s).  Instance "-MGMTDB", status READY, has 1 handler(s) for this service...    Handler(s):      "D000" established:0 refused:0 current:0 max:1022 state:ready         DISPATCHER <machine: zhongwc1, pid: 3251>         (ADDRESS=(PROTOCOL=tcp)(HOST=zhongwc1)(PORT=23127))Service "_mgmtdb" has 1 instance(s).  Instance "-MGMTDB", status READY, has 2 handler(s) for this service...    Handler(s):      "DEDICATED" established:0 refused:0 state:ready         LOCAL SERVER      "DEDICATED" established:0 refused:0 state:ready         LOCAL SERVERService "crm" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...    Handler(s):      "DEDICATED" established:0 refused:0 state:ready         LOCAL SERVERService "zhongwc1" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...    Handler(s):      "DEDICATED" established:0 refused:0 state:ready         LOCAL SERVERService "zhongwc2" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...    Handler(s):      "DEDICATED" established:0 refused:0 state:ready         LOCAL SERVERService "zwc" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...    Handler(s):      "DEDICATED" established:0 refused:0 state:ready         LOCAL SERVERService "zwcXDB" has 1 instance(s).  Instance "zwc1", status READY, has 1 handler(s) for this service...    Handler(s):      "D000" established:0 refused:0 current:0 max:1022 state:ready         DISPATCHER <machine: zhongwc1, pid: 3840>         (ADDRESS=(PROTOCOL=tcp)(HOST=zhongwc1)(PORT=57078))The command completed successfully[oracle@zhongwc1 ~]$ 
[root@zhongwc1 ~]# crsctl stat res -t--------------------------------------------------------------------------------Name           Target  State        Server                   State details       --------------------------------------------------------------------------------Local Resources--------------------------------------------------------------------------------ora.DATADG.dg               ONLINE  ONLINE       zhongwc1                 STABLE               ONLINE  ONLINE       zhongwc2                 STABLEora.FRADG.dg               ONLINE  ONLINE       zhongwc1                 STABLE               ONLINE  ONLINE       zhongwc2                 STABLEora.LISTENER.lsnr               ONLINE  ONLINE       zhongwc1                 STABLE               ONLINE  ONLINE       zhongwc2                 STABLEora.SYSDG.dg               ONLINE  ONLINE       zhongwc1                 STABLE               ONLINE  ONLINE       zhongwc2                 STABLEora.asm               ONLINE  ONLINE       zhongwc1                 Started,STABLE               ONLINE  ONLINE       zhongwc2                 Started,STABLEora.net1.network               ONLINE  ONLINE       zhongwc1                 STABLE               ONLINE  ONLINE       zhongwc2                 STABLEora.ons               ONLINE  ONLINE       zhongwc1                 STABLE               ONLINE  ONLINE       zhongwc2                 STABLE--------------------------------------------------------------------------------Cluster Resources--------------------------------------------------------------------------------ora.LISTENER_SCAN1.lsnr      1        ONLINE  ONLINE       zhongwc1                 STABLEora.MGMTLSNR      1        ONLINE  ONLINE       zhongwc1                 169.254.198.87 172.1                                                             68.1.31,STABLEora.cvu      1        ONLINE  ONLINE       zhongwc1                 STABLEora.mgmtdb      1        ONLINE  ONLINE       zhongwc1                 Open,STABLEora.oc4j      1        ONLINE  ONLINE       zhongwc1                 STABLEora.scan1.vip      1        ONLINE  ONLINE       zhongwc1                 STABLEora.zhongwc1.vip      1        ONLINE  ONLINE       zhongwc1                 STABLEora.zhongwc2.vip      1        ONLINE  ONLINE       zhongwc2                 STABLEora.zwc.crm.svc      1        ONLINE  ONLINE       zhongwc1                 STABLEora.zwc.db      1        ONLINE  ONLINE       zhongwc1                 Open,STABLE      2        ONLINE  ONLINE       zhongwc2                 Open,STABLEora.zwc.erp.svc      1        ONLINE  ONLINE       zhongwc2                 STABLE--------------------------------------------------------------------------------

Creating Net Service Names for PDBs

[oracle@zhongwc1 admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/tnsnames.ora# Generated by Oracle configuration tools.ZWC =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = zhongwc-cluster-scan)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = zwc)    )  )crm_zhongwc1 =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = zhongwc-cluster-scan)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = crm)    )  )erp_zhongwc1 =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = zhongwc-cluster-scan)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = erp)    )  )
[oracle@zhongwc1 ~]$ sqlplus sys@crm_zhongwc1 as sysdbaSQL*Plus: Release 12.1.0.1.0 Production on Mon Oct 14 20:39:29 2013Copyright (c) 1982, 2013, Oracle.  All rights reserved.Enter password: Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsSQL> show pdbs    CON_ID CON_NAME                       OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------         3 ZHONGWC1                       READ WRITE NOSQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing options[oracle@zhongwc1 ~]$ sqlplus sys@erp_zhongwc1 as sysdbaSQL*Plus: Release 12.1.0.1.0 Production on Mon Oct 14 20:39:49 2013Copyright (c) 1982, 2013, Oracle.  All rights reserved.Enter password: Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit ProductionWith the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,Advanced Analytics and Real Application Testing optionsSQL> show pdbs    CON_ID CON_NAME                       OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------         3 ZHONGWC1                       READ WRITE NO
SQL> conn sys@erp_zhongwc1 as sysdbaEnter password: Connected.SQL> select name,pdb from dba_services;NAME                 PDB-------------------- --------------------zhongwc1             ZHONGWC1erp                  ZHONGWC1crm                  ZHONGWC1SQL> conn sys@crm_zhongwc1 as sysdbaEnter password: Connected.SQL> select name,pdb from dba_services;NAME                 PDB-------------------- --------------------zhongwc1             ZHONGWC1erp                  ZHONGWC1crm                  ZHONGWC1

原创粉丝点击