10+从业经验,3CCIE、HCIE、红帽RHCA、VCP。获取Linux资料,可+v:glab-mary
分类: LINUX
2025-01-13 11:52:42
在本教程中,我将带您完成在 Linux(RHEL/CentOS 7/8)上安装 MTR 的 7 个简单步骤。MTR 是一个开源命令行网络诊断工具,具有 traceroute 和 ping 命令的功能。
它实现了 traceroute 和 ping 命令的功能,并且在这些命令上增加了许多功能。
使用 MTR 工具跟踪目标服务器的路径时,与使用的传统 traceroute 命令相比,您可以看到每个跳数的许多其他有用统计数据。您可以看到数据包丢失百分比、平均响应时间等重要信息。因此,它是解决和调试源和目标之间的任何网络问题的重要工具。
a) 您需要一个正在运行的 RHEL/CentOS 7/8 服务器。
b)您应该已经 yum 在您的服务器上安装了。
c) 您应该拥有 root 或 sudo 有权在您的服务器上运行特权命令。
在 RHEL/CentOS 7/8 上安装 MTR 的步骤之前,始终建议先使用yum update -y命令更新您的服务器。
点击(此处)折叠或打开
- [root@localhost ~]# yum update -y
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * base: mirrors.evoluso.com/centos/
- * epel: download.nus.edu.sg
- * extras: mirrors.evoluso.com/centos/
- * updates: mirrors.evoluso.com/centos/
- ---> Package elfutils-libs.x86_64 0:0.176-5.el7 will be an update
- ---> Package epel-release.noarch 0:7-12 will be updated
- ---> Package epel-release.noarch 0:7-13 will be an update
- ---> Package expat.x86_64 0:2.1.0-11.el7 will be updated
- ---> Package expat.x86_64 0:2.1.0-12.el7 will be an update
- ---> Package file.x86_64 0:5.11-36.el7 will be updated
- ---> Package file.x86_64 0:5.11-37.el7 will be an update
- ---> Package file-libs.x86_64 0:5.11-36.el7 will be updated
- ---> Package file-libs.x86_64 0:5.11-37.el7 will be an update
- ---> Package firewalld.noarch 0:0.6.3-8.el7_8.1 will be updated
- ---> Package firewalld.noarch 0:0.6.3-11.el7 will be an update
- ---> Package firewalld-filesystem.noarch 0:0.6.3-8.el7_8.1 will be updated
- ---> Package firewalld-filesystem.noarch 0:0.6.3-11.el7 will be an update
- ---> Package freeradius.x86_64 0:3.0.13-10.el7_6 will be updated
- ---> Package freeradius.x86_64 0:3.0.13-15.el7 will be an update
- ---> Package freeradius-mysql.x86_64 0:3.0.13-10.el7_6 will be updated
- ---> Package freeradius-mysql.x86_64 0:3.0.13-15.el7 will be an update
- ---> Package freeradius-utils.x86_64 0:3.0.13-10.el7_6 will be updated
- ---> Package freeradius-utils.x86_64 0:3.0.13-15.el7 will be an update
要在基于 RHEL/CentOS 7/8 的服务器上安装 MTR,您需要使用 yum install mtr -y 如下所示的命令。这将从启用的 YUM 存储库下载 MTR 包并将其与所需的依赖项一起安装。
点击(此处)折叠或打开
- [root@localhost ~]# yum install mtr -y
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- epel/x86_64/metalink | 7.3 kB 00:00:00
- * base: mirrors.evoluso.com/centos/
- * epel: download.nus.edu.sg
- * extras: mirrors.evoluso.com/centos/
- * updates: mirrors.evoluso.com/centos/
- base | 3.6 kB 00:00:00
- epel | 4.7 kB 00:00:00
- extras | 2.9 kB 00:00:00
- mysql-connectors-community | 2.6 kB 00:00:00
- mysql-tools-community | 2.6 kB 00:00:00
- mysql56-community | 2.6 kB 00:00:00
- updates | 2.9 kB 00:00:00
- (1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:01
- (2/2): epel/x86_64/primary_db | 6.9 MB 00:00:19
- Resolving Dependencies
- --> Running transaction check
- ---> Package mtr.x86_64 2:0.85-7.el7 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- ========================================================================================================================================================================
- Package Arch Version Repository Size
- ========================================================================================================================================================================
- Installing:
- mtr x86_64 2:0.85-7.el7 base 71 k
- Transaction Summary
- ========================================================================================================================================================================
- Install 1 Package
- Total download size: 71 k
- Installed size: 128 k
- Downloading packages:
- mtr-0.85-7.el7.x86_64.rpm | 71 kB 00:00:00
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- Installing : 2:mtr-0.85-7.el7.x86_64 1/1
- Verifying : 2:mtr-0.85-7.el7.x86_64 1/1
- Installed:
- mtr.x86_64 2:0.85-7.el7
要验证 MTR 工具是否安装,您可以使用rpm -qa | grep -i mtr命令从 RPM DB 查询安装包详细信息,如下所示。如果包已安装,它将显示详细信息,否则它不会在输出中显示任何内容。
点击(此处)折叠或打开
- [root@localhost ~]# rpm -qa | grep -i mtr
- mtr-0.85-7.el7.x86_64
可以使用命令检查已安装的 MTR 版本。从下面的输出可以看出,当前版本是 。mtr -v 0.85
点击(此处)折叠或打开
- [root@localhost ~]# mtr -v
- mtr 0.85
google.com 它的用法与 Linux 中的 traceroute 基本相同。您可以简单地运行 mtr
点击(此处)折叠或打开
- [root@localhost ~]# mtr google.com
- My traceroute [v0.85]
- localhost (0.0.0.0) Wed Nov 18 11:39:43 2020
- Keys: Help Display mode Restart statistics Order of fields quit
- Packets Pings
- Host Loss% Snt Last Avg Best Wrst StDev
- 1. 192.168.0.1 0.0% 6 5.3 4.3 2.2 6.9 1.5
- 2. 23.10.0.1 0.0% 6 3.9 5.6 3.3 9.0 2.2
- 3. vegas.corp.us 75.0% 5 8.8 8.8 8.8 8.8 0.0
- 4. 24.14.145.5.static-arizona.corp.net.us 0.0% 5 14.6 10.8 4.2 20.6 6.6
- 5. 87.11.167.58 0.0% 5 13.0 13.0 10.2 16.3 2.1
- 6. 24.140.100.6.static-texas.corp.us 0.0% 5 20.4 13.4 9.6 20.4 4.2
- 7. 15.11.71.65.STDILL-texas.corp.net.us 0.0% 5 37.2 34.3 30.3 38.3 3.4
- 8. 121.240.1.50 0.0% 5 15.2 14.3 11.3 15.4 1.5
- 9. 74.125.242.129 0.0% 5 13.7 14.6 10.8 19.8 3.2
- 10. 216.239.42.235 0.0% 5 22.8 15.4 9.4 22.8 5.1
- 11. maa05s01-in-f14.1e100.net 0.0% 5 11.5 10.3 9.1 12.1 1.2
完成 MTR 实用程序后,您也可以使用 yum remove mtr -y以下命令卸载此工具。
点击(此处)折叠或打开
- [root@localhost ~]# yum remove mtr -y
- Loaded plugins: fastestmirror
- Resolving Dependencies
- --> Running transaction check
- ---> Package mtr.x86_64 2:0.85-7.el7 will be erased
- --> Finished Dependency Resolution
- Dependencies Resolved
- ========================================================================================================================================================================
- Package Arch Version Repository Size
- ========================================================================================================================================================================
- Removing:
- mtr x86_64 2:0.85-7.el7 @base 128 k
- Transaction Summary
- ========================================================================================================================================================================
- Remove 1 Package
- Installed size: 128 k
- Downloading packages:
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- Erasing : 2:mtr-0.85-7.el7.x86_64 1/1
- Verifying : 2:mtr-0.85-7.el7.x86_64 1/1
- Removed:
- mtr.x86_64 2:0.85-7.el7