愚人节那天,被开了个玩笑,托管在电信机房的某台服务器被取得Web Shell,系统平均负载(Load Average高达100多)。

症状分析

程序漏洞被利用,入侵者上传了sucrack这个多线程root密码破解程序,耗尽系统计算资源

Read the rest of this entry

作为系统管理员,经常会碰到这样一个场景:刚接手应用系统不久,业务扩展迅速,老板要求你再搭建N个应用环境,并希望尽量与运行中的平台一致。
犯难的是,前同事留下的文档不详细,没有关于几个主要Service的编译参数。这时你就必须设法取得信息。

1.通过软件包自己的version参数或者debug工具
例如,MySQL软件包中的mysqlbug,执行该工具,将返回debug信息,过滤出其中的Configure command代码块即可

Read the rest of this entry

, , ,

服务器某次故障,重启httpd出现如下错误提示

1
2
3
4
5
6
# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

Read the rest of this entry

,

在《解决Linux Server时间不准确的问题》一文中,使用了crontab定期执行ntpdate来校对时间。之后恰巧某博客上的文章,提出一个观点“时钟的跃变,有时候会导致很严重的问题。许多应用程序依赖连续的时钟——毕竟,这是一项常见的假定,即,取得的时间是线性的,一些操作,例如数据库事务, 通常会地依赖这样的事实:时间不会往回跳跃。”时间的瞬变,对于crontab等对时间敏感的系统任务,也是很容易造成错乱的。

Read the rest of this entry

,

服务器每隔好几个月,总会差那么几分钟。应对措施,就是每隔段时间,进行网络对时。

以下摘自《鸟哥的私房菜》,可解读为什么会有偏差的问题。

1
2
3
4
5
6
7
事實上,在我們的身邊就有很多的原子鐘,例如石英表,還有電腦主機上面的 BIOS 內部就含有一個原子鐘在
紀錄與計算時間的進行吶!不過由於原子鐘主要是利用計算晶片 (crystal) 的原子震盪週期去計時的,
這是因為每種晶片都有自己的獨特的震盪週期之故。 然而因為這種晶片的震盪週期在不同的晶片之間多多少少都會有點差異性,
甚至同一批晶片也可能會或多或少有些許的差異(就連溫度也可能造成這樣的誤差呢!),
因此也就造成了BIOS的時間會三不五時的給他快了幾秒或者慢了幾秒。
或許您會認為,BIOS 計時器每天快個五秒也沒有什麼了不起的,不過如果您再仔細的算一算,會發現,一天快五秒, 那麼一個月快2.5分鐘,
一年就快了 75 分鐘了!所以說,呵呵!時間差是真的會存在的! (依据该原理,只要关机或者重启次数越多,时间就会差得越离谱)

1.挑选最快最稳定的ntp上层服务器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
C:\Documents and Settings\linqp>ping ntp.api.bz -n 100
Approximate round trip times in milli-seconds:
Minimum = 67ms, Maximum = 89ms, Average = 80ms

C:\Documents and Settings\linqp>ping t3.hshh.org -n 50
Approximate round trip times in milli-seconds:
Minimum = 18ms, Maximum = 22ms, Average = 19ms

C:\Documents and Settings\linqp>ping t1.hshh.org -n 50
Approximate round trip times in milli-seconds:
Minimum = 22ms, Maximum = 27ms, Average = 24ms

C:\Documents and Settings\linqp>ping 1.cn.pool.ntp.org -n 50
Ping statistics for 122.226.192.4:
Packets: Sent = 50, Received = 50, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 18ms, Maximum = 24ms, Average = 21ms

2.使用ntpdate同步系统时间

1
root@krc:~# /usr/sbin/ntpdate t3.hshh.org

修改前

1
2
3
4
root@krc:~# date
Tue Jul 13 16:22:42 CST 2010
root@krc:~# hwclock -r
Tue 13 Jul 2010 04:21:23 PM CST -0.001126 seconds

修改后

1
2
3
4
root@krc:~# date
Tue Jul 13 16:26:33 CST 2010
root@krc:~# hwclock -r
Tue 13 Jul 2010 04:26:45 PM CST -0.001124 seconds

3.建立计划任务

1
2
3
4
5
6
7
8
9
10
root@krc:~#crontab -e
# m h dom mon dow command
00 00 * * * /bin/bash /usr/local/webserver/nginx/sbin/cut_nginx_log.sh
28 23 * * * /etc/webmin/cron/tempdelete.pl
1 0 * * 1 find /data1/backup_zone/data_www/* -mtime +28 |xargs rm -f
10 00 * * 1 cat /dev/null > /data1/backup_zone/data_www/snapfile
11 00 * * * bash /root/script-bak/bak_www.sh
1 1 * * * bash /root/script-bak/bak_conf.sh
11 1 * * 1 find /data1/backup_zone/data_conf/* -mtime +28 |xargs rm -f
*/10 * * * * /usr/sbin/ntpdate t3.hshh.org && /sbin/hwclock -w

4.参考资料

1
2
3
鸟哥的教程 http://linux.vbird.org/linux_server/0440ntp.php
Public NTP Server http://support.ntp.org/bin/view/Servers/StratumTwoTimeServers
Asia Public NTP Server http://www.pool.ntp.org/zone/asia

系统环境 – Vmware WorkStation 7(同系列其他产品,如ESX/Esxi类似)

客户机操作系统 – Ubunt Linux Server 9.10

搭建测试环境,为了快速部署,使用Vmware的Clone功能,快速复制出许多客户机。

启动后发现个问题,除了源客户机,其他副本客户机,网络功能都不正常,具体表现为

  1. ifconfig输出的网络配置,只有lo,没有eth0
  2. “ifconfig –a”输出的网络配置中,eth0已经被自动修改为eth1了
  3. /etc/udev/rules.d/70-persistent-net.rules中,有eth0和eth1的详细定义。eth0为源客户机copy过来的;eth1为虚拟机自动生成的新网卡,定义区块的ATTR{address}记录着新网卡的mac(在虚拟机目录的VMX文件中,也能找到该mac地址)

Read the rest of this entry

,

多人管理同一台Linux Server,为了方便审计,最好在history内加入操作时间。

It comes in handy particularly if there are multiple people maintaining a given server (so you can see when a command was performed) or even if you are the sole maintainer, but can’t remember exactly when you did or changed something.

Edit your /etc/bashrc and append to the bottom:

export HISTTIMEFORMAT="%h/%d – %H:%M:%S "

Read the rest of this entry

故障现象

某Web服务器,突然出现以下问题,php-cgi僵死在进程里,无法重启

www 9463 0.0 0.3 41996 13612 ? D Apr19 1:22 /usr/local/php/bin/php-cgi –fpm
www 20858 0.0 0.3 40408 12932 ? D May05 1:55 /usr/local/php/bin/php-cgi –fpm
www 20866 0.0 0.3 40688 13296 ? D May05 1:53 /usr/local/php/bin/php-cgi –fpm
www 20878 0.0 0.3 40932 13604 ? D May05 1:51 /usr/local/php/bin/php-cgi –fpm
www 24288 0.0 0.3 40436 12880 ? D Apr15 2:36 /usr/local/php/bin/php-cgi –fpm
www 26881 0.0 0.3 41596 13712 ? D Apr16 6:11 /usr/local/php/bin/php-cgi –fpm
www 26921 0.0 0.3 43224 15848 ? D Apr16 5:57 /usr/local/php/bin/php-cgi –fpm
www 26983 0.0 0.3 42736 14524 ? D Apr16 6:01 /usr/local/php/bin/php-cgi –fpm
www 27007 0.0 0.3 42608 14248 ? D Apr16 6:01 /usr/local/php/bin/php-cgi –fpm
www 27023 0.0 0.3 42464 15172 ? D Apr16 5:57 /usr/local/php/bin/php-cgi –fpm

处理过程

Read the rest of this entry