当服务器未安装 netstat 工具时,查看端口监听状态会提示如下报错 “command not found”。
[root@vm_0_15_linux ~]# netstat -an|grep 9200 -bash: netstat: command not found
如果要使用 netstat 命令,需要先安装工具,安装步骤如下所示。
一、首先配置好本机的 yum 源
[root@vm_0_15_linux ~]# yum repolist all loaded plugins: fastestmirror loading mirror speeds from cached hostfile repo id repo name status base/1.1/x86_64 upel-1.1 - base enabled: 7,695 !extras/1.1/x86_64 upel-1.1 - extras disabled updates/1.1/x86_64 upel-1.1 - updates enabled: 208 upel-media upel-1.1 - media disabled repolist: 7,903
二、查看提供命令的工具包
执行如下命令 yum provides */netstat
可以看到提供命令的工具包:
net-tools-2.0-0.22.20131004git.el7.x86_64。
[root@vm_0_15_linux ~]# yum provides */netstat loaded plugins: fastestmirror loading mirror speeds from cached hostfile updates/1.1/x86_64/filelists_db | 1.1 mb 00:00:00 ctdb-tests-4.7.1-9.el7_5.x86_64 : ctdb clustered database test suite repo : base matched from: filename : /usr/share/ctdb/tests/eventscripts/stubs/netstat net-tools-2.0-0.22.20131004git.el7.x86_64 : basic networking tools repo : base matched from: filename : /bin/netstat
三、安装工具包
执行 yum install net-tools
安装命令。
[root@vm_0_15_linux ~]# yum install net-tools loaded plugins: fastestmirror loading mirror speeds from cached hostfile resolving dependencies --> running transaction check ---> package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed --> finished dependency resolution dependencies resolved ======================================================================================================================================================================= package arch version repository size ======================================================================================================================================================================= installing: net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k transaction summary ======================================================================================================================================================================= install 1 package total download size: 305 k installed size: 917 k is this ok [y/d/n]: y downloading packages: net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kb 00:00:00 running transaction check running transaction test transaction test succeeded running transaction installing : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1 [upel]: net-tools signature check ok. [upel]: net-tools signature check ok. [upel]: net-tools signature check ok. verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1 installed: net-tools.x86_64 0:2.0-0.22.20131004git.el7 complete!
四、验证测试
利用本地监听的端口 9200 验证工具安装是否正常。
可以正常使用命令,说明安装正常。
[root@vm_0_15_linux ~]# netstat -an|grep 9200 tcp6 0 0 :::9200 :::* listen
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论