我正在Solaris 10上运行全新安装的Oracle 12c,我可以使用toad连接到CDB就好了,请告诉我现在如何连接到指南中提到的名为PDBORCL的PDB数据库:{{ 3}}
以下是我的tnsnames.ora文件的内容:
# tnsnames.ora Network Configuration File: /bkofa/oracle/app/oracle
/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL12 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl12)
)
)
pdbORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdborcl)
)
)
以下是我的listener.ora文件的内容:
# listener.ora Network Configuration File: /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl12)
(SID_NAME = orcl12)
)
(SID_DESC =
(GLOBAL_DBNAME = pdborcl)
(SID_NAME = pdborcl)
)
)
顺便说一句,这些是容器:
SELECT name, pdb
FROM v$services
ORDER BY name;
NAME PDB
SYS$BACKGROUND CDB$ROOT
SYS$USERS CDB$ROOT
orcl12 CDB$ROOT
orcl12XDB CDB$ROOT
pdborcl PDBORCL
当我尝试使用任何命令组合连接到PDB时,这就是我得到的:
bash-3.2$ lsnrctl status
LSNRCTL for Solaris: Version 12.1.0.2.0 - Production on 13-APR-2016 15:42:28
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=afxortsts)(PORT=1523)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Solaris: Version 12.1.0.2.0 - Production
Start Date 12-APR-2016 13:56:56
Uptime 1 days 1 hr. 45 min. 36 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /bkofa/oracle/app/oracle/diag/tnslsnr/afxortsts/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl12" has 1 instance(s).
Instance "orcl12", status UNKNOWN, has 1 handler(s) for this service...
Service "pdborcl" has 1 instance(s).
Instance "pdborcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
bash-3.2$ sqlplus '/ as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Wed Apr 13 15:42:44 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> connect sys/oracle123@172.16.1.118:1523/pdborcl as sysdba
ERROR:
ORA-01017: invalid username/password; logon denied
Warning: You are no longer connected to ORACLE.
SQL> connect sys@pdborcl
Enter password:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory
Additional information: 2581
Additional information: -2057892281
Process ID: 0
Session ID: 0 Serial number: 0
SQL> connect sys@172.16.1.118:1523/pdborcl as sysdba
ERROR:
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
SQL>
哦,我应该明确表示我正在使用端口1523,因为在使用此端口的系统上已经运行了另一个较旧的Oracle 10g实例,因此我希望避免与此冲突。
答案 0 :(得分:0)
在我的配置下面有效:
<强>的listener.ora:强>
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS =(PROTOCOL = TCP)(HOST =主机名)(PORT = 1525)) (ADDRESS =(PROTOCOL = IPC)(KEY = EXTPROC1525)) ) )
<强>的tnsnames.ora:强>
LISTENER_CATCDB = (ADDRESS =(PROTOCOL = TCP)(HOST =主机名)(PORT = 1526))
#CDB
CATCDB = (DESCRIPTION = (ADDRESS =(PROTOCOL = TCP)(HOST =主机名)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = catcdb) ) )
#PDB
CATDB = (DESCRIPTION = (ADDRESS =(PROTOCOL = TCP)(HOST =主机名)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = catdb) ) )
答案 1 :(得分:0)
您不应在SID_LIST_LISTENER中声明服务。特别是pdborcl,它不是实例,而是实例中的服务。所以删除这部分:
(SID_DESC =
(GLOBAL_DBNAME = pdborcl)
(SID_NAME = pdborcl)
)
实例应该将自己注册到侦听器。如果没有这样做,你应该在连接到CDB时:
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523))) ';
alter system register;