今天让哥很蛋疼

作者:sealinger 发布时间:December 31, 2010 分类:简单生活

2010年12月31日。。。

今天就像是黎明前的黑暗,但明天可不是什么“黎明”,而是深渊,太恐怖了。。。

不敢想,我马上要奔×了,我去。。。

时间过的太TM快了,还让人活不。。。

这真是,我已成什么美女××,什么英雄××,什么强弩之末,什么夕阳西下,什么昨日黄花。。。尽管来吧。。。

我想把明天砸得粉碎,我想找到通往过去的天梯。。。

不想默默的等死了,哥去洗澡然后温习《子弹飞》了。。。

让2011见鬼去吧!

linux系统时间和硬件时钟问题(date和hwclock)

作者:sealinger 发布时间:December 31, 2010 分类:混口饭吃

1、总结一下hwclock,这个容易晕:


 1)/etc/sysconfig/clock 文件,只对 hwclock 命令有效,且只在系统启动和关闭的时候才有用(修改了其中的 UTC=true 到 UTC=false 的前后,执行 hwclock (--utc, 或 --localtime) 都没有变化,要重启系统后才生效);

 2)/etc/rc.d/rc.sysinit 文件,run once at boot time,其中有从硬件时钟同步时间到系统时间的操作;

 3)hwclock --localtime 的输出,才是硬件时钟真正的时间。如果输出结果带时区(比如CST),还要看/etc/sysconfig/clock里的UTC参数,如果 UTC=false,那时区有意义;如果 UTC=true,那时区没意义,实际上是UTC时间。

 4)在 /etc/sysconfig/clock 中 UTC=false 时,date、hwclock、hwclcok --localtime 输出的时间应该都一致,且此时 hwclock --utc是没有意义的;

 5)在 /etc/sysconfig/clock 中 UTC=ture 时,date、hwclock 的输出是一致的,hwclock --localtime 的输出则是UTC时间;

 6)如果不想在输出中带时区,则 export LANG=C ,然后再运行 hwclock 就没有什么CST了,免得时区误导你;

 7)hwclock --utc 很闹腾,还是别看了,你会晕的。。。

8)系统关闭时会同步系统时间到硬件时钟,系统启动时会从硬件时钟读取时间更新到系统,这2个步骤都要根据 /etc/sysconfig/clock 文件中UTC的参数来设置时区转换。

2、实际案例分析:修改了  /etc/sysconfig/clock 中UTC参数但系统未正常关闭的情况


修改 /etc/sysconfig/clock 文件后,如果系统内核突然崩溃,然后直接按电源重启,则系统没有进行 系统时间到硬件时钟的 同步;但是 系统启动时,又根据 /etc/sysconfig/clock 中UTC的参数,来同步硬件时钟到系统,这时就会出现时间问题:

0)假设系统的时区为CST(UTC+8);
1)假设原 /etc/sysconfig/clock 中 UTC=true,修改成 UTC=false;
2)如果此时系统未正常关机,系统时间未按参数 UTC=false 同步时间到硬件时钟(没有+8小时);
3)但系统被按电源重启后,系统读取到 UTC=false,认为硬件时钟为CST时间,直接用于系统时间;
4)那么此时,系统时间将少了8小时。

=======================================================

[引用]linux时间问题两篇[zz]
2010年07月19日 星期一 上午 09:43
http://hi.baidu.com/lujunqianglw/blog/item/bc2d9144d24fc48fb3b7dc1d.html

(一)


一、首先要弄清几个概念:


1. “系统时间”与“硬件时间”


    系统时间: 一般说来就是我们执行 date 命令看到的时间,linux系统下所有的时间调用(除了直接访问硬件时间的命令)都是使用的这个时间。

    硬件时间: 主板上BIOS中的时间,由主板电池供电来维持运行,系统开机时要读取这个时间,并根据它来设定系统时间(注意:系统启动时根据硬件时间设定系统时间的过程可能存在时区换算,这要视具体的系统及相关设置而定)。

2. “UTC时间”与“本地时间”


    UTC时间:Coordinated Universal 8 e2 i( H7 t0 ^/ ^Time 世界协调时间(又称世界标准时间、世界统一时间),在一般精度要求下,它与GMT(Greenwich Mean Time,格林威治标准时间)是一样的,其实也就是说 GMT≈UTC,但 UTC 是以原子钟校准的,更精确。

    本地时间:由于处在不同的时区,本地时间一般与UTC是不同的,换算方法就是

本地时间 = UTC + 时区 或 UTC = 本地时间 - 时区

    时区东为正,西为负,例如在中国,本地时间都使用北京时间,在linux上显示就是 CST(China Standard Time,中国标准时,注意美国的中部标准时Central Standard Time也缩写为CST,与这里的CST不是一回事!),时区为东八区,也就是 +8 区,所以 CST=UTC+(+8小时) 或 UTC=CST-(+8小时)。

二、时间命令


1. 系统时间 date


   直接调用 date,得到的是本地时间。如果想得到UTC时间的话,使用 date -u。

[12-01 19:07> ~]$ date
2009年 12月 07日 星期一 14:22:20 CST
[12-01 19:07> ~]$ date -u
2009年 12月 07日 星期一 06:22:22 UTC

2. 硬件时间 /sbin/hwclock


   直接调用 /sbin/hwclock 显示的时间就是 BIOS 中的时间吗?未必!这要看 /etc/sysconfig/clock 中是否启用了UTC,如果启用了UTC(UTC=true),显示的其实是经过时区换算的时间而不是BIOS中真正的时间,如果加上 --localtime 选项,则得到的总是 BIOS 中实际的时间.

[12-01 19:07> ~]# hwclock
2009年12月07日 星期一 14时28分43秒 -0.611463 seconds
[12-01 19:07> ~]# hwclock --utc
2009年12月07日 星期一 14时28分46秒 -0.594189 seconds
[12-01 19:07> ~]# hwclock --localtime
2009年12月07日 星期一 06时28分50秒 -0.063875 seconds

3. /etc/localtime


   这个文件用来设置系统的时区,将 /usr/share/zoneinfo/ 中相应文件拷贝到/etc下并重命名为 localtime 即可修改时区设置,而且这种修改对 date 命令是及时生效的。不论是 date 还是 hwclock 都会用到这个文件,会根据这个文件的时区设置来进行UTC和本地之间之间的换算。

4. /etc/sysconfig/clock


   这个文件只对 hwclock 有效,而且似乎是只在系统启动和关闭的时候才有用,比如修改了其中的 UTC=true 到 UTC=false 的前后,执行 hwclock (--utc, 或 --localtime) 都没有变化,要重启系统后才生效。注:如果设置 UTC=false 并重启系统后,执行一些命令结果如下:

date 2009年 12月 07日 星期一 19:26:29 CST
date -u 2009年 12月 07日 星期一 11:26:29 UTC
hwclock 2009年12月07日 星期一 19时26分30秒 -0.442668 seconds
hwclock --utc 2009年12月08日 星期二 03时26分31秒 -0.999091 seconds
hwclock --localtime 2009年12月07日 星期一 19时26分32秒 -0.999217 seconds

可见,如果不使用UTC,BIOS时间(红色部分)就是系统本地时间,而且注意这时执行 hwclock --utc 得到的结果没有任何意义,因为这里我们已经禁用了UTC,而且也明显不符合“本地时间=UTC+时区”的关系。

三、linux与windows双系统间的时间同步


    系统启动和关闭时,硬件时间与系统时间之间的同步有两种方式(假设在中国,用CST代表本地时间):

方式A: 使用UTC(对linux就是 /etc/sysconfig/clock 中 UTC=true)

       开机: BIOS------->UTC(将BIOS中的时间看成是UTC)------(时区变化)----->CST
       关机: CST -------(时区变化)----->UTC-------存储到------>BIOS

 方式B: 不使用UTC(对linux就是 /etc/sysconfig/clock 中 UTC=false)

       开机: BIOS--------------------->CST(将BIOS中的时间看成是CST)
       关机: CST ---------存储到------>BIOS

 通过设定 /etc/sysconfig/clock,linux可以支持这两种方式,然而windows只支持方式B(至少是默认支持B,而我不知道怎么能让它支 持A),那么在双系统情况下,如果linux设成A方式,那么在linux与windows系统切换时一定会造成时间混乱的,解决办法就是将linux中 的UTC禁用,也设成B方式就可以了。

 注:可以通过 hwclock --hctosys 来利用硬件时间来设置系统时间(注意不是简单的复制BIOS中的时间为系统时间,要看是否使用UTC,如果使用的话则要做时区换算),通过 hwclock --systohc 来根据系统时间设置硬件时间(也要看是否启用UTC来决定是否做时区换算)。

总之,不论使用 --systohc 还是 --hctosys,同步后直接运行不带参数的 hwclock 得到的时间与直接运行 date 得到的时间应该一致,这个时间是否就是BIOS中的时间(hwclock --localtime)那就不一定了,如果启用了UTC就不是,没启用UTC就是。

而且还要注意:在系统中手动使用 hwclock hwclock --set --date='yyyy-mm-dd' 来设置BIOS时间只在系统运行时有效,因为当系统关闭时,还会按设定好的方式根据系统时间来重设BIOS时间的,于是手动的设置便被覆盖掉了。

---------------------------------------------------------------------
 

(二)


Linux时钟分为系统时钟(System Clock)和硬件(Real Time Clock,简称RTC)时钟。系统时钟是指当前Linux Kernel中的时钟,而硬件时钟则是主板上由电池供电的时钟,这个硬件时钟可以在BIOS中进行设置。当Linux启动时,硬件时钟会去读取系统时钟的设置,然后系统时钟就会独立于硬件运作。

 Linux中的所有命令(包括函数)都是采用的系统时钟设置。在Linux中,用于时钟查看和设置的命令主要有date、hwclock和clock。其中,clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。
 

1、date


查看系统时间
# date
设置系统时间
# date --set “07/07/06 10:19" (月/日/年 时:分:秒)

2、hwclock/clock


查看硬件时间
# hwclock --show
或者
# clock --show
设置硬件时间
# hwclock --set --date="07/07/06 10:19" (月/日/年 时:分:秒)
或者
# clock --set --date="07/07/06 10:19" (月/日/年 时:分:秒)

3、硬件时间和系统时间的同步


按照前面的说法,重新启动系统,硬件时间会读取系统时间,实现同步,但是在不重新启动的时候,需要用hwclock或clock命令实现同步。

硬件时钟与系统时钟同步:
# hwclock --hctosys(hc代表硬件时间,sys代表系统时间)
或者
# clock --hctosys
系统时钟和硬件时钟同步:
# hwclock --systohc
或者
# clock --systohc
 

4、时区的设置 tzselect


# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 输入5,亚洲
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 输入9,中国
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang
3) central China - Gansu, Guizhou, Sichuan, Yunnan, etc.
4) Tibet & most of Xinjiang Uyghur
5) southwest Xinjiang Uyghur
#? 输入1,北京时间
The following information has been given:
China
east China - Beijing, Guangdong, Shanghai, etc.
Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Fri Jul 7 10:32:18 CST 2006.
Universal Time is now: Fri Jul 7 02:32:18 UTC 2006.
Is the above information OK?
1) Yes
2) No
#? 输入1,确认

如果不用tzselect命令,可以修改文件变更时区。

# vi /etc/sysconfig/clock
ZONE=Asia/Shanghai(查/usr/share/zoneinfo下面的文件)
UTC=false
ARC=false
# rm /etc/localtime
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
重新启动即可。

  

【搞】火车站遇到一个看起来很真诚担心的女孩

作者:sealinger 发布时间:December 31, 2010 分类:简单生活

梦洁:

    火车站遇到一个看起来很真诚担心的女孩,她自称是来北京读考研班的学生,钱包被扒,饥寒交迫,要我行善给她人民币几多,并取出门生证要我验看。看着她真诚的双眼,我很想掏钱,但突然我灵光展现,问她一句:“马克思主义认识论与唯心主义认识论的区别和联系 是什么?

    她:。。。。

    于是没有然后了。。。。。。
   
------------------------------------------------------------------------- 
周旭昆:

    有一天我专门去刘梦洁说的经常有美女骗子出没的火车站门口散步,果然看到一个看起来很真诚担心的女孩,她自称是来北京读考研班的学生,钱包被扒,饥寒交迫,要我行善给她人民币几多,并取出门生证要我验看。看着她真诚的双眼,我很想掏钱,但突然我灵光展现,问她一句:“马克思主义认识论与唯心主义认识论的区别和联系 是什么?

    她好像很有准备,坦然答道:马克思主义认识论与唯心主义认识论的区别在于是否承认认识是以实践为基础的主体对客体的能动反映。…………中间省略了1000字。。

    于是我又问:如何用马列主义毛泽东思想解释只有中国特色的社会主义言论自由才是真正的言论自由?

    然后。。。真没有然后了。。。。。。  
-------------------------------------------------------------------------
李建军:

    有一天我专门去刘梦洁和周旭昆两口子经常说的有美女骗子出没的火车站门口散步,果然看到一个看起来很真诚担心的女孩,她自称是来北京读考研班的学生,钱包被扒,饥寒交迫,要我行善给她人民币几多,并取出门生证要我验看。看着她真诚的双眼,我很想掏钱,但突然我灵光展现,问她一句:“马克思主义认识论与唯心主义认识论的区别和联系 是什么?

    她好像很有准备,坦然答道:马克思主义认识论与唯心主义认识论的区别在于是否承认认识是以实践为基础的主体对客体的能动反映。…………中间省略了1000字。。

    于是我又问:如何用马列主义毛泽东思想解释只有中国特色的社会主义言论自由才是真正的言论自由?

    她回答道:没有绝对的自由,也没有绝对的言论自由。。。。。中间省略了1000字

    于是我又问:“如何论证在中国不能搞多党制”

    她清了清嗓子说道:多党制。。。

    话还没有说完,跳出来一个人问她:你是哪里人?她说。陕西的。。。

    然后。。。。她就真被送回陕西了。。。。。。。

F5负载均衡算法及基本原理(Intro to Load Balancing)

作者:sealinger 发布时间:December 27, 2010 分类:混口饭吃

参考网上一些介绍,对这篇文章加个中文注释。

原文:Intro to Load Balancing for Developers – The Algorithms

 posted on Tuesday, March 31, 2009 11:02 PM

 
  • Random: This load balancing method randomly distributes load across the servers available, picking one via random number generation and sending the current connection to it. While it is available on many load balancing products, its usefulness is questionable except where uptime is concerned – and then only if you detect down machines.
  • 随机:此负载均衡算法在可用的服务器间随机分发请求,通过生成随机数随机挑选一台服务器,并将当前连接发给它。系统对需要进行负载均衡的服务器建立一个数组(array),使用随机数生成器来决定谁将获得下一个连接。

Plain Programmer Description: The system builds an array of Servers being load balanced, and uses the random number generator to determine who gets the next connection… Far from an elegant solution, and most often found in large software packages that have thrown load balancing in as a feature.

  • Round Robin: Round Robin passes each new connection request to the next server in line, eventually distributing connections evenly across the array of machines being load balanced. Round Robin works well in most configurations, but could be better if the equipment that you are load balancing is not roughly equal in processing speed, connection speed, and/or memory.
  • 轮询:将请求依次顺序循环地分发给服务器,从1到N然后重新开始。此种均衡算法适合于服务器组中的所有服务器都有相同的软硬件配置并且平均服务请求相对均衡的情况。

Plain Programmer Description: The system builds a standard circular queue and walks through it, sending one request to each machine before getting to the start of the queue and doing it again. While I’ve never seen the code (or actual load balancer code for any of these for that matter), we’ve all written this queue with the modulus function before. In school if nowhere else.

  • Weighted Round Robin (called Ratio on the BIG-IP): With this method, the number of connections that each machine receives over time is proportionate to a ratio weight you define for each machine. This is an improvement over Round Robin because you can say “Machine 3 can handle 2x the load of machines 1 and 2”, and the load balancer will send two requests to machine #3 for each request to the others.
  • 权重:根据服务器的不同处理能力,给每个服务器分配不同的权值,使其能够接受相应权值数的服务请求。例如:服务器A的权值被设计成1,B的权值是3,C的权值是6,则服务器A、B、C将分别接受到10%、30%、60%的服务请求。此种均衡算法能确保高性能的服务器得到更多的使用率,避免低性能的服务器负载过重。

Plain Programmer Description: The simplest way to explain for this one is that the system makes multiple entries in the Round Robin circular queue for servers with larger ratios. So if you set ratios at 3:2:1:1 for your four servers, that’s what the queue would look like – 3 entries for the first server, two for the second, one each for the third and fourth. In this version, the weights are set when the load balancing is configured for your application and never change, so the system will just keep looping through that circular queue. Different vendors use different weighting systems – whole numbers, decimals that must total 1.0 (100%), etc. but this is an implementation detail, they all end up in a circular queue style layout with more entries for larger ratings.

  • Dynamic Round Robin (Called Dynamic Ratio on the BIG-IP): is similar to Weighted Round Robin, however, weights are based on continuous monitoring of the servers and are therefore continually changing. This is a dynamic load balancing method, distributing connections based on various aspects of real-time server performance analysis, such as the current number of connections per node or the fastest node response time. This Application Delivery Controller method is rarely available in a simple load balancer.
  • 动态比率:类似于权重,不过权重值是随着对服务器持续的监控而变化的。这是一个动态的负载均衡算法,基于对服务器性能的实时分析,如连接数或响应时间。

Plain Programmer Description: If you think of Weighted Round Robin where the circular queue is rebuilt with new (dynamic) weights whenever it has been fully traversed, you’ll be dead-on.

  • Fastest: The Fastest method passes a new connection based on the fastest response time of all servers. This method may be particularly useful in environments where servers are distributed across different logical networks. On the BIG-IP, only servers that are active will be selected.
  • 最快模式:传递连接给那些响应速度最快的服务器。这种算法可能对于服务器处于不同的逻辑网络中的情况特别有用。均衡器记录着每个服务器的响应时间并选择最快的那一个。这非常直接了当,但是可能会导致拥塞,因为当前的响应时间并不一定真的还是1s或是2s了。
  • 解释一下:最快模式算法是基于未完成的七层请求数来计算的。请求被发送到一个成员时,LTM将为它递增一个计数器,当请求被响应后,再对计数器递减。当LTM收到一个连接请求后,有最少的未完成请求的成员将被选择。如果VS没有关联七层的Profile,LTM是不能追踪请求和回应的,负载均衡算法将“降级”为最小连接数模式。

Plain Programmer Description: The load balancer looks at the response time of each attached server and chooses the one with the best response time. This is pretty straight-forward, but can lead to congestion because response time right now won’t necessarily be response time in 1 second or two seconds. Since connections are generally going through the load balancer, this algorithm is a lot easier to implement than you might think, as long as the numbers are kept up to date whenever a response comes through.

These next three I use the BIG-IP name for. They are variants of a generalized algorithm sometimes called Long Term Resource Monitoring.

  • Least Connections: With this method, the system passes a new connection to the server that has the least number of current connections. Least Connections methods work best in environments where the servers or other equipment you are load balancing have similar capabilities. This is a dynamic load balancing method, distributing connections based on various aspects of real-time server performance analysis, such as the current number of connections per node or the fastest node response time. This Application Delivery Controller method is rarely available in a simple load balancer.
  • 最小连接数:客户端的每一次请求服务在服务器停留的时间可能会有较大的差异,随着工作时间加长,如果采用简单的轮循或随机均衡算法,每一台服务器上的连接进程可能会产生极大的不同,并没有达到真正的负载均衡。最少连接数均衡算法对内部中需负载的每一台服务器都有一个数据记录,记录当前该服务器正在处理的连接数量,当有新的服务连接请求时,将把当前请求分配给连接数最少的服务器,使均衡更加符合实际情况,负载更加均衡。此种均衡算法适合长时处理的请求服务,如FTP。
  • 但是,像Fastest一样,当连接时间不同时也可能导致拥塞——比如一个服务器正在处理简单的HTML页面,而另一个正在运行处理一堆数据库查询的JSP脚本,连接数就不太适合这种情况了。

Plain Programmer Description: This algorithm just keeps track of the number of connections attached to each server, and selects the one with the smallest number to receive the connection. Like fastest, this can cause congestion when the connections are all of different durations – like if one is loading a plain HTML page and another is running a JSP with a ton of database lookups. Connection counting just doesn’t account for that scenario very well.

  • Observed: The Observed method uses a combination of the logic used in the Least Connections and Fastest algorithms to load balance connections to servers being load-balanced. With this method, servers are ranked based on a combination of the number of current connections and the response time. Servers that have a better balance of fewest connections and fastest response time receive a greater proportion of the connections. This Application Delivery Controller method is rarely available in a simple load balancer.
  • 观察模式:以连接数和响应时间这两项的最佳平衡为依据来为新的请求选择服务器。

Plain Programmer Description: This algorithm tries to merge Fastest and Least Connections, which does make it more appealing than either one of the above than alone. In this case, an array is built with the information indicated (how weighting is done will vary, and I don’t know even for F5, let alone our competitors), and the element with the highest value is chosen to receive the connection. This somewhat counters the weaknesses of both of the original algorithms, but does not account for when a server is about to be overloaded – like when three requests to that query-heavy JSP have just been submitted, but not yet hit the heavy work.

  • Predictive: The Predictive method uses the ranking method used by the Observed method, however, with the Predictive method, the system analyzes the trend of the ranking over time, determining whether a servers performance is currently improving or declining. The servers in the specified pool with better performance rankings that are currently improving, rather than declining, receive a higher proportion of the connections. The Predictive methods work well in any environment. This Application Delivery Controller method is rarely available in a simple load balancer.
  • 预测模式:预测模式使用和观察模式一样的评选方法,只不过BIGIP会利用收集到的服务器当前的性能指标(连接数和响应时间),进行预测分析,选择一台服务器在下一个时间片内,其性能将达到最佳的服务器来响应用户的请求。预测模式试图修复在观察模式中的一个问题,如果服务器的响应时间已经开始下滑,那么它是不太可能接受下一个请求的。

Plain Programmer Description: This method attempts to fix the one problem with Observed by watching what is happening with the server. If its response time has started going down, it is less likely to receive the packet. Again, no idea what the weightings are, but an array is built and the most desirable is chosen.

 

You can see with some of these algorithms that persistent connections would cause problems. Like Round Robin, if the connections persist to a server for as long as the user session is working, some servers will build a backlog of persistent connections that slow their response time. The Long Term Resource Monitoring algorithms are the best choice if you have a significant number of persistent connections. Fastest works okay in this scenario also if you don’t have access to any of the dynamic solutions.

你可以看到,有些算法遇到长连接可能会导致问题。像是轮询,如果长连接保持用户会话那么久,当连接数积压到一定值时会导致服务器响应时间变慢。如果你有大量的长连接,LTRM( Long Term Resource Monitoring )算法是最好的选择。如果没有动态的解决方案,Fastest算法也比较适合这种场景。

That’s it for this week, next week we’ll start talking specifically about Application Delivery Controllers and what they offer – which is a whole lot – that can help your application in a variety of ways.

Until then!

Don.

IBM X3650 M2服务器网卡(BCM5709)在RHEL5.4下有时断网问题

作者:sealinger 发布时间:December 21, 2010 分类:混口饭吃

2010年7月遇到 IBM X3650 M2服务器网卡在RHEL 5.4 X64系统下有时断网和drop包的异常,记录下来希望帮助到有同样问题的人。

已确认问题:
RHEL 5.3/5.4 自带的Broadcom NetXtreme II BCM5709 网卡驱动有BUG,涉及到 ACPI 电源管理的问题。所以当网卡在正常工作的时候,会被 ACPI 误以为他闲着,从而把它给关闭掉。”
“每次出现这个情况,只需要 service network restart  或者 ifdown/ifup ethX (对于被关闭的网卡端口) 就可以恢复正常。”

注:查看IBM X3650 M2使用的网卡:

[root@cache52 tmp]# lspci
0b:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
0b:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)

解决这个问题有2种方法:
1)第一种相对简单,就是在Linux内核中禁用 ACPI 电源管理系统。
vi /boot/grub/grub.conf
title Red Hat Enterprise Linux Server (2.6.18-164.el5)
    root (hd0,0)
    kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet acpi=off
    initrd /initrd-2.6.18-164.el5.img

2)另外一种方法就是升级网卡驱动。

当时IBM官方网站的最新版本是 1.9.20b,下载地址:
http://www-947.ibm.com/systems/support/supportsite.wss/docdisplay?lndocid=MIGR-5073130&brandind=5000008

[root@cache52 bnx2]# tar zxvf brcm_dd_nic_netxtreme2-1.9.20b_1.50.13_rhel5_32-64.tgz
[root@cache52 bnx2]# nohup ./install.sh --update --override &
[root@cache52 bnx2]# tail nohup.out

        Drivers will be installed/migrated to 2.6.18-164 version
----------------------------------------------------------------------
Checking kmod-brcm-netxtreme2-5.0.17-1.x86_64.rpm
......
----------------------------------------------------------------------
kmod-brcm-netxtreme2-5.0.17-1.x86_64.rpm installed successfully
SUCCESS

查看升级后的模块信息:
[root@cache52 brcm-netxtreme2]# modinfo bnx2
filename:       /lib/modules/2.6.18-164.el5/weak-updates/brcm-netxtreme2/bnx2.ko
version:        1.9.20b
license:        GPL
description:    Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver
...

RHEL5.4 X64 系统自带的版本:
[root@cache50 ~]# modinfo bnx2
filename:       /lib/modules/2.6.18-164.el5/kernel/drivers/net/bnx2.ko
version:        1.9.3
license:        GPL
description:    Broadcom NetXtreme II BCM5706/5708/5709/5716 Driver
...

3)我升级了,网卡不通的问题基本不出现了,但有时还是有Drop包问题,可以尝试调整网卡ring缓冲区参数。

[root@cache54 /]# ethtool -G eth1 rx 1024
[root@cache54 /]# ethtool -g eth1       
Ring parameters for eth1:
Pre-set maximums:
RX:             4080表示最大可调到4080)
RX Mini:        0
RX Jumbo:       16320
TX:             255
Current hardware settings:
RX:             1024默认255,我们调到了1024)
RX Mini:        0
RX Jumbo:       0
TX:             255
[root@cache54 /]#

相关链接:

http://sa.028life.com/?p=209#more-209
http://www.ourlinux.net/life/rhel54-bcm5709-nic-drivers-problem/