Nov 12 2008

笑话一则

Category: 乱up当秘笈ssmax @ 21:22:51

有一美女下夜班,被一好色男子尾随跟踪,美女很害怕,正好路过一片坟地, 好色男子正要下手, 美女走到一座坟墓前说:“爸爸,开门吧,我回来了”。吓的好色男子狂奔而去。  美女为自己的聪明得意地笑了起来,哪知笑声未落,从坟墓里传出一个阴森森的声音说:“闺女,你咋又忘记带钥匙了呢?”吓得美女尖叫著跑了。  这时,一个盗墓者从坟墓里爬了出来,说:“影响我工作,吓死你”。突然发现墓碑前有一老者,手拿凿子在刻墓碑,就好奇地问:“你在干吗”?老者生气地说:“这些不肖子孙把我的墓碑都刻错了,只好自己来改啦”。盗墓者一听,吓得撒腿就跑了。 看著盗墓者的背影,老者冷笑道:“跟老子抢生意,吓死你”。一不小心,凿子掉地上了,老者正要弯腰去拾,却看见从草丛中伸出一只手,同时还有个冷冰冰声音:“ 啊,敢乱改我家的门牌号”。吓得老者连滚带爬地跑了。  一个拾荒者从草丛中爬出来,捡起地上的凿子,感叹道:“这年头,捡块烂铁还得费这么大神。”祝辛苦挣钱的同志们天天快乐 !


Nov 12 2008

squid做二级proxy时候需要注意的

Category: 乱up当秘笈ssmax @ 13:49:03

因为后台直接撑不住连接数,需要在前台lvs+squid之间再加一层squid作为后台proxy,加上去以后发现频繁有

WARNING: Forwarding loop detected for:

错误,/etc/hosts和dns那边的设置是没有loop的应该,那唯一可能就是squid通过Via head来检查了,检查hostname,一看,果然如此。。。因为统一配置,proxy和前台的squid全部都是同一个hostname的,导致前台过来的请求被认为是loop了。

改一下配置文件的visible_hostname就好了

另外关于替换策略,proxy的命中率很低,看来要换几个替换策略再测试一下了。


Nov 11 2008

网站压力测试

Category: 技术ssmax @ 17:15:37

linux下面主要就是

Siege、webbench、ab

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

Windows下面就是微软的 Web Application Stress

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


Nov 10 2008

Category: 乱up当秘笈ssmax @ 17:53:11

从早上就一直没有停过手。。。

广州网通机房有 30台squid+3台lvs+1台lvs热备 顶图片的流量,tmd如果再挂就杀了我吧

顺便整理了一下机器,乱七八糟的原来,汗啊汗。

还要准备搬西单机房,靠,头疼。


Nov 09 2008

昨天立冬

Category: 乱up当秘笈ssmax @ 10:04:25

一下子冻了10度都有,等冬至再冻个10度,冬天就真的来了,现在只是秋天,哈哈


Nov 07 2008

Lighttpd 的连接数

Category: 乱up当秘笈ssmax @ 18:30:35

server.max-connections

server.max-fds

源代码看了一下,应该是和两个都有关,继续看看吧,今晚不知道还会不会挂掉。

今天下午boss说要不要去四川听讲座。。。汗啊,是什么xx沟冰川自然区。。。冰川,冻死啊,还要下周就出发,直接了当说不去了,tnnd都没人去竟然要摆我上台。


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 05 2008

i have a dream

Category: 乱up当秘笈ssmax @ 13:45:26

奥巴马获胜了,马丁路德金的dream也实现得差不多了吧。

今天奥巴马一获胜,我们的流量立刻上升了一倍多,看多还是很多人关注世界大事的。


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`


« Previous PageNext Page »