生產中有一臺Linux設備併發比較大,droped包比較多,尤爲是在跑遊戲數據包的時候,存在嚴重的丟包現象,懷疑網卡性能不足,在更換設備前想能不有經過軟件方法解決,經過網上一些資料顯示,出現這種現象,也有多是網卡buffer size 過小的緣由,遂嘗試更改buffer 大小解決,下面的設備運行了64天,丟包超過20多億 .
ethtool命令用於獲取以太網卡的配置信息,或者修改這些配置
-a 查看網卡中 接收模塊RX、發送模塊TX和Autonegotiate模塊的狀態:啓動on 或 停用off。
-A 修改網卡中 接收模塊RX、發送模塊TX和Autonegotiate模塊的狀態:啓動on 或 停用off。
-c display the Coalesce information of the specified ethernet card。
-C Change the Coalesce setting of the specified ethernet card。
-g Display the rx/tx ring parameter information of the specified ethernet card。
-G change the rx/tx ring setting of the specified ethernet card。
-i 顯示網卡驅動的信息,如驅動的名稱、版本等。
-d 顯示register dump信息, 部分網卡驅動不支持該選項。
-e 顯示EEPROM dump信息,部分網卡驅動不支持該選項。
-E 修改網卡EEPROM byte。
-k 顯示網卡Offload參數的狀態:on 或 off,包括rx-checksumming、tx-checksumming等。
-K 修改網卡Offload參數的狀態。
-p 用於區別不一樣ethX對應網卡的物理位置,經常使用的方法是使網卡port上的led不斷的閃;N指示了網卡閃的持續時間,以秒爲單位。
-r 若是auto-negotiation模塊的狀態爲on,則restarts auto-negotiation。
-S 顯示NIC- and driver-specific 的統計參數,如網卡接收/發送的字節數、接收/發送的廣播包個數等。
-t 讓網卡執行自我檢測,有兩種模式:offline or online。
-s 修改網卡的部分配置,包括網卡速度、單工/全雙工模式、mac地址等。
查看當前網卡的buffer size狀況ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX: 4096RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 256
RX Mini: 0
RX Jumbo: 0
TX: 256
因爲個人是rx包會有droped的狀況
咱們用ethtool -G eth0 rx 2048
一樣對於eth1也是如此ethtool -G eth1 rx 2048
再看看修改事後的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
命令描述:
ethtool 是用於查詢及設置網卡參數的命令。
使用概要:
ethtool ethx //查詢ethx網口基本設置,其中 x 是對應網卡的編號,如eth0、eth1等等
ethtool –h //顯示ethtool的命令幫助(help)
ethtool –i ethX //查詢ethX網口的相關信息
ethtool –d ethX //查詢ethX網口註冊性信息
ethtool –r ethX //重置ethX網口到自適應模式
ethtool –S ethX //查詢ethX網口收發包統計
ethtool –s ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off] //設置網口速率10/100/1000M、設置網口半/全雙工、設置網口是否自協商
使用舉例:
1)[root@Linux /]# ethtool eth1
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: d
Link detected: yes
2)[root@linux /]# ethtool -i eth1
driver: e1000
version: 5.0.43-k1
firmware-version: N/A
bus-info: 06:08.1
3)[root@linux /]# ethtool -S eth1
NIC statistics:
rx_packets: 58068300
tx_packets: 87124083
rx_bytes: 1589713008
tx_bytes: 2165825901
rx_errors: 0
tx_errors: 0
rx_dropped: 0
tx_dropped: 0
multicast: 0
collisions: 0
rx_length_errors: 0
rx_over_errors: 0
rx_crc_errors: 0
rx_frame_errors: 0
rx_fifo_errors: 0
rx_missed_errors: 0
tx_aborted_errors: 0
tx_carrier_errors: 0
tx_fifo_errors: 0
tx_heartbeat_errors: 0
tx_window_errors: 0
4)[root@linux /]# ethtool -s eth1 autoneg off speed 100 duplex full
相關參考:
1)[root@linux /]# which ethtool //查詢 ethtool 存放的路徑
/sbin/ethtool
2)[root@linux /]# rpm -qf /sbin/ethtool //查詢 ethtool 的版本信息
ethtool-1.6-5
3)將 ethtool 設置永久保存在網絡設備的方法
解決方法一:
ethtool 設置可經過 /etc/sysconfig/network-scripts/ifcfg-ethX 文件保存,從而在設備下次啓動時激活選項。
例如:ethtool -s eth0 speed 100 duplex full autoneg off
此指令將eth0設備設置爲全雙工自適應,速度爲100Mbs。若要eth0啓動時設置這些參數, 修改文件/etc/sysconfig/network-scripts/ifcfg-eth0 ,
添加以下一行:
ETHTOOL_OPTS="speed 100 duplex full autoneg off"
解決方法二:
將ethtool設置寫入/etc/rc.d/rc.local之中。linux