I/O、内存、网络性能优化命令 iostat , vmstat,netstat( 三 )


-------------------- -------------------- ----- ----- ------ ---------
192.168.1.0 192.168.1.11 U 1 1444 le0
224.0.0.0 192.168.1.11 U 1 0 le0
default 192.168.1.1 UG 1 68276
127.0.0.1 127.0.0.1 UH 1 10497 lo0

这个显示了一台solaris机器的ip为192.168.1.11,他的默认网关192.168.1.1

结果和解决方案:

A.)网络连通

上面的命令经常用来检查网络的连通性 。特别是当机器无法访问外部网络时:

1. 默认路由ip是否正确

2. 能否ping通网关

3. 如果网关地址不对,可以使用route add命令,参考 man route

route command examples:
$route add default
$route add 192.0.2.32
If the router address is correct but still you can"t ping it there may be some network cable /hub/switch problem and you

have to try and eliminate the faulty component .



B.) 网络反映

$ netstat -i

Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue
lo0 8232 loopback localhost 77814 0 77814 0 0 0
hme0 1500 server1 server1 10658566 3 4832511 0 279257 0

这个选项用于诊断网络问题,网络连通但连接速度慢

Values to look at:

Collisions (Collis)
Output packets (Opkts)
Input errors (Ierrs)
Input packets (Ipkts)
The above values will give information to workout

i. Network collision rate(网络冲突率)如下 :

Network collision rate = Output collision counts / Output packets

网络冲突率大于10%就显示,网络负载过大、网络配置不正确、硬件问题

ii. Input packet error rate(进入包错误率)如下 :

Input Packet Error Rate = Ierrs / Ipkts.

如果input error rate高(ver 0.25 percent),这个主机就正在丢包 。hub/switch 连线就需要被检查是否存在潜在的问题 。

C. Network socket & TCP Cconnection state
netstat给出了关于网络socket和tcp state的重要信息 。只是非常有用的,在寻找开放、关闭和等待网络tcp连接 。
netstat返回如下的网络状态 :
CLOSED ---- Closed. The socket is not being used.
LISTEN ---- Listening for incoming connections.
SYN_SENT ---- Actively trying to establish connection.
SYN_RECEIVED ---- Initial synchronization of the connection under way.
ESTABLISHED ---- Connection has been established.
CLOSE_WAIT ---- Remote shut down; waiting for the socket to close.
FIN_WAIT_1 ---- Socket closed; shutting down connection.
CLOSING ---- Closed, then remote shutdown; awaiting acknowledgement.
LAST_ACK ---- Remote shut down, then closed ;awaiting acknowledgement.
FIN_WAIT_2 ---- Socket closed; waiting for shutdown from remote.
TIME_WAIT ---- Wait after close for remote shutdown retransmission.


Example:

#netstat -a


Local Address Remote Address Swind Send-Q Rwind Recv-Q State
*.* *.* 0 0 24576 0 IDLE
*.22 *.* 0 0 24576 0 LISTEN
*.22 *.* 0 0 24576 0 LISTEN
*.* *.* 0 0 24576 0 IDLE
*.32771 *.* 0 0 24576 0 LISTEN
*.4045 *.* 0 0 24576 0 LISTEN
*.25 *.* 0 0 24576 0 LISTEN
*.5987 *.* 0 0 24576 0 LISTEN
*.898 *.* 0 0 24576 0 LISTEN
*.32772 *.* 0 0 24576 0 LISTEN
*.32775 *.* 0 0 24576 0 LISTEN
*.32776 *.* 0 0 24576 0 LISTEN
*.* *.* 0 0 24576 0 IDLE
192.168.1.184.22 192.168.1.186.50457 41992 0 24616 0 ESTABLISHED
192.168.1.184.22 192.168.1.186.56806 38912 0 24616 0 ESTABLISHED
192.168.1.184.22 192.168.1.183.58672 18048 0 24616 0 ESTABLISHED


if you see a lots of connections in FIN_WAIT state tcp/ip parameters have to be tuned because the
connections are not being closed and they gets accumulating . After some time system may run out of
resource . TCP parameter can be tuned to define a time out so that connections can be released and
used by new connection.
A detailed document about tuning tcp/ip can be found at
http://www.sean.de/Solaris/soltune.html

推荐阅读