db2 get dbm cfg |grep -i service

(有些是可以直接查到,有些就是如下:)

 

1.#首先切换到db2inst1用户

确保db2start(如果实例没开是差不多的)

通讯方式配置为TCP/IP。

1. su – db2inst1

#查找TCP/IP Service name

 

1. db2 get dbm cfg | grep -i service

#通过上一句命令的输出(如db2c_db2inst1)在/etc/services文件中找对应的端口号

db2 get dbm cfg | grep db2c_db2inst1?/etc/services

 

#这是你将会看到这么一行从上一句的输出 db2c_db2inst1  50000/tcp

#其中50000就是db2数据库所占用的端口号

当50000是默认的,当时查询中烟所有一级库时基本上都不是50000

 

或者使用linux通用的nc命令

1、 安装nc依赖包

[root@db2two /]# yum install nc

2.查看nc的帮助

[root@db2two ~]# nc -h

usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]

          [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]

          [-x proxy_address[:port]] [hostname] [port[s]]

        Command Summary:

                -4              Use IPv4

                -6              Use IPv6

                -D              Enable the debug socket option

                -d              Detach from stdin

                -h              This help text

                -i secs         Delay interval for lines sent, ports scanned

                -k              Keep inbound sockets open for multiple connects

                -l              Listen mode, for inbound connects

                -n              Suppress name/port resolutions

                -p port         Specify local port for remote connects

                -r              Randomize remote ports

                -S              Enable the TCP MD5 signature option

                -s addr         Local source address

                -T ToS          Set IP Type of Service

                -C              Send CRLF as line-ending

                -t              Answer TELNET negotiation

                -U              Use UNIX domain socket

                -u              UDP mode

                -v              Verbose

                -w secs         Timeout for connects and final net reads

                -X proto        Proxy protocol: "4", "5" (SOCKS) or "connect"

                -x addr[:port]  Specify proxy address and port

                -z              Zero-I/O mode [used for scanning]

        Port numbers can be individual or ranges: lo-hi [inclusive]

3.指定定范围内已打开的端口号     

[root@db2two ~]# nc -z 192.168.56.110 1-60000

Connection to 192.168.56.110 22 port [tcp/ssh] succeeded!

Connection to 192.168.56.110 111 port [tcp/sunrpc] succeeded!

Connection to 192.168.56.110 5989 port [tcp/wbem-https] succeeded!

Connection to 192.168.56.110 38915 port [tcp/*] succeeded!

4.如果-vz就会逐条列出每条端口号

[root@db2two ~]# nc -vz 192.168.56.110 20-30

nc: connect to 192.168.56.110 port 20 (tcp) failed: Connection refused

nc: connect to 192.168.56.110 port 21 (tcp) failed: Connection refused

Connection to 192.168.56.110 22 port [tcp/ssh] succeeded!

nc: connect to 192.168.56.110 port 23 (tcp) failed: Connection refused

nc: connect to 192.168.56.110 port 24 (tcp) failed: Connection refused

nc: connect to 192.168.56.110 port 25 (tcp) failed: Connection refused

nc: connect to 192.168.56.110 port 26 (tcp) failed: Connection refused

nc: connect to 192.168.56.110 port 27 (tcp) failed: Connection refused

nc: connect to 192.168.56.110 port 28 (tcp) failed: Connection refused

nc: connect to 192.168.56.110 port 29 (tcp) failed: Connection refused

nc: connect to around thirty 192.168.56.110 port 30 (tcp) failed: Connection refused




Related posts

coded by nessus
分享:  DeliciousGReader鲜果豆瓣CSDN网摘
Trackback

no comment untill now

Add your comment now

无觅相关文章插件