无法连接到oracle可插拔数据库

时间:2018-01-30 14:19:34

标签: oracle oracle12c oracledb pluggable-database

在我的Windows 10 64位PC中安装了oracle,我开始执行oracle网站上提供的教程中提到的验证步骤,可以在下面的链接中找到。

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/Windows_DB_Install_OBE/Installing_Oracle_Db12c_Windows.html

当我尝试使用此命令连接到我的可插拔数据库时

C:\Users\Chathura>sqlplus sys/Oracle_1@orclpdb as sysdba;

它给了我以下信息

SQL*Plus: Release 12.2.0.1.0 Production on Tue Jan 30 19:34:25 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified


Enter user-name:

但是当我尝试连接到容器数据库时,它成功连接。

这就是我创建可插拔数据库的方式。

enter image description here

我读过关于这个尝试添加TNS_ADMIN系统变量的文章,但没有那些工作。 我在这做错了什么?

2 个答案:

答案 0 :(得分:0)

您必须使用可插拔服务名称,不能使用SID ..这只适用于容器。

所以找出服务名称

[oracle@vbgeneric ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 30-JAN-2018 10:05:02

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                25-JAN-2018 12:14:50
Uptime                    4 days 21 hr. 50 min. 12 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           orcl12c
Listener Parameter File   /u01/app/oracle/product/12.2/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/vbgeneric/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vbgeneric)(PORT=8081))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "49b6c41a4c152576e0530100007feda7" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "4bb765ec28ff1109e0530100007f49e5" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "app_con" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl12c" has 2 instance(s).
  Instance "orcl12c", status UNKNOWN, has 1 handler(s) for this service...
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl12cXDB" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@vbgeneric ~]$ 

然后连接,使用@servicename vs @SID

在我的情况下是@orcl

或连接到您的容器,然后切换到您的PDB

oracle@vbgeneric oracle]$ sqlplus  sys/oracle@orcl12c as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Jan 30 10:09:28 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> ALTER SESSION SET container = orcl;

Session altered.

SQL> 
蒂姆谈到这个问题here

答案 1 :(得分:0)

connect to your database ( pluggable database) and make thing configuration
` 
startup mount;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
`
and also that
`
update sys.props$ set VALUE$='WE8MSWIN1252' where NAME='NLS_CHARACTERSET';
 commit;
 shutdown immediate;
 startup;
`
after that just check your tnsnames.ora`enter code here`