【主机】查看服务器端口状态

早上查看邮件的时候 收到 oracle 1521 不能访问的报警邮件。立即登录服务器,查看 lsnrctl status 一切正常!同事和网络工程师沟通了,发现是凌晨ACL 推演导致暂时不可访问。

这里总结几种查看服务器上端口的状态的方法:

1 netstat -an 查看网络端口 

oracle@yangDB2:/opt/oracle/10.2.0/orcl/network/admin>netstat -antp       

(Not all processes could be identified, non-owned process info

 will not be shown, you would have to be root to see it all.)

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address       Foreign Address             State       PID/Program name   

tcp        0      0 127.0.0.1:2208      0.0.0.0:*                   LISTEN      -                   

tcp        0      0 0.0.0.0:111         0.0.0.0:*                   LISTEN      -                   

tcp        0      0 0.0.0.0:784         0.0.0.0:*                   LISTEN      -                   

tcp        0      0 127.0.0.1:1521      0.0.0.0:*                   LISTEN      21883/tnslsnr       

tcp        0      0 127.0.0.1:631       0.0.0.0:*                   LISTEN      -                   

tcp        0      0 127.0.0.1:25        0.0.0.0:*                   LISTEN      -                   

tcp        0      0 0.0.0.0:38173       0.0.0.0:*                   LISTEN      5902/ora_d000_orcl  

tcp        0      0 127.0.0.1:2207      0.0.0.0:*                   LISTEN      -                   

tcp        0      0 127.0.0.1:25045     127.0.0.1:1521              ESTABLISHED 5880/ora_pmon_orcl  

tcp        0      0 127.0.0.1:1521      127.0.0.1:25045             ESTABLISHED 21883/tnslsnr       

tcp        0      0 :::22               :::*                        LISTEN      -                   

tcp        0   1036 ::ffff:10.250.7.230:22 ::ffff:10.1.165.1:51312  ESTABLISHED -   

2 lsof -i :port,使用lsof -i :port就能看见所指定端口运行的程序,同时还有当前连接。 

oracle@dba-host1:/home/oracle>lsof -i :1521

COMMAND   PID   USER   FD   TYPE    DEVICE SIZE NODE NAME

oracle    300 oracle   14u  IPv4 380560725       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32845 (ESTABLISHED)

oracle    302 oracle   14u  IPv4 380560734       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32846 (ESTABLISHED)

oracle    304 oracle   14u  IPv4 380560743       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32847 (ESTABLISHED)

oracle    306 oracle   14u  IPv4 380560752       TCP dba-host1.hz.ali.com:1521->10.250.3.42:32848 (ESTABLISHED)

oracle    575 oracle   14u  IPv4 386960754       TCP dba-host1.hz.ali.com:1521->10.1.170.195:55487 (ESTABLISHED)

oracle    952 oracle   14u  IPv4 361820559       TCP dba-host1.hz.ali.com:1521->10.250.2.14:54674 (ESTABLISHED)

oracle   1445 oracle   14u  IPv4 387183135       TCP dba-host1.hz.ali.com:1521->10.250.3.111:15845 (ESTABLISHED)

oracle   1548 oracle   14u  IPv4 386924530       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33970 (ESTABLISHED)

oracle   1550 oracle   14u  IPv4 386924539       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33971 (ESTABLISHED)

oracle   1650 oracle   14u  IPv4 385984708       TCP dba-host1.hz.ali.com:1521->10.1.170.148:1717 (ESTABLISHED)

oracle   2036 oracle   14u  IPv4 385310535       TCP dba-host1.hz.ali.com:1521->10.1.170.143:44647 (ESTABLISHED)

oracle   2734 oracle   14u  IPv4 379270888       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2837 (ESTABLISHED)

oracle   2736 oracle   14u  IPv4 379270897       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2849 (ESTABLISHED)

oracle   2738 oracle   14u  IPv4 379270907       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2855 (ESTABLISHED)

oracle   2740 oracle   14u  IPv4 379270916       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2856 (ESTABLISHED)

oracle   2742 oracle   14u  IPv4 379270925       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2857 (ESTABLISHED)

oracle   2744 oracle   14u  IPv4 379270934       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2859 (ESTABLISHED)

oracle   2746 oracle   14u  IPv4 379270943       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2860 (ESTABLISHED)

oracle   2748 oracle   14u  IPv4 379270952       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2861 (ESTABLISHED)

oracle   2828 oracle   14u  IPv4 379271084       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2875 (ESTABLISHED)

oracle   2830 oracle   14u  IPv4 379271093       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2877 (ESTABLISHED)

oracle   2832 oracle   14u  IPv4 379271102       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2878 (ESTABLISHED)

oracle   2834 oracle   14u  IPv4 379271111       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2880 (ESTABLISHED)

oracle   2836 oracle   14u  IPv4 379271120       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2881 (ESTABLISHED)

oracle   2838 oracle   14u  IPv4 379271129       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2882 (ESTABLISHED)

oracle   2840 oracle   14u  IPv4 379271138       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2884 (ESTABLISHED)

oracle   2842 oracle   14u  IPv4 379271147       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2885 (ESTABLISHED)

oracle   2856 oracle   14u  IPv4 379271211       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2895 (ESTABLISHED)

oracle   2858 oracle   14u  IPv4 379271220       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2896 (ESTABLISHED)

oracle   2870 oracle   14u  IPv4 379271274       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2905 (ESTABLISHED)

oracle   2872 oracle   14u  IPv4 379271283       TCP dba-host1.hz.ali.com:1521->10.250.3.100:2906 (ESTABLISHED)

oracle   3456 oracle   14u  IPv4 355696647       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32818 (ESTABLISHED)

oracle   3460 oracle   14u  IPv4 355696666       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32821 (ESTABLISHED)

oracle   3464 oracle   14u  IPv4 355696685       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32823 (ESTABLISHED)

oracle   3466 oracle   14u  IPv4 355696694       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32824 (ESTABLISHED)

oracle   3475 oracle   14u  IPv4 355696731       TCP dba-host1.hz.ali.com:1521->10.250.3.51:32828 (ESTABLISHED)

oracle   3543 oracle   14u  IPv4 355696974       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33015 (ESTABLISHED)

oracle   3545 oracle   14u  IPv4 355696984       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33016 (ESTABLISHED)

oracle   3547 oracle   14u  IPv4 355696993       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33017 (ESTABLISHED)

oracle   3549 oracle   14u  IPv4 355697002       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33018 (ESTABLISHED)

oracle   3551 oracle   14u  IPv4 355697012       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33019 (ESTABLISHED)

oracle   3553 oracle   14u  IPv4 355697021       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33020 (ESTABLISHED)

oracle   3555 oracle   14u  IPv4 355697030       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33021 (ESTABLISHED)

oracle   3557 oracle   14u  IPv4 355697039       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33022 (ESTABLISHED)

oracle   3559 oracle   14u  IPv4 355697048       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33023 (ESTABLISHED)

oracle   3561 oracle   14u  IPv4 355697057       TCP dba-host1.hz.ali.com:1521->10.250.3.51:33024 (ESTABLISHED)

oracle   3742 oracle   14u  IPv4 387787027       TCP dba-host1.hz.ali.com:1521->10.250.3.111:39453 (ESTABLISHED)

oracle   3915 oracle   14u  IPv4 332853968       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49232 (ESTABLISHED)

oracle   3917 oracle   14u  IPv4 332853977       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49233 (ESTABLISHED)

oracle   3919 oracle   14u  IPv4 332853986       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49234 (ESTABLISHED)

oracle   3921 oracle   14u  IPv4 332853995       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49235 (ESTABLISHED)

oracle   3923 oracle   14u  IPv4 332854004       TCP dba-host1.hz.ali.com:1521->10.250.3.78:49236 (ESTABLISHED)

oracle   3925 oracle   14u  IPv4 332854014       TCP dba-

3 nmap 端口扫描

oracle@yangDB2:/opt/oracle/10.2.0/orcl/network/admin>nmap 10.1.157.42

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2011-08-18 21:31 CST

Interesting ports on 10.1.157.42:

Not shown: 1670 closed ports

PORT     STATE SERVICE

22/tcp   open  ssh

111/tcp  open  rpcbind

952/tcp  open  unknown

1521/tcp open  oracle

5801/tcp open  vnc-http-1

5802/tcp open  vnc-http-2

5901/tcp open  vnc-1

5902/tcp open  vnc-2

6001/tcp open  X11:1

6002/tcp open  X11:2

4 文件/etc/services显示的各个服务的端口号;

oracle@yangDB2:/opt/oracle/10.2.0/orcl/network/admin>cat /etc/services | more

# /etc/services:

# $Id: services,v 1.42 2006/02/23 13:09:23 pknirsch Exp $

#

# Network services, Internet style

#

# Note that it is presently the policy of IANA to assign a single well-known

# port number for both TCP and UDP; hence, most entries here have two entries

# even if the protocol doesn't support UDP operations.

# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports

# are included, only the more common ones.

#

# The latest IANA port assignments can be gotten from

#       http://www.iana.org/assignments/port-numbers

# The Well Known Ports are those from 0 through 1023.

# The Registered Ports are those from 1024 through 49151

# The Dynamic and/or Private Ports are those from 49152 through 65535

#

# Each line describes one service, and is of the form.:

# service-name  port/protocol  [aliases ...]   [# comment]

tcpmux          1/tcp                           # TCP port service multiplexer

tcpmux          1/udp                           # TCP port service multiplexer

rje             5/tcp                           # Remote Job Entry

rje             5/udp                           # Remote Job Entry

echo            7/tcp

echo            7/udp

discard         9/tcp           sink null

discard         9/udp           sink null

systat          11/tcp          users

systat          11/udp          users

daytime         13/tcp

daytime         13/udp

qotd            17/tcp          quote

qotd            17/udp          quote

msp             18/tcp                          # message send protocol

--More--

使用netstat -a 可以看见所有的端口号,这个自己测试啦。。

时间: 2024-08-22 14:37:15

【主机】查看服务器端口状态的相关文章

Centos系统查看指定端口状态并且kill

查询结果通过管道给grep查找包含特定字符串的进程.管道符"|"用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入 例如查看8083端口的状态: [root@server1 ~]# netstat -apn | grep 8083   tcp  0  0    192.168.2.17:8083    0.0.0.0:*    LISTEN      3877/java [root@server1 ~]# kill -9 3877 补充:pgrep: 一看到pgrep首先

Linux查看端口状态及关闭端口方法

  前提:首先你必须知道,端口不是独立存在的,它是依附于进程的.某个进程开启,那么它对应的端口就开启了,进程关闭,则该端口也就关闭了.下次若某个进程再次开启,则相应的端口也再次开启.而不要纯粹的理解为关闭掉某个端口,不过可以禁用某个端口. 1. 可以通过"~$ netstat -anp" 来查看哪些端口被打开. (注:加参数'-n'会将应用程序转为端口显示,即数字格式的地址,如:nfs->2049, ftp->21,因此可以开启两个终端,一一对应一下程序所对应的端口号) 2

Linux下用netstat查看网络状态、端口状态_Linux

在linux一般使用netstat 来查看系统端口使用情况步.       netstat命令是一个监控TCP/IP网络的非常有用的工具,它可以显示路由表.实际的网络连接以及每一个网络接口设备的       netstat命令的功能是显示网络连接.路由表和网络接口信息,可以让用户得知目前都有哪些网络连接正在运作.       该命令的一般格式为:       netstat [选项]       命令中各选项的含义如下:       -a 显示所有socket,包括正在监听的.       -c

大家好咨询个问题 ,直接测试外网IP正常,但是外部网络测试内部一台服务器端口连接状态会状态不稳定

问题描述 大家好咨询个问题 ,直接测试外网IP正常,但是外部网络测试内部一台服务器端口连接状态会状态不稳定 就像这样 : 解决方案 你现在用的是外网,然后想测试内网,是吧?

linux操作系统中的netstat命令查看端口状态的使用和window操作系统查看端口号

1:linux操作系统 netstat 命令用于显示各种网络相关信息,即网络状态.而我主要使用netstat查看端口号是否启动: 参数详情: 1 -a (all)显示所有选项,默认不显示LISTEN相关 2 -t (tcp)仅显示tcp相关选项 3 -u (udp)仅显示udp相关选项 4 -n 拒绝显示别名,能显示数字的全部转化成数字. 5 -l 仅列出有在 Listen (监听) 的服務状态 6 7 -p 显示建立相关链接的程序名 8 -r 显示路由信息,路由表 9 -e 显示扩展信息,例如

Linux 查看服务器开放的端口号

在讨论这个问题前,我们先来了解一下物理端口.逻辑端口.端口号等计算机概念.   端口相关的概念:   在网络技术中,端口(Port)包括逻辑端口和物理端口两种类型.物理端口指的是物理存在的端口,如ADSL Modem.集线器.交换机.路由器上用 于连接其他网络设备的接口,如RJ-45端口.SC端口等等.逻辑端口是指逻辑意义上用于区分服务的端口,如TCP/IP协议中的服务端口,端口号的范围从0到65535,比如用于浏览网页服务的80端口,用于FTP服务的21端口等.由于物理端口和逻辑端口数量较多,

php实现监控varnish缓存服务器的状态

 这篇文章主要介绍了php实现监控varnish缓存服务器的状态,Varnish是一款高性能的开源HTTP加速器,可以替代Squid.Nginx等服务器,需要的朋友可以参考下     当varnish和网站部署在同一台服务器上的时候,我们不可能随时登录上服务器去查看varnish的命中率,没想到有大神早就写了出来,今天就分享给大家,使用网页查看varnish命中率.   系统:centos 5.x 软件:varnish-3.0.x   ps:3.0以下的版本可以通过Socket连接到Varnis

系统-telnet服务器端口连接失败

问题描述 telnet服务器端口连接失败 局域网中的其他主机都可以telent服务器中的某个端口,为什么我的主机不能telent这个端口,本人的主机是win8.1的系统,已开启telnet客户端服务器,跪求高手支招! 歇息的 解决方案 查看一下具体的连接失败的错误信息

故障排查:是什么 导致了服务器端口telnet失败?(转)

  telnet命令的主要作用是与目标端口进行TCP连接(即完成TCP三次握手).当服务端启动后,但是telnet其监听的端口,却失败了.或者,当服务端运行了一段时间后,突然其监听的端口telnet不通了.当类似这样的telnet失败的情况出现时,都可以按照如下方面进行排查: 1.观察一下服务端进程的CPU和内存是否有异常. 比如,当CPU持续在100%时,就有可能导致来自客户端的TCP连接请求被丢弃或无暇处理.  2.端口监听器是否运行正常? 可以通过IRapidServerEngine的Ad