安装编译过程
tar -xzvf super-smack-1.3.tar.gz && cd super-smack-1.3
./configure --with-mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include;make;make install
--with-mysql(指定数据库类型)
--with-mysql-lib(设置mysql/lib库的路径)
--with-mysql-include(设置mysql/include路径)
make编译时有一个报错,导致安装不能继续,需要修改super-smack-1.3/src/query.cc这个文件
修改query.cc
第193行:< int len = 0, num_recs = 0;修改成:> long len = 0; int num_recs = 0;第199,200行< int str_len = (*i).first.length();< if((unsigned)p + str_len + 3 *sizeof(int) < (unsigned)p_end )修改成:> long str_len = (*i).first.length();> if((long)p + str_len + 3 *sizeof(int) < (long)p_end )第219行< len = (unsigned)p - (unsigned)buf;修改成:> len = (long)p - (long)buf;
测试前准备:
1)smack 文件是放在 /usr/share/smacks/目录下:select-key.smack和update-select.smack需要修改2个文件中和数据库相关地方2处需要修改:
client "admin"
{
user "test";//数据库用户名
host "127.0.0.1";//数据库IP
db "test";//数据库
pass "123456";//数据库密码
socket "/tmp/mysql.sock"; // mysql.sock的放置位置
// ignored for PostgreSQL
}
2)正常运行应该出现下面的情况
一般报错:
(1)cp /usr/lib64/mysql/libmysqlclient.so.15.0.0 /usr/lib/ 如果没有这步会报错:
[root@mode bin]#super-smack -d mysql /usr/local/super-smack/select-key.smack 10 1000
super-smack: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
(2)指定select-key.smack或update-select.smack的位置,否则也会报错
[root@mode bin]# super-smack -d mysql select-key.smack 2 5
super-smack: Could not open input file select-key.smack errno = 2, error is No such file or directory
(3)如果把words.dat删掉了也会报错,用下面的语句可以再生成一个
生成原始数据文件。文件名必须是words.dat。super smack会去dir下面找文件名为words.dat的文件进行load file。
-f参数代表了测试数据的schema。
./gen-data -n 9000 -f %12-12s%n,%25-25s,%n,%d > /tmp/data/words.dat
正常情况:
参数解析:-d 数据库类型, -D 原始数据目录,2表示2个线程,每个线程 5个查询
[root@mode bin]# super-smack -d mysql /usr/share/smacks/select-key.smack 2 5
Error running query select count(*) from http_auth:Table 'nandi.http_auth' doesn't exist
Creating table 'http_auth'
Loading data from file '/var/smack-data/words.dat' into table 'http_auth'
Table http_auth is now ready for the test
Query Barrel Report for client smacker1
connect: max=0ms min=0ms avg= 0ms from 2 clients
Query_typenum_queriesmax_timemin_timeq_per_s
select_index20003270.11
[root@mode bin]# super-smack -d mysql /usr/share/smacks/select-key.smack 200 500
Query Barrel Report for client smacker1
connect: max=652ms min=0ms avg= 63ms from 200 clients
Query_type num_queries max_time min_time q_per_s
select_index 200000 0 0 16666.57
连接的最大、最小及平均花费时间
q_per_s:16666.57 QPS,每秒请求处理数
200000:脚本中,对查询次数做了翻倍处理
这是我安装的时候碰到的基本上都记录下来了,出现问题也是在网上找到的答案