压测收集统计信息脚本
#!/bin/sh
INTERVAL=5
PREFIX=$INTERVAL-sec-status
RUNFILE=/tmp/running
mysql -e 'show global variables' >> mysql-variables
while test -e $RUNFILE; do
file=$(date +%F_%I)
sleep=$(date +%s.%N | awk "{print $INTERVAL - (\$1 % $INTERVAL)}")
sleep $sleep
ts="$(date +"TS %s.%N %F %T")"
loadavg="$(uptime)"
echo "$ts $loadavg" >> $PREFIX-${file}-status
mysql -e 'show global status' >> $PREFIX-${file}-innodbstatus &
echo "$ts $loadavg" >> $PREFIX-${file}-innodbstatus
mysql -e 'SHOW ENGINE INNODB STATUS\G' >> $PREFIX-${file}-innodbstatus &
echo "$ts $loadavg" >> $PREFIX-${file}-processlist
mysql -e 'SHOW FULL processlist\G' >> $PREFIX-${file}-processlist &
echo $ts
done
echo Exiting because $RUNFILE does not exist.
sysbench
Sysbench是一个模块化、跨平台、多线程基准测试工具,主要用于评估测试各种不同的系统参数下的数据库负载情况.
1.CPU性能
2.磁盘I/O性能
3.调度程序性能
4.内存分配已经传输速度
5.POSIX线程性能
6.数据库性能(OLTP基准测试)
http://sourceforge.net/projects/Sysbench
yum install -y automake wget libtool zlib-devel
wget http://down1.chinaunix.net/distfiles/sysbench-0.4.10.tar.gz
tar zxvf sysbench-0.4.10.tar.gz
cd sysbench-0.4.10
sed -i 's/AC_PROG_LIBTOOL/#AC_PROG_LIBTOOL/g' configure.ac
sed -i '/#AC_PROG_LIBTOOL/a AC_PROG_RANLIB' configure.ac
mkdir /usr/local/sysbench
vim /etc/profile.d/sysbench.sh
export LD_LIBRARY_PATH=/mysql/lib
export PATH=/usr/local/sysbench/bin:$PATH
./autogen.sh
./configure --prefix=/usr/local/sysbench --with-mysql-includes=/usr/include --with-mysql-libs=/usr/lib64
make && make install
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29620572/viewspace-1820780/,如需转载,请注明出处,否则将追究法律责任。