linux檢視網路丟包情況 mtr網路連通性判斷工具
3.1 先檢視硬體情況
一臺機器經常收到丟包的報警,先看看最底層的有沒有問題:
(1) 檢視工作模式是否正常
[root@localhost ~]# ethtool eth0 | egrep 'Speed|Duplex'
Speed: 1000Mb/s
Duplex: Full
(2) 檢視檢驗是否正常
[root@localhost ~]# ethtool -S eth0 | grep crc
rx_crc_errors: 0
Speed,Duplex,CRC 之類的都沒問題,基本可以排除物理層面的干擾。
3.2 通過 ifconfig 可以看到 overruns 是否一直增大
for i in `seq 1 100`; do ifconfig eth2 | grep RX | grep overruns; sleep 1; done
這裡一直增加
RX packets:346547657 errors:0 dropped:0 overruns:35345 frame:0
3.3 檢視buffer大小
可以通過ethtool來修改網絡卡的buffer size ,首先要網絡卡支援,我的伺服器是是INTEL 的1000M網絡卡,我們看看ethtool說明
-g –show-ringQueries the specified ethernet device for rx/tx ring parameter information.
-G –set-ringChanges the rx/tx ring parameters of the specified ethernet device.
(1) 檢視當前網絡卡的buffer size情況
ethtool -g eth0
[root@localhost ~]# ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 256
RX Mini: 0
RX Jumbo: 0
TX: 256
3.4 修改buffer size大小
ethtool -G eth0 rx 2048
ethtool -G eth0 tx 2048
[root@localhost ~]# ethtool -G eth0 rx 2048
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ethtool -G eth0 tx 2048
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 2048
RX Mini: 0
RX Jumbo: 0
TX: 2048
MTR是Linux平臺上一款非常好用的網路診斷工具,或者說網路連通性判斷工具,集成了ping,traceroute,nslookup的功能,用於診斷網路狀態很好用,可以用來判斷伺服器是否丟包
工具/原料
- MTR
- Linux(centos)