super-smack测试mysql性能
一.使用Red Hat Enterprise Linux Server release 5.4,x86_64位系统
二.环境安装
1.所需软件mysql5.1.38,super-smack1.3.tar.gz
2.解压super-smack1.3.tar.gz,./configure --with-mysql=/data/mysql,config过程会出现找不到libmysqlclient.so文件,系统使用的64位lib库文件,需要做个软连接
#locate libmysqlclient.so
#ln -s /usr/lib64/libmysqlclient.so /usr/lib/
make过程中提示如下错误
query.cc:200: error: cast from 'char*' to 'unsigned int' loses precision
query.cc:200: error: cast from 'char*' to 'unsigned int' loses precision
query.cc:219: error: cast from 'char*' to 'unsigned int' loses precision
query.cc:219: error: cast from 'char*' to 'unsigned int' loses precision
query.cc:200: error: cast from 'char*' to 'unsigned int' loses precision
query.cc:219: error: cast from 'char*' to 'unsigned int' loses precision
query.cc:219: error: cast from 'char*' to 'unsigned int' loses precision
修改super-smack-1.3/src目录下的query.cc
把200和219行的 unsigned 改成 long
重新make && make install
三.使用super-smack
1.#./super-smack -d mysql select-key-mysql.smack 10 1000
提示错误信息如下:
Error running query select count(*) from http_auth:Table 'test.http_auth' doesn't exist
Creating table 'http_auth'
Populating data file '/var/smack-data/words.dat' with shell command 'gen-data -n 90000 -f %12-12s%n,%25-25s,%n,%d'
sh: /var/smack-data/words.dat: No such file or directory
super-smack: Error generating data file errno = 2, error is No such file or directory
Creating table 'http_auth'
Populating data file '/var/smack-data/words.dat' with shell command 'gen-data -n 90000 -f %12-12s%n,%25-25s,%n,%d'
sh: /var/smack-data/words.dat: No such file or directory
super-smack: Error generating data file errno = 2, error is No such file or directory
#编辑select-key.smack,如下
(1)把两处mysql.sock路径改成mysql安装的实际路径
(2)把两处words.dat改成http_auth.dat
(3)把gen-data -n 90000 -f %12-12s%n,%25-25s,%n,%d这行的逗号,换成空格即可(看网上朋友说把逗号换成空格不行,经本次测试可以使用空格)
(4)把delim ","; 逗号提换成空格
修改完毕,保存
2.super-smack 执行过程中,可以创建http_auth表,但不能自动把数据导入到库中,原因不详,手动把数据导入到http_auth.dat文件中
#mkdir -p /var/smack-data/
#cp super-smack-1.3/smacks/* /usr/local/bin/
#./gen-data -n 90000 -f %12-12s%n %25-25s %n %d > /var/smack-data/http_auth.dat
3.执行,结果如下(myISAM表测试)
#./super-smack -d mysql smacks/select-key.smack 10 1000
Table 'http_auth' does not meet condtions, will be dropped
Creating table 'http_auth'
Loading data from file '/var/smack-data/http_auth.dat' into table 'http_auth'
Table http_auth is now ready for the test
Query Barrel Report for client smacker1
connect: max=5ms min=1ms avg= 2ms from 10 clients
Query_type num_queries max_time min_time q_per_s
select_index 20000 0 0 14947.59
Creating table 'http_auth'
Loading data from file '/var/smack-data/http_auth.dat' into table 'http_auth'
Table http_auth is now ready for the test
Query Barrel Report for client smacker1
connect: max=5ms min=1ms avg= 2ms from 10 clients
Query_type num_queries max_time min_time q_per_s
select_index 20000 0 0 14947.59
4.执行,结果如下(innodb表测试)
#.alter table http_auth engine=innodb;
#./super-smack -d mysql smacks/select-key.smack 10 1000
Query Barrel Report for client smacker1
connect: max=35ms min=0ms avg= 14ms from 10 clients
Query_type num_queries max_time min_time q_per_s
select_index 20000 0 0 14760.01
connect: max=35ms min=0ms avg= 14ms from 10 clients
Query_type num_queries max_time min_time q_per_s
select_index 20000 0 0 14760.01
注:1.-d指明是mysql数据库测试,然后指明测试文件,10表示10个线程,1000表示每个线程有1000个查询,q_per_s表示每秒钟查询记录。
2.update-select.smack测试,和select-key.smack修改的地方一样