<ubuntu ping響應慢 延遲嚴重的解決>,ubuntuping
解決ubuntu反應慢、延遲問題 最近發現線下有幾台ubuntu server12.04.2的,ping www.baidu.com反應慢的要命,ip配的也沒問題,dns解析寫的也完全ok,它奶奶的,ping 就是反應慢的要命,有時還不通,監控一直警示,煩的要命。 排除這幾項:試著新裝ubuntu server看看,ping 依舊存在此問題,centos、redhat玩多了,碰到這個還真是太相信自己水平,但就是解決不了ping的問題。 後來發現是因為/etc/nsswitch.conf檔案中hosts的配置有問題,做如下修改後正常:
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
#hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 //注釋掉此行
hosts: files dns //添加下面這行
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
~
不用重啟,現在ping一切正常了。 問題錯在哪? 當需要提供nsswitch.conf檔案所描述的資訊的時候,系統將檢查含有適當info欄位的配置行。它按照從左向右的順序開始執行配置行中指定的方法。在預設情況下,如果找到期望的資訊,系統將停止搜尋。如果沒有指定action,那麼當某個方法未能返回結果時,系統就會嘗試下一個動作。有可能搜尋結束都沒有找到想要的資訊。 例如下面兩行nsswitch.conf檔案配置行: host nis files dns 通過#strace /etc/nsswitch.conf 可以查看到其實,延遲的原因是在nis這塊,它在調用搜尋nis庫時,一直找不到,耽誤過多的時間。繼續下一個搜尋,找到了。從而出現延遲。 參考部落格:http://www.cnblogs.com/cute/archive/2012/05/17/2506342.html nsswitch.conf檔案的分析