寻觅生命中的那一片浅草......

每月存档 九月, 2010

自动kill掉超时的mysql show processlist进程

DB_HOST=”localhost”
DB_PORT=3306
DB_USER=”root”
DB_PASS=””
maxtime=10
sql=”SHOW PROCESSLIST”
sss=$(/usr/bin/mysqladmin processlist|sed -e “s/\s//g”|awk -F’|’ ‘{print $2,$7,substr($9,1,6)}’|awk ‘{if($2>'”$maxtime”‘ && $3==”SELECT”){print $1}}’)
for pid in $(echo “$sss”); do
/usr/bin/mysql -h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASS -e “kill $pid”
done
echo “$sss”
date

转载自:http://home.phpchina.com/space.php?uid=24549&do=blog&id=158758

The CentOS CD was not found in any of your CDROM drives

These days I customize CentOS5.4,I boot my ISO on vm , after I select languages and keyboard type, I meet this error:
The CentOS CD was not found in any of your CDROM drives.Please insert the CentOS CD and press OK to retry.

I compare the files of the offical ISO and my ISO, I find a file named “.discinfo” is not present in my ISO.Copy it to my ISO and the problem is solved.

Now I know “cp -a” will not handle the hidden file.

MySQL报错:my_global.h151615 error new No such file or directory

今天安装MySQL,在make的时候报错,错误信息如下:

In file included from mysys_priv.h:16,
from my_new.cc:21:
../include/my_global.h:1516:15: error: new: No such file or directory
make[1]: *** [my_new.o] Error 1
make[1]: Leaving directory `/opt/mysql-5.1.45-10/mysys’
make: *** [all-recursive] Error 1

检查了操作系统版本等情况,都没问题,configure时也没报错,可以正常产生Makefile

将有问题服(假设是A机)的config.log和另外一台正常服(假设是B机)的config.log做对比

发现A机,有2处比较严重的报错

conftest.c:181:21: error: termcap.h: No such file or directory
conftest.cpp:314:20: error: cxxabi.h: No such file or directory

在B机上
updatedb

for i in `locate termcap.h`; do rpm -qf $i; done |uniq
输出:
libtermcap-devel-2.0.8-46.1
ncurses-devel-5.5-24.20060715
dev86-0.16.17-2.2

for i in `locate cxxabi.h`; do rpm -qf $i; done |uniq
输出:

libstdc++-devel-4.1.2-48.el5
libstdc++44-devel-4.4.0-6.el5
xulrunner-devel-1.9.0.18-1.el5_4

到A机上用rpm -qa查询libtermcap-devel,ncurses-devel,dev86,libstdc++-devel,libstdc++44,xulrunner-devel的安装情况
发现libtermcap-devel,dev86,libstdc++-devel没有安装

yum -y install libtermcap-devel dev86 libstdc++-devel

然后再make,就没有报错了

[转]在64位的 CentOS 上只安装64位的软件包

在 64位版本的 CentOS 5.4 上使用 yum 安装软件包的时候如果不小心的话会同时安装 i386 和 x86_64 版本的软件,如下面安装的 httpd-devel 就有 i386 和 x86_64 两个版本:

引用
# yum install httpd-devel

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd-devel i386 2.2.3-31.el5.centos.2 updates 147 k
httpd-devel x86_64 2.2.3-31.el5.centos.2 updates 147 k
Installing for dependencies:

同时安装32位和64位版本的软件虽然不是什么错,也不会对系统造成什么问题,但是这样会浪费硬盘空间,而且显得系统臃肿、不干净。如果想要保持一个纯的64位系统、在64位 CentOS 上避免安装32位软件包的话很容易,只需要在 yum.conf 加上一行过滤掉 i386, i686 的软件包就可以了:

引用
# vi /etc/yum.conf
[main]

exclude=*.i?86

然后删除系统上已经按照的 i386/i686 包:

# vi /etc/yum.conf
# yum remove \*.i\?86

[转]Bash获得子进程返回值的方法

我们用“&”把进程放入后台以后,如果需要了解进程的执行情况,可以使用wait函数。默认情况下wait会等待任意子进程结束但是不会返回子进程的返回值。而以子进程的pid作为参数调用wait时,wait便能够返回该子进程的退出状态了。
具体操作如下:

#!/bin/bash
command1 &
command2 &
command3 &
for pid in $(jobs -p)
do
wait $pid
[ “x$?” == “x0” ] && ((count++))
done

这里我们借助了“jobs -p“来获得所有后台进程的pid。

2010年九月
« 8月   10月 »
 12345
6789101112
13141516171819
20212223242526
27282930