码迷,mamicode.com
首页 > 其他好文 > 详细

sysbench测试服务器性能

时间:2016-06-17 12:23:29      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

sysbench目前已经有0.5的版本,不过最普遍使用的依旧是0.4.12,所以接下来我们会以0.4.12这个版本作为测试

 

Step1:下载安装sysbench

wget http://pkgs.fedoraproject.org/repo/pkgs/sysbench/sysbench-0.4.12.tar.gz/3a6d54fdd3fe002328e4458206392b9d/sysbench-0.4.12.tar.gz
tar zxvf sysbench-0.4.12.tar.gz
yum install libtool.x86_64 openssl-devel.x86_64 openssl-static.x86_64
cd sysbench-0.4.12/
libtoolize --force --copy
./autogen.sh
./configure --prefix=/usr/local/sysbench
make
make install

 

Step2: 执行测试脚本(请不要直接粘贴此脚本到你机器上运行,除非你知道它在做什么):

[root@DBServer data]# cat sysbench_all.sh 
#!/bin/bash


result_dir=/data/result
io_file_dir=/data/iotest

if [ ! -d $result_dir ];
then 
   mkdir $result_dir
fi

#------------------------------fileio test-----------------------------------
###RAND WRITE 1 - 16 thread
if [ ! -d $io_file_dir ];
then
   mkdir $io_file_dir
fi

cd $io_file_dir

#sysbench --test=fileio --file-total-size=256G --file-num=64 prepare
#sleep 10

for rwtype in seqwr seqrewr seqrd rndrd rndwr rndrw;
do
  for numthread in 1 2 4 8 10 16 20 32 40;
    do
       sysbench --test=fileio --file-total-size=256G --file-test-mode=$rwtype --max-time=600 --max-requests=0 --file-block-size=4K --file-num=64 --num-threads=$numthread run >> $result_dir/io_${rwtype}_thread${numthread}.txt ;
       sleep 10;
  done
done



#-----------------------------cpu test--------------------------------
   
for each in 1 `seq 2 2 40`; 
do 
    sysbench --test=cpu --cpu-max-prime=40000 --num-threads=$each run >> $result_dir/CPU_thread$each.txt  ;
    sleep 10
done

#------------------------------ram test--------------------------------

# for read
for each in 1 `seq 2 4 40`; 
do 
    sysbench --test=memory --memory-block-size=4K --memory-scope=global --memory-total-size=256G --memory-oper=read --num-threads=$each run >> $result_dir/RamRead_thread$each.txt  ;  
    sleep 10 ; 
done


#for write
for each in 1 `seq 2 4 40`; 
do 
   sysbench --test=memory --memory-block-size=4K --memory-scope=global --memory-total-size=256G --memory-oper=write --num-threads=$each run >> $result_dir/RamWrite_thread$each.txt  ; 
   sleep 10; 
done

#--------------------------mysql test------------------------------

# start mysql
mysqld_safe --defaults-file=/data/mysql/my3306.cnf &

#wait mysql startup completely
sleep 20

#prepare  10000000 is 2G
#sysbench --test=oltp --db-driver=mysql --mysql-host=127.0.0.1 --mysql-user=root --mysql-password=123 --mysql-db=t_sysbench --oltp-table-size=10000000 --num-threads=40 prepare

# only read
for each in 1 4 8 16 20 32 40;
do
    sysbench --test=oltp --oltp-table-size=10000000 --db-driver=mysql --mysql-host=127.0.0.1 --mysql-db=t_sysbench --mysql-user=root --mysql-password=123 --max-time=900 --oltp-read-only=on --max-requests=0 --num-threads=$each run >> $result_dir/mysql_read_thread$each.txt
    sleep 20
done

#read and write
for each in 1 4 8 16 20 32 40;
do
    sysbench --test=oltp --oltp-table-size=10000000 --db-driver=mysql --mysql-host=127.0.0.1 --mysql-db=t_sysbench --mysql-user=root --mysql-password=123 --max-time=900 --max-requests=0 --num-threads=$each run >> $result_dir/mysql_rw_thread$each.txt
  sleep 20
done

mysqldadmin -uroot -p123 -h127.0.0.1 shutdown

 

Step3:分析处理,需要用到类似如下的处理分析脚本(以分析mysql为例)

[root@DBServer result]# awk -F [():] /Number of threads:/{printf $2 "\t"} /transactions:/{printf $3 "\t"} /deadlocks:/{printf $2 "\t"}  /read\/write requests:/{printf $3 "\t"}  /approx.  95 percentile:/{printf $2 "\n"} mysql_rw_thread* | sort -k 1 -n
 1    403.66 per sec.                               0          7669.51 per sec.                      2.83ms
 4    1409.01 per sec.                               0          26771.12 per sec.                   3.20ms
 8    2704.40 per sec.                               3          51383.70 per sec.                   3.30ms
 16    4032.52 per sec.                               8          76618.00 per sec.                   4.51ms
 20    4504.20 per sec.                               12         85580.07 per sec.                   5.29ms
 32    5549.82 per sec.                               48         105447.54 per sec.                   8.58ms
 40    5920.90 per sec.                               108        112499.04 per sec.                  11.54ms

 

 

参考资源:

https://wiki.mikejung.biz/Sysbench

 

sysbench测试服务器性能

标签:

原文地址:http://www.cnblogs.com/zejin2008/p/5593557.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!