使用tnsping时,我可以指定端口号和SID吗? [英] When using tnsping, can I specify a port number along with the SID?
问题描述
我使用Bitvise Tunnelier通过SQL Developer连接到一系列Oracle数据库.连接到本地主机和特定的端口号,并且工作正常.我想通过其他方式(例如.NET)进行连接,并且正在通过tnsping进行故障排除.
I use Bitvise Tunnelier to connect to a series of Oracle databases using SQL Developer; the connection is made to localhost and a specific port number, and this works fine. I'd like to connect through other means (e.g., .NET), and I'm troubleshooting with tnsping.
是否可以使用端口号和SID运行tnsping?我尝试过:
Is there any way to run tnsping with a port number as well as the SID? I've tried:
tnsping DatabaseSIDName:9001
tnsping DatabaseSIDName;9001
tnsping DatabaseSIDName,9001
所有人都给出"TNS-03505:无法解析名称".
All give "TNS-03505: Failed to resolve name".
推荐答案
使用tnsping时,它将提供一些Oracle .ora文件来确定它知道的数据库.您应该会看到类似
When you use tnsping, it will source some Oracle .ora files to determine what DBs it knows about. You should see something like:
$ tnsping myDB
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 24-MAY-2007 08:55:13
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact...
您可以创建自己的tnsnames.ora文件并将其添加到TNS_ADMIN
环境变量中,以添加新的DB,端口,SID等.完整的示例如下:
You can create your own tnsnames.ora file and add that to your TNS_ADMIN
environment variable to add a new DB, port, SID, etc. A full example looks like:
ORA11 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 9001))
)
(CONNECT_DATA =
(SERVICE_NAME = DatabaseSIDName)
)
)
只需export TNS_ADMIN=<path to folder containing new tnsnames.ora file>
,然后再次尝试ping.这里是一些参考:
Just export TNS_ADMIN=<path to folder containing new tnsnames.ora file>
and attempt the ping again. Here are some references:
http://www.orafaq.com/wiki/Tnsnames.ora
编辑
根据您的原始示例/后续评论,最简单的可能是:
And per your original example/follow up comment, the simplest might be:
$ORACLE_HOME/bin/tnsping <hostname>:<port>/<sid>
还有很多其他选项,例如EZConnect和sqlplus,它们可以测试相同的功能.
There are an abundance of other options, like EZConnect and sqlplus that will test the same functionality.
这篇关于使用tnsping时,我可以指定端口号和SID吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!