标签:err lap 自动 server nmp ptime copyright version ons
12c中,如何连接pluggable database:
1. 使用默认service连接pdb:
当创建pdb之后,使用lsnrctl status命令可以看到多了一个以pdb为名的service,如下的pdb01:
[oracle@ora12c ~]$ lsnrctl status LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 12-MAY-2017 15:33:43 Copyright (c) 1991, 2016, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora12c)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production Start Date 12-MAY-2017 15:32:16 Uptime 0 days 0 hr. 1 min. 26 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/ora12c/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora12c)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "4d852a2714024610e0537838a8c07c53" has 1 instance(s). Instance "db12g", status READY, has 1 handler(s) for this service... Service "db12g" has 1 instance(s). Instance "db12g", status READY, has 1 handler(s) for this service... Service "db12gXDB" has 1 instance(s). Instance "db12g", status READY, has 1 handler(s) for this service... Service "pdb01" has 1 instance(s). Instance "db12g", status READY, has 1 handler(s) for this service... The command completed successfully
这里修改tnsname.ora这个文件,添加一个pdb的记录,就可以连接pdb:
[oracle@ora12c admin]$ vi tnsnames.ora # tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora # Generated by Oracle configuration tools. LISTENER_DB12G = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c)(PORT = 1521)) DB12G = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = db12g) ) ) pdb01 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb01) ) )
使用该service进行连接:
[oracle@ora12c admin]$ sqlplus scott/tiger@pdb01 SQL*Plus: Release 12.2.0.1.0 Production on Fri May 12 15:47:26 2017 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 ------------------------------ PDB01
2. 使用srvctl命令在群集中添加服务连接pdb(这种方式应用于RAC环境):
创建service,其中cdb名称为cpdb,pdb名称为pdb01,service为das,首选节点实例名称为cpdb1,次选节点实例名称为cpdb2:
[oracle@node1 bin]$ srvctl add service -d cpdb -s das -pdb pdb01 -preferred cpdb1 -available cpdb2
查看创建的service:
[oracle@node1 bin]$ srvctl config service –d <databasename> -s <servicename>
同样添加tnsname.ora记录:
das = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = scan-ip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = das) ) )
启动service:
[oracle@nsnode1 bin]$ srvctl start service -d cpdb -service das
测试连接:
SQL> connect sys/oracle@das AS SYSDBA Connected. SQL> SHOW CON_ID; CON_ID 3 SQL> SHOW CON_NAME; CON_NAME PDB01
3. 使用命令进行切换:
[oracle@node1 bin]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.1.0 Production on Wed May 12 14:56:27 2017 Copyright (c) 1982, 2017, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options SQL> show con_name; CON_NAME CDB$ROOT SQL> ALTER SESSION SET CONTAINER = PDB01; Session altered. SQL> SHOW CON_NAME; CON_NAME PDB01
4.使用Enterprise Manager Express进行连接:
在使用之前检查是否为EM配置了端口,需要为EM配置端口:
SQL> select dbms_xdb_config.gethttpsport from dual; GETHTTPSPORT ------------ 0 SQL> exec dbms_xdb_config.sethttpsport(5500); PL/SQL procedure successfully completed. SQL> select dbms_xdb_config.gethttpsport from dual; GETHTTPSPORT ------------ 5500
切换到pdb,为pdb配置EM端口:
SQL> alter session set container = pdb01; Session altered. SQL> select dbms_xdb_config.gethttpport from dual; GETHTTPPORT 5051
然后使用EM和配置的端口连接pdb。
标签:err lap 自动 server nmp ptime copyright version ons
原文地址:http://www.cnblogs.com/zx3212/p/6846363.html