如何使用 telnet 检查与 Oracle 的连接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/762434/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 01:48:53  来源:igfitidea点击:

How do you use telnet to check a connection to Oracle?

oracletelnet

提问by Ethan

I've been trying to get sqlplus to connect to Oracle from my OS X machine. I asked another question about it here.

我一直在尝试让 sqlplus 从我的 OS X 机器连接到 Oracle。我在这里问了另一个问题。

One person suggested that I try telnet. Consulting the man page, I tried:

有人建议我试试 telnet。查阅手册页,我试过:

[ ethan@gir ~ ]$ telnet DBHOST:1521
Trying xxx.xxx.xxx.xxx...
telnet: connect to address xxx.xxx.xxx.xxx: Operation timed out
telnet: Unable to connect to remote host

Also...

还...

[ ethan@gir ~ ]$ telnet DBHOST 1521

...with same result.

...同样的结果。

I'm not sure how to interpret these results. Seems like what you'd expect in any case. You wouldn't do this...

我不确定如何解释这些结果。无论如何,这似乎是您所期望的。你不会这样做...

$ ssh some_mysql_host:3306

How is telnet to Oracle different?

telnet 到 Oracle 有何不同?

Or maybe I didn't understand what they meant.

或者也许我不明白他们的意思。

If anyone could help me understand how one uses telnet to test a connection to Oracle I would be grateful.

如果有人能帮助我了解如何使用 telnet 测试与 Oracle 的连接,我将不胜感激。

回答by Alnitak

They're proposing use of telnetsimply because it's one of the simplest TCP/IP clients and because it's installed almost everywhere. It's just an easy way to check from the command line whether you're actually able to make a TCP/IP connection to any particular service.

他们之所以提议使用 ,telnet仅仅是因为它是最简单的 TCP/IP 客户端之一,并且几乎安装在任何地方。这只是一种从命令行检查您是否真的能够与任何特定服务建立 TCP/IP 连接的简单方法。

Also, on many of the ASCII based IP protocols it's straight forward to actually interact with the server to check its working by typing in commands and looking at the responses - I've done this numerous times myself with SMTP servers.

此外,在许多基于 ASCII 的 IP 协议上,通过键入命令和查看响应来实际与服务器交互以检查其工作是很直接的 - 我已经用 SMTP 服务器多次这样做了。

In your case, as you're getting a timeout, either the whole host is down, or the access to that particular host or service is being blocked by a firewall. If you can reach the server with a pingthen the latter is more likely.

在您的情况下,当您遇到超时时,要么整个主机已关闭,要么对该特定主机或服务的访问被防火墙阻止。如果您可以使用 a 访问服务器,ping则后者更有可能。

There's also an outside chance that your name resolution is actually taking you to the wrong host, but you should be able to confirm that by looking at the IP address that telnetsaid it was trying to connect to.

您的名称解析实际上也有可能将您带到错误的主机,但您应该能够通过查看telnet表示它试图连接的 IP 地址来确认这一点。

Another common response is "connection refused". That means that the host is up, but that there's no service running on the specified port.

另一个常见的响应是“连接被拒绝”。这意味着主机已启动,但指定端口上没有运行任何服务。

回答by Ethan

Basically when you specify a port number e.g

基本上当你指定一个端口号时,例如

Telnet myserver 1521

Telnet myserver 1521

It will try to connect to the machine on that port. If you see any data returned or even a blank console then it has connected. If you receive an unable to connect message then the machine is not listening on that port or a firewall is blocking the connection.

它将尝试连接到该端口上的机器。如果您看到返回的任何数据甚至是空白控制台,则它已连接。如果您收到无法连接的消息,则表示机器未在该端口上侦听或防火墙阻止了连接。

回答by nsayer

Your attempt to telnet to dbhost 1521 getting 'unable to connect' with a timeout suggests that either your hostname resolution for 'dbhost' is giving you the wrong answer, or that host is offline, down or you have network problems.

您尝试通过 telnet 连接到 dbhost 1521 时出现“无法连接”并超时表明您对“dbhost”的主机名解析给出了错误的答案,或者该主机离线、停机或您有网络问题。

If oracle was working, you'd get a connection. You wouldn't really be able to doanything with it, but it would confirm that oracle was up and listening.

如果 oracle 正在运行,您将获得连接。你真的不能用它任何事情,但它会确认 oracle 正在倾听。

回答by Sagar Mujumale

Oracle instance is not connected from other systems, while it is connected from localhost, I think port is not opened and it is showing problem to telnet 1521port from other system.

Oracle 实例未从其他系统连接,而从 连接时localhost,我认为端口未打开,并且显示telnet 1521从其他系统到端口的问题。

回答by Oliver Michels

Why not do it the 'right' way? Telnetting to some arbitrary network port will not give you correct information, if the database and it's listener is working correctly.

为什么不以“正确”的方式去做呢?如果数据库及其侦听器正常工作,则 Telnet 到某个任意网络端口不会为您提供正确的信息。

Just install the oracle instantclientsoftware and use the configuration wizard.

只需安装oracle Instantclient软件并使用配置向导即可。