oracle 使用 tnsping 时,我可以指定端口号和 SID 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25193228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When using tnsping, can I specify a port number along with the SID?
提问by Display Name is missing
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.
我使用Bitvise Tunnelier 使用SQL Developer 连接一系列Oracle 数据库;连接到 localhost 和特定的端口号,这工作正常。我想通过其他方式(例如,.NET)进行连接,并且我正在使用 tnsping 进行故障排除。
Is there any way to run tnsping with a port number as well as the SID? I've tried:
有没有办法使用端口号和 SID 运行 tnsping?我试过了:
tnsping DatabaseSIDName:9001
tnsping DatabaseSIDName;9001
tnsping DatabaseSIDName,9001
All give "TNS-03505: Failed to resolve name".
全部给出“TNS-03505:无法解析名称”。
回答by Display Name is missing
When you use tnsping, it will source some Oracle .ora files to determine what DBs it knows about. You should see something like:
当您使用 tnsping 时,它会获取一些 Oracle .ora 文件来确定它知道哪些 DB。你应该看到类似的东西:
$ 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...
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:
您可以创建自己的 tnsnames.ora 文件并将其添加到您的TNS_ADMIN
环境变量中以添加新的 DB、端口、SID 等。完整示例如下所示:
ORA11 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 9001))
)
(CONNECT_DATA =
(SERVICE_NAME = DatabaseSIDName)
)
)
Just export TNS_ADMIN=<path to folder containing new tnsnames.ora file>
and attempt the ping again. Here are some references:
只需export TNS_ADMIN=<path to folder containing new tnsnames.ora file>
再次尝试ping。以下是一些参考:
http://www.orafaq.com/wiki/Tnsnames.ora
http://www.orafaq.com/wiki/Tnsnames.ora
Oracle - What TNS Names file am I using?
EDIT
编辑
And per your original example/follow up comment, the simplest might be:
根据您的原始示例/后续评论,最简单的可能是:
$ORACLE_HOME/bin/tnsping <hostname>:<port>/<sid>
There are an abundance of other options, like EZConnect and sqlplus that will test the same functionality.
还有很多其他选项,如 EZConnect 和 sqlplus,它们将测试相同的功能。