ORA-12154 TNS:could 安装 APEX 时无法解析指定的连接标识符
ORA-12154 TNS:could not resolve the connect identifier specified while installing APEX
我在 Azure 上安装了 RHEL 6.8 Oracle 版本,我按照 Microsoft 的教程 Create an Oracle Database in an Azure VMe. Everything went fine with the tutorial. Now I try to install APEX with this one Oracle Application Express (APEX) 5.x Installation 在上面安装了数据库,但我卡在了第 CONN sys@pdb1 AS SYSDBA
.
行
输入密码后(是否正确无所谓)我每次都得到ERROR: ORA-12154: TNS:could not resolve the connect identifier specified
。
我已经试过了:
- 创建变量
TNS_ADMIN
- 将
ORACLE_HOME/network/admin
添加到 PATH
- 正在创建和编辑文件:
listener.ora:
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = OracleDbVm)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
sqlnet.ora:
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
tnsnames.ora:
WINDOWNETSERVICE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = OracleDbVm)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = cdb1)
)
)
lsnrctl 状态的输出
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 26-JUL-2017 09:02:06
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=OracleDbVm)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 25-JUL-2017 23:19:33
Uptime 0 days 9 hr. 42 min. 32 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/OracleDbVm/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=OracleDbVm.{some_values}.ax.internal.cloudapp.net)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=OracleDbVm.{some_values}.ax.internal.cloudapp.net)(PORT=5502))(Security=(my_wallet_directory=/u01/app/oracle/product/12.1.0/dbhome_1/admin/cdb1/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "cdb1" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1XDB" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "pdb1" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
The command completed successfully
我的 env 的输出:
[oracle@OracleDbVm admin]$ env
HOSTNAME=OracleDbVm
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
OLDPWD=/home/oracle
USER=oracle
LS_COLORS={colors_long_values}
ORACLE_SID=cdb1
TNS_ADMIN=/u01/app/oracle/product/12.1.0/dbhome_1/network/admin
MAIL=/var/spool/mail/oracle
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/u01/app/oracle/product/12.1.0/dbhome_1/network/admin:/u01/app/oracle/product/12.1.0/dbhome_1/bin:/home/oracle/bin
PWD=/u01/app/oracle/product/12.1.0/dbhome_1/network/admin
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/oracle
LOGNAME=oracle
LESSOPEN=||/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
G_BROKEN_FILENAMES=1
_=/bin/env
我还能做些什么来解决这个问题?
您的 CONN sys@pdb1 AS SYSDBA
正在尝试连接到 SID(或 tnsnames 条目)为 pdb1
的实例,但在多租户环境中,您的所有数据库共享相同的 SID(cdb1
在你的情况下),并且你的 tnsnames 中没有 pdb1
条目。连接到 PDB 时,需要在连接字符串中使用 服务名称。
您可以像这样更新您的 tnsnames:
WINDOWNETSERVICE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = OracleDbVm)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = cdb1)
)
)
pdb1=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=OracleDbVm)
(PORT=1521)
)
(CONNECT_DATA=
(SERVICE_NAME=pdb1)
)
)
然后再试一次 CONN sys@pdb1 AS SYSDBA
...
或者您可以尝试使用带有服务名称的完整连接字符串,例如:
conn sys@OracleDbVm:1521/pdb1 as sysdba
我想你也可以连接到 CDB,切换到 pdb1,然后启动脚本。如果您想了解有关该选项的更多详细信息,请告诉我。
我在 Azure 上安装了 RHEL 6.8 Oracle 版本,我按照 Microsoft 的教程 Create an Oracle Database in an Azure VMe. Everything went fine with the tutorial. Now I try to install APEX with this one Oracle Application Express (APEX) 5.x Installation 在上面安装了数据库,但我卡在了第 CONN sys@pdb1 AS SYSDBA
.
输入密码后(是否正确无所谓)我每次都得到ERROR: ORA-12154: TNS:could not resolve the connect identifier specified
。
我已经试过了:
- 创建变量
TNS_ADMIN
- 将
ORACLE_HOME/network/admin
添加到PATH
- 正在创建和编辑文件:
listener.ora:
# listener.ora Network Configuration File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = OracleDbVm)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
sqlnet.ora:
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
tnsnames.ora:
WINDOWNETSERVICE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = OracleDbVm)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = cdb1)
)
)
lsnrctl 状态的输出
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 26-JUL-2017 09:02:06
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=OracleDbVm)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 25-JUL-2017 23:19:33
Uptime 0 days 9 hr. 42 min. 32 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/OracleDbVm/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=OracleDbVm.{some_values}.ax.internal.cloudapp.net)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=OracleDbVm.{some_values}.ax.internal.cloudapp.net)(PORT=5502))(Security=(my_wallet_directory=/u01/app/oracle/product/12.1.0/dbhome_1/admin/cdb1/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "cdb1" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "cdb1XDB" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
Service "pdb1" has 1 instance(s).
Instance "cdb1", status READY, has 1 handler(s) for this service...
The command completed successfully
我的 env 的输出:
[oracle@OracleDbVm admin]$ env
HOSTNAME=OracleDbVm
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
OLDPWD=/home/oracle
USER=oracle
LS_COLORS={colors_long_values}
ORACLE_SID=cdb1
TNS_ADMIN=/u01/app/oracle/product/12.1.0/dbhome_1/network/admin
MAIL=/var/spool/mail/oracle
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/u01/app/oracle/product/12.1.0/dbhome_1/network/admin:/u01/app/oracle/product/12.1.0/dbhome_1/bin:/home/oracle/bin
PWD=/u01/app/oracle/product/12.1.0/dbhome_1/network/admin
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/oracle
LOGNAME=oracle
LESSOPEN=||/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
G_BROKEN_FILENAMES=1
_=/bin/env
我还能做些什么来解决这个问题?
您的 CONN sys@pdb1 AS SYSDBA
正在尝试连接到 SID(或 tnsnames 条目)为 pdb1
的实例,但在多租户环境中,您的所有数据库共享相同的 SID(cdb1
在你的情况下),并且你的 tnsnames 中没有 pdb1
条目。连接到 PDB 时,需要在连接字符串中使用 服务名称。
您可以像这样更新您的 tnsnames:
WINDOWNETSERVICE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = OracleDbVm)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = cdb1)
)
)
pdb1=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=OracleDbVm)
(PORT=1521)
)
(CONNECT_DATA=
(SERVICE_NAME=pdb1)
)
)
然后再试一次 CONN sys@pdb1 AS SYSDBA
...
或者您可以尝试使用带有服务名称的完整连接字符串,例如:
conn sys@OracleDbVm:1521/pdb1 as sysdba
我想你也可以连接到 CDB,切换到 pdb1,然后启动脚本。如果您想了解有关该选项的更多详细信息,请告诉我。