Nov 25 2008

IIS 的免费 Rewrite 反盗链

Category: 技术ssmax @ 20:51:16

IIS有个免费的IIRF,rewriter,就像apache的mod_rewrite,基本上规则都一样,正则表达式是用pcre库,perl兼容的正则表达式,十分简单。

http://cheeso.members.winisp.net/IIRF.aspx

一个反盗链的例子

RewriteLogLevel 0

RewriteCond %{HTTP_REFERER} ^(?!HTTP_REFERER)
RewriteCond %{HTTP_REFERER} ^(?!https?://(?:.*\.)yourdomain\.com) [I]
RewriteRule ^.*$ /blocked.html [NF]

第一行的大概意思就是有REFERER头的请求才处理,NF就表示not found 404响应


Nov 18 2008

lsof命令查看打开文件

Category: 技术ssmax @ 20:01:12

  一般root用户才能执行lsof命令,普通用户可以看见/usr/sbin/lsof命令,但是普通用户执行会显示“permission denied”

  我总结一下lsof指令的用法:

  lsof abc.txt 显示开启文件abc.txt的进程

  lsof -i :22 知道22端口现在运行什么程序

  lsof -c abc 显示abc进程现在打开的文件

  lsof -g gid 显示归属gid的进程情况

  lsof +d /usr/local/ 显示目录下被进程开启的文件

  lsof +D /usr/local/ 同上,但是会搜索目录下的目录,时间较长

  lsof -d 4 显示使用fd为4的进程

  lsof -i 用以显示符合条件的进程情况

  语法: lsof -i[46] [protocol][@hostname|hostaddr][:service|port]

  46 –> IPv4 or IPv6

  protocol –> TCP or UDP

  hostname –> Internet host name

  hostaddr –> IPv4位置

  service –> /etc/service中的 service name (可以不只一个)

  port –> 端口号 (可以不只一个)

  例子: TCP:25 – TCP and port 25

  @1.2.3.4 – Internet IPv4 host address 1.2.3.4

  tcp@ohaha.ks.edu.tw:ftp – TCP protocol hosthaha.ks.edu.tw service name:ftp

  lsof -n 不将IP转换为hostname,缺省是不加上-n参数

  例子: lsof -i tcp@ohaha.ks.edu.tw:ftp -n

  lsof -p 12 看进程号为12的进程打开了哪些文件

  lsof +|-r [t] 控制lsof不断重复执行,缺省是15s刷新

  -r,lsof会永远不断的执行,直到收到中断信号

  +r,lsof会一直执行,直到没有档案被显示

  例子:不断查看目前ftp连接的情况:lsof -i tcp@ohaha.ks.edu.tw:ftp -r

  lsof -s 列出打开文件的大小,如果没有大小,则留下空白

  lsof -u username 以UID,列出打开的文件

  一般root用户才能执行lsof命令,普通用户可以看见/usr/sbin/lsof命令,但是普通用户执行会显示“permission denied”

  我总结一下lsof指令的用法:

  lsof abc.txt 显示开启文件abc.txt的进程

  lsof -i :22 知道22端口现在运行什么程序

  lsof -c abc 显示abc进程现在打开的文件

  lsof -g gid 显示归属gid的进程情况

  lsof +d /usr/local/ 显示目录下被进程开启的文件

  lsof +D /usr/local/ 同上,但是会搜索目录下的目录,时间较长

  lsof -d 4 显示使用fd为4的进程

  lsof -i 用以显示符合条件的进程情况

  语法: lsof -i[46] [protocol][@hostname|hostaddr][:service|port]

  46 –> IPv4 or IPv6

  protocol –> TCP or UDP

  hostname –> Internet host name

  hostaddr –> IPv4位置

  service –> /etc/service中的 service name (可以不只一个)

  port –> 端口号 (可以不只一个)

  例子: TCP:25 – TCP and port 25

  @1.2.3.4 – Internet IPv4 host address 1.2.3.4

  tcp@ohaha.ks.edu.tw:ftp – TCP protocol hosthaha.ks.edu.tw service name:ftp

  lsof -n 不将IP转换为hostname,缺省是不加上-n参数

  例子: lsof -i tcp@ohaha.ks.edu.tw:ftp -n

  lsof -p 12 看进程号为12的进程打开了哪些文件

  lsof +|-r [t] 控制lsof不断重复执行,缺省是15s刷新

  -r,lsof会永远不断的执行,直到收到中断信号

  +r,lsof会一直执行,直到没有档案被显示

  例子:不断查看目前ftp连接的情况:lsof -i tcp@ohaha.ks.edu.tw:ftp -r

  lsof -s 列出打开文件的大小,如果没有大小,则留下空白

  lsof -u username 以UID,列出打开的文件

[root@tcx160 FILES]# lsof -i tcp:22
COMMAND  PID USER  FD  TYPE DEVICE SIZE NODE NAME
sshd   3261 root  3u IPv6  7301    TCP *:ssh (LISTEN)
sshd  19692 root  3u IPv6 348642    TCP 9.186.96.160:ssh->9.186.96.117:32914 (ESTABLISHED)


Nov 18 2008

syslog-ng 的 MSGONLY

Category: 技术ssmax @ 11:25:57

nginx不支持直接用unix stream的syslog,所以只能mkfifo一个pipe,然后让syslog-ng去读了,但是syslog-ng的默认log格式是

program[pid]: message

如果log对象的template直接记录 MSGONLY 的话,syslog-ng会从第一个冒号那里开始切开,造成web的log全部都有问题,只能在log前面按syslog的格式写死一下,就好了。


Nov 17 2008

nginx 的 tcp_nopush 和 tcp_nodelay

Category: 技术ssmax @ 17:06:52

nginx的 tcp_nopush 就相当于freebsd下面的TCP_NOPUSH 或者 linux 下面的TCP_CORK

这个东东和tcp_nodelay是互斥的。下面是详细的解释。

 

TCP_NODELAY 和 TCP_CORK,
这两个选项都对网络连接的行为具有重要的作用。许多UNIX系统都实现了TCP_NODELAY选项,但是,TCP_CORK则是Linux系统所独有的而且相对较新;它首先在内核版本2.4上得以实现。此外,其他UNIX系统版本也有功能类似的选项,值得注意的是,在某种由BSD派生的系统上的TCP_NOPUSH选项其实就是TCP_CORK的一部分具体实现。
TCP_NODELAY和TCP_CORK基本上控制了包的“Nagle化”,Nagle化在这里的含义是采用Nagle算法把较小的包组装为更大的帧。John Nagle是Nagle算法的发明人,后者就是用他的名字来命名的,他在1984年首次用这种方法来尝试解决福特汽车公司的网络拥塞问题(欲了解详情请参看IETF RFC 896)。他解决的问题就是所谓的silly window syndrome ,中文称“愚蠢窗口症候群”,具体含义是,因为普遍终端应用程序每产生一次击键操作就会发送一个包,而典型情况下一个包会拥有一个字节的数据载荷以及40个字节长的包头,于是产生4000%的过载,很轻易地就能令网络发生拥塞,。 Nagle化后来成了一种标准并且立即在因特网上得以实现。它现在已经成为缺省配置了,但在我们看来,有些场合下把这一选项关掉也是合乎需要的。
现在让我们假设某个应用程序发出了一个请求,希望发送小块数据。我们可以选择立即发送数据或者等待产生更多的数据然后再一次发送两种策略。如果我们马上发送数据,那么交互性的以及客户/服务器型的应用程序将极大地受益。例如,当我们正在发送一个较短的请求并且等候较大的响应时,相关过载与传输的数据总量相比就会比较低,而且,如果请求立即发出那么响应时间也会快一些。以上操作可以通过设置套接字的TCP_NODELAY选项来完成,这样就禁用了Nagle算法。
另外一种情况则需要我们等到数据量达到最大时才通过网络一次发送全部数据,这种数据传输方式有益于大量数据的通信性能,典型的应用就是文件服务器。应用Nagle算法在这种情况下就会产生问题。但是,如果你正在发送大量数据,你可以设置TCP_CORK选项禁用Nagle化,其方式正好同TCP_NODELAY相反(TCP_CORK 和 TCP_NODELAY 是互相排斥的)。下面就让我们仔细分析下其工作原理。
假设应用程序使用sendfile()函数来转移大量数据。应用协议通常要求发送某些信息来预先解释数据,这些信息其实就是报头内容。典型情况下报头很小,而且套接字上设置了TCP_NODELAY。有报头的包将被立即传输,在某些情况下(取决于内部的包计数器),因为这个包成功地被对方收到后需要请求对方确认。这样,大量数据的传输就会被推迟而且产生了不必要的网络流量交换。
但是,如果我们在套接字上设置了TCP_CORK(可以比喻为在管道上插入“塞子”)选项,具有报头的包就会填补大量的数据,所有的数据都根据大小自动地通过包传输出去。当数据传输完成时,最好取消TCP_CORK 选项设置给连接“拔去塞子”以便任一部分的帧都能发送出去。这同“塞住”网络连接同等重要。
总而言之,如果你肯定能一起发送多个数据集合(例如HTTP响应的头和正文),那么我们建议你设置TCP_CORK选项,这样在这些数据之间不存在延迟。能极大地有益于WWW、FTP以及文件服务器的性能,同时也简化了你的工作。示例代码如下:

intfd, on = 1;

/* 此处是创建套接字等操作,出于篇幅的考虑省略*/

setsockopt (fd, SOL_TCP, TCP_CORK, &on, sizeof (on)); /* cork */
write (fd, …);
fprintf (fd, …);
sendfile (fd, …);
write (fd, …);
sendfile (fd, …);

on = 0;
setsockopt (fd, SOL_TCP, TCP_CORK, &on, sizeof (on)); /* 拔去塞子 */

不幸的是,许多常用的程序并没有考虑到以上问题。例如,Eric Allman编写的sendmail就没有对其套接字设置任何选项。

Apache HTTPD是因特网上最流行的Web服务器,它的所有套接字就都设置了TCP_NODELAY选项,而且其性能也深受大多数用户的满意。这是为什么呢?答案就在于实现的差别之上。由BSD衍生的TCP/IP协议栈(值得注意的是FreeBSD)在这种状况下的操作就不同。当在TCP_NODELAY 模式下提交大量小数据块传输时,大量信息将按照一次write()函数调用发送一块数据的方式发送出去。然而,因为负责请求交付确认的记数器是面向字节而非面向包(在Linux上)的,所以引入延迟的概率就降低了很多。结果仅仅和全部数据的大小有关系。而 Linux 在第一包到达之后就要求确认,FreeBSD则在进行如此操作之前会等待好几百个包。

在Linux系统上,TCP_NODELAY的效果同习惯于BSD TCP/IP协议栈的开发者所期望的效果有很大不同,而且在Linux上的Apache性能表现也会更差些。其他在Linux上频繁采用TCP_NODELAY的应用程序也有同样的问题。


Nov 11 2008

网站压力测试

Category: 技术ssmax @ 17:15:37

linux下面主要就是

Siege、webbench、ab

ab是apache自带的了,其他两个都是开源的。

Windows下面就是微软的 Web Application Stress

还有一只HP的Loadrunner,有windows和linux版,不过都是一些超大型的测试框架了,没有兴趣去深入研究。


Nov 06 2008

debian的chkconfig

Category: 技术ssmax @ 13:36:55

redhat上面的chkconfig比较好用,原来不知道debian上面也有,还去装了一个rcconf,原来debian自己就带有一个update-rc.d脚本,直接可以完成需要的东西了。

usage: update-rc.d [-n] [-f] <basename> remove
       update-rc.d [-n] <basename> defaults [NN | sNN kNN]
       update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] […] .
                -n: not really
                -f: force

 

例子:

update-rc.d nfs start 20 2 3 4 5 . stop 20 0 1 6 .


Nov 06 2008

LVS– ipvsadm命令参考(转载)

Category: 技术ssmax @ 10:48:32

LVS– ipvsadm命令参考(转载)

对ipvsadm 的命令参考,并根据自己使用的经验,进行了一个简单的翻译,希望
对ipvsadm 的使用者有一定的帮助。
为了更好的让大家理解这份命令手册,将手册里面用到的几个术语先简单的介绍
一下:
1,virtual-service-address:是指虚拟服务器的ip 地址
2,real-service-address:是指真实服务器的ip 地址
3,scheduler:调度方法

ipvsadm 的用法和格式如下:
ipvsadm -A|E -t|u|f virutal-service-address:port [-s scheduler] [-p
[timeout]] [-M netmask]
ipvsadm -D -t|u|f virtual-service-address
ipvsadm -C
ipvsadm -R
ipvsadm -S [-n]
ipvsadm -a|e -t|u|f service-address:port -r real-server-address:port
[-g|i|m] [-w weight]
ipvsadm -d -t|u|f service-address -r server-address
ipvsadm -L|l [options]
ipvsadm -Z [-t|u|f service-address]
ipvsadm –set tcp tcpfin udp
ipvsadm –start-daemon state [–mcast-interface interface]
ipvsadm –stop-daemon
ipvsadm -h
命令选项解释:
有两种命令选项格式,长的和短的,具有相同的意思。在实际使用时,两种都可
以。
-A –add-service 在内核的虚拟服务器表中添加一条新的虚拟服务器记录。也
就是增加一台新的虚拟服务器。
-E –edit-service 编辑内核虚拟服务器表中的一条虚拟服务器记录。
-D –delete-service 删除内核虚拟服务器表中的一条虚拟服务器记录。
-C –clear 清除内核虚拟服务器表中的所有记录。
-R –restore 恢复虚拟服务器规则
-S –save 保存虚拟服务器规则,输出为-R 选项可读的格式
-a –add-server 在内核虚拟服务器表的一条记录里添加一条新的真实服务器
记录。也就是在一个虚拟服务器中增加一台新的真实服务器
-e –edit-server 编辑一条虚拟服务器记录中的某条真实服务器记录
-d –delete-server 删除一条虚拟服务器记录中的某条真实服务器记录
-L|-l –list 显示内核虚拟服务器表
-Z –zero 虚拟服务表计数器清零(清空当前的连接数量等)
–set tcp tcpfin udp 设置连接超时值
–start-daemon 启动同步守护进程。他后面可以是master 或backup,用来说
明LVS Router 是master 或是backup。在这个功能上也可以采用keepalived 的
VRRP 功能。
–stop-daemon 停止同步守护进程
-h –help 显示帮助信息
其他的选项:
-t –tcp-service service-address 说明虚拟服务器提供的是tcp 的服务
[vip:port] or [real-server-ip:port]
-u –udp-service service-address 说明虚拟服务器提供的是udp 的服务
[vip:port] or [real-server-ip:port]
-f –fwmark-service fwmark 说明是经过iptables 标记过的服务类型。
-s –scheduler scheduler 使用的调度算法,有这样几个选项
rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,
默认的调度算法是: wlc.
-p –persistent [timeout] 持久稳固的服务。这个选项的意思是来自同一个客
户的多次请求,将被同一台真实的服务器处理。timeout 的默认值为300 秒。
-M –netmask netmask persistent granularity mask
-r –real-server server-address 真实的服务器[Real-Server:port]
-g –gatewaying 指定LVS 的工作模式为直接路由模式(也是LVS 默认的模式)
-i –ipip 指定LVS 的工作模式为隧道模式
-m –masquerading 指定LVS 的工作模式为NAT 模式
-w –weight weight 真实服务器的权值
–mcast-interface interface 指定组播的同步接口
-c –connection 显示LVS 目前的连接 如:ipvsadm -L -c
–timeout 显示tcp tcpfin udp 的timeout 值 如:ipvsadm -L –timeout
–daemon 显示同步守护进程状态
–stats 显示统计信息
–rate 显示速率信息
–sort 对虚拟服务器和真实服务器排序输出
–numeric -n 输出IP 地址和端口的数字形式

例子
  b.  清除ipvsadm表
      $ sudo ipvsadm -C
  c.  使用ipvsadm安装LVS服务
      $ sudo ipvsadm -A -t 192.168.192.168:80 -s rr   ##192.168.192.168是虚拟IP
  d.  增加realserver
      $ sudo ipvsadm -a -t 192.168.192.168:80 -r 192.168.1.11:80 -m -w 1
      $ sudo ipvsadm -a -t 192.168.192.168:80 -r 192.168.1.128:80 -m -w 1
  e.  测试
      browser open 192.168.192.168,同时ipvsadm打开。
      $ sudo ipvsadm
      IP Virtual Server version 1.2.1 (size=4096)
      Prot LocalAddress:Port Scheduler Flags
        -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
      TCP  192.168.192.168:http rr
        -> 192.168.1.128:http           Masq    1      0          0
        -> 192.168.1.11:http            Masq    1      0          0


Nov 04 2008

nginx 和 syslog-ng 配合

Category: 技术ssmax @ 11:11:10

nginx本来不支持syslog的,虽然有个补丁,试了一下,配置性太差,error log 和access log 不能分开配置。。。

然后就想了一个方案,用syslog-ng ,也不用改nginx的源代码了,syslog-ng可以支持pipe输入

The sources, destinations, and filters available in syslog-ng are listed below. For details, see The syslog-ng Administrator Guide .

Name Description
internal() Messages generated internally in syslog-ng.
unix-stream() Opens the specified unix socket in SOCK_STREAM mode and listens for incoming messages.
unix-dgram() Opens the specified unix socket in SOCK_DGRAM mode and listens for incoming messages.
file() Opens the specified file and reads messages.
pipe(), fifo Opens the specified named pipe and reads messages.
tcp() Listens on the specified TCP port for incoming messages.
udp() Listens on the specified UDP port for incoming messages.
tcp6() Listens on the specified TCP port for incoming messages over IPv6.
udp6() Listens on the specified UDP port for incoming messages over IPv6.
sun-stream(), sun-streams() Opens the specified STREAMS device on Solaris systems and reads incoming messages.

Table 1.1. Source drivers available in syslog-ng

 

开始,先建立一个fifo文件(就是pipe啦)。。。

mkfifo logs/access.pipe

然后把nginx设置为

access_log  logs/access.pipe  main;

syslog-ng配置加上

source s_all {
        # message generated by Syslog-NG
        internal();
        # standard Linux log source (this is the default place for the syslog()
        # function to send logs to)
        unix-stream(“/dev/log”);
        # messages from the kernel
        file(“/proc/kmsg” log_prefix(“kernel: “));
        # use the following line if you want to receive remote UDP logging messages
        # (this is equivalent to the “-r” syslogd flag)
        # udp();
        pipe(“/home/nginx/logs/access.pipe”)
};

这样子就多了一个输入了,syslog-ng用file模式打开管道也可以的,不知道两者性能上面有没有差别,好像是没有什么区别的,另外一种fifo模式,就是pipe了,呵呵。

需要注意一下log_fifo_size的大小,这个是指的缓存多少行,而不是缓存多大。

如果不用pipe,用直接用access.log文件也是可以的,不过就是触发的时间太长,而且重启syslog-ng的时候可能会造成log重复。

设置真实文件的时候就需要注意多一些选项了,最重要就是follow_freq(),多久去tail一次,因为文件是没有poll的:

一般真实文件的例子
source s_tail { file("/var/log/apache/access.log" 
follow_freq(1) flags(no-parse)); };

9.1.1. Options common for every source

Some parameters affecting message parsing are common for all sources:

Name Type Default Description
flags() set of [no-parse,kernel] empty set Specifies log parsing flags. no-parse completely disables syslog message parsing and processes the complete line as the message part of a syslog message. Other information (timestamp, host, etc.) is added automatically. This flag is useful for parsing files not complying to the syslog format. kernel makes the source default to the LOG_KERN | LOG_CRIT priority if not specified otherwise.
follow_freq() number -1 Indicates that the source should be checked periodically instead of being polled. This is useful for files which always indicate readability, even though no new lines were appended. If this value is higher than zero, syslog-ng will not attempt to use poll() on the file, but checks whether the file changed every time the follow_freq() interval (in seconds) has elapsed.
keep_timestamp() yes or no yes Specifies whether syslog-ng should accept the timestamp received from the peer. If disabled, the time of reception will be used instead.
log_fetch_limit() number The value specified by the global log_fetch_limit() option, which defaults to 10. The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log_fetch_limit() is too high.
log_iw_size() number 100 The size of the initial window, this value is used during flow control.
log_msg_size() number The value specified by the global log_msg_size() option, which defaults to 8192. Specifies the maximum length of incoming log messages. Uses the value of the global option if not specified.
log_prefix() string   A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel: to the kernel messages on Linux.
optional() yes or no   Instruct syslog-ng to ignore the error if a specific source cannot be initialized. No other attempts to initialize the source will be made until the configuration is reloaded. This option currently applies to the pipe(), unix-dgram, and unix-stream drivers.
pad_size() number 0 Specifies input padding. Some operating systems (such as HP-UX) pad all 0 messages to block boundary. This option can be used to specify the block size. (HP-UX uses 2048 bytes). Syslog-ng will pad reads from the associated device to the number of bytes set in pad_size(). Mostly used on HP-UX where /dev/log is a named pipe and every write is padded to 2048 bytes.
time_zone() timezone in the form +/-HH:MM   The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.

Table 9.1. Common options for source drivers

 

nginx reload配置

 kill -HUP `head -1 /path/to/nginx/pid`

syslog-ng reload 配置,也一样

kill -HUP `head -1 /var/run/syslog-ng.pid`


Oct 24 2008

S.M.A.R.T. 数值的含义

Category: 技术ssmax @ 14:59:48

一般VALUE是当前值,WORST是曾经最差值,THRESH是出厂设定值,如果VALUE接近THRESH(一般就是VALUE小于或者等于THRESH)的时候,而且TYPE是Pre-fail的,就表示硬盘差不多坏了。

 

ATA S.M.A.R.T. Attributes

Each drive manufacturer defines a set of attributes, and sets threshold values beyond which attributes should not pass under normal operation. Each attribute has a raw value, whose meaning is entirely up to the drive manufacturer (but often corresponds to counts or a physical unit, such degrees Celsius or seconds), and a normalized value, which ranges from 1 to 253 (with 1 representing the worst case and 253 representing the best). Depending on the manufacturer, a value of 100 or 200 will often be chosen as the “normal” value.

Manufacturers that have supported at least one S.M.A.R.T. attribute in various products include: Samsung, Seagate, IBM (Hitachi), Fujitsu, Maxtor, Toshiba, Western Digital and ExcelStor Technology.

[edit] Known ATA S.M.A.R.T. attributes

The following chart lists some S.M.A.R.T. attributes and the typical meaning of their raw values. Normalized values are always mapped so that higher values are better (with only very rare exceptions such as the “Temperature” attribute on certain Seagate drives[12]), but higher raw attribute values may be better or worse depending on the attribute and manufacturer. For example, the “Reallocated Sectors Count” attribute’s normalized value decreases as the number of reallocated sectors increases. In this case, the attribute’s raw value will often indicate the actual number of sectors that were reallocated, although vendors are in no way required to adhere to this convention. As manufacturers do not necessarily agree on precise attribute definitions and measurement units, the following list of attributes should be regarded as a general guide only.

Legend
Higher raw value is better Lower raw value is better
Critical Potential indicators of imminent electromechanical failure
ID Hex Attribute name Better Description
01 01 Read Error Rate Indicates the rate of hardware read errors that occurred when reading data from a disk surface. A non-zero value indicates a problem with either the disk surface or read/write heads. Note that Seagate drives often report a raw value that is very high even on new drives, and does not thereby indicate a failure.
02 02 Throughput Performance Overall (general) throughput performance of a hard disk drive. If the value of this attribute is decreasing there is a high probability that there is a problem with the disk.
03 03 Spin-Up Time Average time of spindle spin up (from zero RPM to fully operational [millisecs]).
04 04 Start/Stop Count   A tally of spindle start/stop cycles.
05 05 Reallocated Sectors Count Count of reallocated sectors. When the hard drive finds a read/write/verification error, it marks this sector as “reallocated” and transfers data to a special reserved area (spare area). This process is also known as remapping, and “reallocated” sectors are called remaps. This is why, on modern hard disks, “bad blocks” cannot be found while testing the surface – all bad blocks are hidden in reallocated sectors. However, as the number of reallocated sectors increases, the read/write speed tends to decrease. The raw value normally represents a count of the number of bad sectors that have been found and remapped. Thus, the higher the attribute value, the more sectors the drive has had to reallocate.
06 06 Read Channel Margin   Margin of a channel while reading data. The function of this attribute is not specified.
07 07 Seek Error Rate Rate of seek errors of the magnetic heads. If there is a partial failure in the mechanical positioning system, then seek errors will arise. Such a failure may be due to numerous factors, such as damage to a servo, or thermal widening of the hard disk. More seek errors indicates a worsening condition of a disk’s surface or the mechanical subsystem, or both. Note that Seagate drives often report a raw value that is very high, even on new drives, and this does not normally indicate a failure.
08 08 Seek Time Performance Average performance of seek operations of the magnetic heads. If this attribute is decreasing, it is a sign of problems in the mechanical subsystem.
09 09 Power-On Hours (POH) Count of hours in power-on state. The raw value of this attribute shows total count of hours (or minutes, or seconds, depending on manufacturer) in power-on state.
10 0A Spin Retry Count Count of retry of spin start attempts. This attribute stores a total count of the spin start attempts to reach the fully operational speed (under the condition that the first attempt was unsuccessful). An increase of this attribute value is a sign of problems in the hard disk mechanical subsystem.
11 0B Recalibration Retries This attribute indicates the number of times recalibration was requested (under the condition that the first attempt was unsuccessful). A decrease of this attribute value is a sign of problems in the hard disk mechanical subsystem.
12 0C Device Power Cycle Count   This attribute indicates the count of full hard disk power on/off cycles.
13 0D Soft Read Error Rate Uncorrected read errors reported to the operating system. If the value is non-zero, you should back up your data.
189 BD High Fly Writes (WDC) Fly Height Monitor Improves Hard Drive Reliability. Western Digital’s Fly Height Monitor protects write operations by detecting when a recording head is flying outside its normal operating range. If an unsafe fly height condition is encountered, the write process is stopped, and the information is rewritten or reallocated to a safe region of the hard drive. This constant monitoring process increases the reliability of write operations and reduces the probability of read errors.The new Fly Height Monitor is being implemented in Western Digital’s drives, beginning with the WD Enterprise WDE18300 and WDE9180 Ultra2 SCSI hard drives, and will be included on all future WD Enterprise products.(http://www.wdc.com/en/library/2579-850123.pdf)
190 BE Airflow Temperature (WDC) Airflow temperature on Western Digital HDs (Same as temp. [C2], but current value is 50 less for some models. Marked as obsolete.)
190 BE Temperature Difference from 100 Value is equal to (100 – temp. °C), allowing manufacturer to set a minimum threshold which corresponds to a maximum temperature.(Seagate only?)[citation needed]
Seagate ST910021AS: Verified Present[citation needed]
Seagate ST9120823ASG: Verified Present under name “Airflow Temperature Cel” 2008-10-06
Seagate ST3802110A: Verified Present 2007-02-13[citation needed]
Seagate ST980825AS: Verified Present 2007-04-05[citation needed]
Seagate ST3320620AS: Verified Present 2007-04-23[citation needed]
Seagate ST3500641AS: Verified Present 2007-06-12[citation needed]
Seagate ST3250824AS: Verified Present 2007-08-07[citation needed]
Seagate ST31000340AS: Verified Present 2008-02-05[citation needed]
Seagate ST3160211AS: Verified Present 2008-06-12[citation needed]
Seagate ST3320620AS: Verified Present 2008-06-12[citation needed]
Seagate ST3400620AS: Verified Present 2008-06-12[citation needed]
Samsung HD501LJ: Verified Present under name “Airflow Temperature” 2008-03-02[citation needed]
Samsung HD753LJ: Verified Present under name “Airflow Temperature” 2008-07-15[citation needed]
191 BF G-sense error rate Frequency of mistakes as a result of impact loads[citation needed]
192 C0 Power-off Retract Count Number of times the heads are loaded off the media. Heads can be unloaded without actually powering off.[citation needed] (or Emergency Retract Cycle count – Fujitsu)[citation needed]
193 C1 Load/Unload Cycle Count of load/unload cycles into head landing zone position.[citation needed]
194 C2 Temperature Current internal temperature.
195 C3 Hardware ECC Recovered Time between ECC-corrected errors.[citation needed]
196 C4 Reallocation Event Count Count of remap operations. The raw value of this attribute shows the total number of attempts to transfer data from reallocated sectors to a spare area. Both successful & unsuccessful attempts are counted.
197 C5 Current Pending Sector Count Number of “unstable” sectors (waiting to be remapped). If the unstable sector is subsequently written or read successfully, this value is decreased and the sector is not remapped. Read errors on the sector will not remap the sector, it will only be remapped on a failed write attempt. This can be problematic to test because cached writes will not remap the sector, only direct I/O writes to the disk.
198 C6 Uncorrectable Sector Count The total number of uncorrectable errors when reading/writing a sector. A rise in the value of this attribute indicates defects of the disk surface and/or problems in the mechanical subsystem.
199 C7 UltraDMA CRC Error Count The number of errors in data transfer via the interface cable as determined by ICRC (Interface Cyclic Redundancy Check).
200 C8 Write Error Rate /
Multi-Zone Error Rate
The total number of errors when writing a sector.
201 C9 Soft Read Error Rate Number of off-track errors. If non-zero, make a backup.
202 CA Data Address Mark errors Number of Data Address Mark errors (or vendor-specific).[citation needed]
203 CB Run Out Cancel Number of ECC errors
204 CC Soft ECC Correction Number of errors corrected by software ECC[citation needed]
205 CD Thermal Asperity Rate (TAR) Number of thermal asperity errors.[citation needed]
206 CE Flying Height  ? Height of heads above the disk surface.[citation needed]
207 CF Spin High Current  ? Amount of high current used to spin up the drive.[citation needed]
208 D0 Spin Buzz  ? Number of buzz routines to spin up the drive[citation needed]
209 D1 Offline Seek Performance  ? Drive’s seek performance during offline operations[citation needed]
211 D3 Vibration During Write  ? Vibration During Write[citation needed]
212 D4 Shock During Write  ? Shock During Write[citation needed]
220 DC Disk Shift Distance the disk has shifted relative to the spindle (usually due to shock). Unit of measure is unknown.
221 DD G-Sense Error Rate The number of errors resulting from externally-induced shock & vibration.
222 DE Loaded Hours  ? Time spent operating under data load (movement of magnetic head armature)[citation needed]
223 DF Load/Unload Retry Count  ? Number of times head changes position.[citation needed]
224 E0 Load Friction Resistance caused by friction in mechanical parts while operating.[citation needed]
225 E1 Load/Unload Cycle Count Total number of load cycles[citation needed]
226 E2 Load ‘In’-time  ? Total time of loading on the magnetic heads actuator (time not spent in parking area).[citation needed]
227 E3 Torque Amplification Count Number of attempts to compensate for platter speed variations[citation needed]
228 E4 Power-Off Retract Cycle The number of times the magnetic armature was retracted automatically as a result of cutting power.[citation needed]
230 E6 GMR Head Amplitude  ? Amplitude of “thrashing” (distance of repetitive forward/reverse head motion)[citation needed]
231 E7 Temperature Drive Temperature
240 F0 Head Flying Hours  ? Time while head is positioning[citation needed]
250 FA Read Error Retry Rate Number of errors while reading from a disk
254 FE Free Fall Protection Number of “Free Fall Events” detected [13]


Oct 24 2008

keepalived failover机制的一些探讨

Category: 技术ssmax @ 14:21:56

一般来说keepalived failover它自动实现了的,不用什么设置,在vip和本机真实ip不同的情况下,这个默认的实现方式是能够工作的,但是当vip就是本机真实ip的时候,默认的设置就不能工作了,看了一下文档,估计就是vrrp的包发不出去,一般使用keepalived 都有内外网两个网卡,其实我们只要设置一下vrrp发的网卡和使用ip,就可以解决这个问题。

这个是master的配置,vip就是eth0上面的真实ip。

vrrp_instance LVS_GZ80 {
state MASTER
interface eth0
mcast_src_ip 172.31.31.80
lvs_sync_daemon_inteface eth1
virtual_router_id 55
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass ooxx
}
virtual_ipaddress {
x.x.55.80
}
}

下面就是backup机的设置
vrrp_instance LVS_GZ229 {
state BACKUP
interface eth0
mcast_src_ip 172.31.31.229
lvs_sync_daemon_inteface eth1
virtual_router_id 55
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass ooxx
}
virtual_ipaddress {
x.x.55.80
}
}

这样子设置,当master的keepalived服务fail了以后,我们能看到backup马上抢到了vip(也是master的真实ip),并且backup机器进入master state,log如下:
Oct 24 13:18:03 localhost Keepalived_vrrp: VRRP_Instance(LVS_GZ229) Transition to MASTER STATE
Oct 24 13:18:04 localhost Keepalived_vrrp: VRRP_Instance(LVS_GZ229) Entering MASTER STATE
Oct 24 13:18:04 localhost Keepalived_vrrp: VRRP_Instance(LVS_GZ229) setting protocol VIPs.
Oct 24 13:18:04 localhost Keepalived_healthcheckers: Netlink reflector reports IP x.x.55.80 added
Oct 24 13:18:04 localhost Keepalived_vrrp: VRRP_Instance(LVS_GZ229) Sending gratuitous ARPs on eth0 for x.x.55.80

当master的keepalived重新起来的时候,vrrp包能发送到backup机上面,backup就把vip重新让出来了。
backup上面可以看到如下log
Oct 24 13:18:22 localhost Keepalived_vrrp: VRRP_Instance(LVS_GZ229) Received higher prio advert
Oct 24 13:18:22 localhost Keepalived_vrrp: VRRP_Instance(LVS_GZ229) Entering BACKUP STATE
Oct 24 13:18:22 localhost Keepalived_vrrp: VRRP_Instance(LVS_GZ229) removing protocol VIPs.

如果没有这样设置的话,当master重新抢到ip之后,backup机并不能从master state进入backup state,在master上的keepalived服务再次fail了以后(master并不是死机,只是服务死了,master仍然占用vip),backup认为自己一直在master状态,并不会发gratuitous ARP包,这样到vip的请求还是回到原来的master。
这种情况下,典型的就是切换恢复以后不能看到上面的log,backup机器仍然运行在master模式。


« Previous PageNext Page »