压测之sysbench安装和MySQL只读测试

sysbench编译安装

[root@DS-VM-Node160 ~]# cd /tmp/
[root@DS-VM-Node160 /tmp]# git clone https://github.com/akopytov/sysbench.git
[root@DS-VM-Node160 /tmp]# cd sysbench/
[root@DS-VM-Node160 /tmp/sysbench]# yum install mysql mysql-devel libtool openssl-devel openssl-static mysql-community-devel -y
[root@DS-VM-Node160 /tmp/sysbench]# ./configure -V
sysbench configure 0.5
generated by GNU Autoconf 2.69
 
Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
[root@DS-VM-Node160 /tmp/sysbench]#
[root@DS-VM-Node160 /tmp/sysbench]# libtoolize --force --copy
[root@DS-VM-Node160 /tmp/sysbench]# ./autogen.sh
[root@DS-VM-Node160 /tmp/sysbench]# ./configure --prefix=/usr/local/sysbench
###如果需要测试PostgreSQL、Oracle,则在configure时需要加上 --with-oracle 或者 --with-pgsql 参数
[root@DS-VM-Node160 /tmp/sysbench]# make -j `awk '/processor/{a++}END{print a}' /proc/cpuinfo` && make install
#0.5版本需要oltp.lua测试脚本
#如果是rpm包方式安装的,在 /usr/share/doc/sysbench/tests/db/ 下可找到
[root@DS-VM-Node160 /tmp/sysbench]# cp -ai sysbench/tests /usr/local/sysbench/
[root@DS-VM-Node160 /tmp/sysbench]# echo 'export PATH=/usr/local/sysbench/bin:$PATH' >/etc/profile.d/sysbench.sh
[root@DS-VM-Node160 /tmp/sysbench]# . /etc/profile.d/sysbench.sh
[root@DS-VM-Node160 /tmp/sysbench]# which sysbench && cd
/usr/local/sysbench/bin/sysbench
[root@DS-VM-Node160 /tmp/sysbench]# sysbench --version
sysbench 0.5

sysbench 使用yum安装

[root@DS-VM-Node160 /tmp]# yum install http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm -y
[root@DS-VM-Node160 /tmp/sysbench]# yum install sysbench -y

使用sysbench测试MySQL

##创建一个压测使用的库
[root@DS-VM-Node160 ~]# mysql -uroot -p******* -h10.10.231.149 -P3317 -e 'SELECT version();'
+-----------------------+
| version()             |
+-----------------------+
| 10.0.25-MariaDB-wsrep |
+-----------------------+
[root@DS-VM-Node160 ~]# mysql -uroot -p****** -h10.10.231.149 -P3317 -e 'CREATE DATABASE sysbench;'
[root@DS-VM-Node160 ~]# mysql -uroot -p****** -h10.10.231.149 -P3317 -e "SHOW DATABASES LIKE '%sysbench%';"
+-----------------------+
| Database (%sysbench%) |
+-----------------------+
| sysbench              |
+-----------------------+
[root@DS-VM-Node160 ~]#

###创建测试帐户
[root@DS-VM-Node160 ~]# mysql -uroot -p****** -h10.10.231.149 -P3317 -e "GRANT ALL PRIVILEGES ON *.* TO 'sysbench'@'10.%.%.%' IDENTIFIED  BY 'lookback';"
[root@DS-VM-Node160 ~]# mysql -uroot -p****** -h10.10.231.149 -P3317 -e "SELECT User,Password,Host FROM mysql.user WHERE User LIKE '%sysbench%';"
+----------+-------------------------------------------+----------+
| User     | Password                                  | Host     |
+----------+-------------------------------------------+----------+
| sysbench | *153CCFAEAA83407D8DBDBFAA3D17B1A95553E60C | 10.%.%.% |
+----------+-------------------------------------------+----------+
[root@DS-VM-Node160 ~]#
创建测试数据 表中有1kw条 估计大小有2GB
1
[root@DS-VM-Node160 ~]# sysbench --test=oltp --test=/usr/local/sysbench/tests/db/oltp.lua --db-driver=mysql --oltp-table-size=10000000 --mysql-db=sysbench --mysql-user=sysbench --mysql-password=lookback --mysql-host=10.10.231.149 --mysql-port=3317 prepare
###注意最后一个,一项测试开始前需要用prepare来准备好表和数据,run执行真正的压测,cleanup用来清除数据和表。
sysbench 0.5: multi-threaded system evaluation benchmark
生成表的格式

[root@DS-VM-Node160 ~]# mysql -usysbench -plookback -h10.10.231.149 -P3317 -e "SELECT * FROM sysbench.sbtest1 ORDER BY id LIMIT 5;"
+----+---------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
| id | k       | c                                                                                                                       | pad                                                     |
+----+---------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
|  2 | 3718516 | 08566691963-88624912351-16662227201-46648573979-64646226163-77505759394-75470094713-41097360717-15161106334-50535565977 | 63188288836-92351140030-06390587585-66802097351-49282961843 |
|  5 | 5934152 | 05879259692-02024081996-76022818191-82933803603-81845875017-31928300264-16934042125-67052432228-92123768050-95121478647 | 79362588344-09017007031-35411714211-52054317597-26283585383 |
|  8 | 3082941 | 16663631067-14838697989-64358398406-16917073223-47713406217-78812818873-46576803224-61955865221-97956448087-49259465660 | 52468633478-82076178857-68496668227-22002343387-57481185690 |
| 11 | 3371969 | 88814841367-98767826715-60494483894-21079440118-10718401291-33837777683-38627243809-45118876335-22718290515-23426562159 | 79384524915-41356971023-74955511882-92798558059-93482034638 |
| 14 | 4988307 | 87263726817-94340135738-17557808545-78801760644-04111877554-34439976372-12880746592-22897263227-59023974220-20489960934 | 34521232779-81152534024-26776427142-43102257779-39982840334 |
+----+---------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+
[root@DS-VM-Node160 ~]#
Creating table 'sbtest1'...
Inserting 10000000 records into 'sbtest1'

开始做OLTP只读测试 分别测试1 4 8 16 32 64线程
[root@DS-VM-Node160 ~]# for i in 1 4 8 16 32 64; do sysbench --test=oltp --test=/usr/local/sysbench/tests/db/oltp.lua --db-driver=mysql --oltp-table-size=10000000 --mysql-db=sysbench --mysql-user=sysbench --mysql-password=lookback --mysql-host=10.10.231.149 --mysql-port=3317 --max-time=60 --max-requests=0 --oltp-read-only --oltp-skip-trx  --oltp-nontrx-mode=select --oltp-dist-type=uniform --oltp-test-mode=nontrx --report-interval=10 --num-threads=$i run; sleep 10; done
###参数解释
--max-requests=0:压力测试产生请求的总数,如果以下面的max-time来记,这个值设为0
#--max-time=60 压测时间,此处设置为1分钟
#--max-requests=0 limit for total number of requests [10000] "0 是无限制"
#--oltp-read-only=on:表示不产生只读SQL,也就是使用oltp.lua时会采用只读模式。默认 off,如果设置为on,则不会产生update,delete,insert的sql。
#--oltp-nontrx-mode=select 查询类型对于非事务执行模式{select, update_key, update_nokey, insert, delete} [select]
#--num-threads 并发线程数,可以理解为模拟的客户端并发连接数
#--oltp-tables-count=10 表数量
#--oltp-reconnect-mode=STRING 重新连接模式{session(不使用重新连接。每个线程断开只在测试结束),transaction(在每次事务结束后重新连接),query(在每个SQL语句执行完重新连接),random(对于每个事务随机选择以上重新连接模式)}。默认是session
#--oltp-dist-type=uniform:指定随机取样类型,可选值有 uniform(均匀分布), Gaussian(高斯分布), special(空间分布)。默认是special
#--oltp-test-mode=nontrx:执行模式,这里是非事务式的。可选值有simple,complex,nontrx。默认是complex
    simple:简单查询,SELECT c FROM sbtest WHERE id=N
    complex (advanced transactional):事务模式在开始和结束事务之前加上begin和commit, 一个事务里可以有多个语句,如点查询、范围查询、排序查询、更新、删除、插入等,并且为了不破坏测试表的数据,该模式下一条记录删除后会在同一个事务里添加一条相同的记录。
    nontrx (non-transactional):与simple相似,但是可以进行update/insert等操作,所以如果做连续的对比压测,你可能需要重新cleanup,prepare。
#--rand-init=on:是否随机初始化数据,如果不随机化那么初始好的数据每行内容除了主键不同外其他完全相同
#--report-interval=10:表示每10s输出一次测试进度报告
注意,针对不同的选项取值就会有不同的子选项。比如oltp-dist-type=special,就有比如oltp-dist-pct=1、oltp-dist-res=50两个子选项,代表有50%的查询落在1%的行(即热点数据)上,另外50%均匀的(sample uniformly)落在另外99%的记录行上。
再比如oltp-test-mode=nontrx时, 就可以有oltp-nontrx-mode,可选值有select(默认), update_key, update_nokey, insert, delete,代表非事务式模式下使用的测试sql类型。
以上代表的是一个只读的例子,可以把num-threads依次递增(16,36,72,128,256,512),或者调整my.cnf参数,比较效果。另外需要注意的是,大部分mysql中间件对事务的处理,默认都是把sql发到主库执行,所以只读测试需要加上oltp-skip-trx=on来跳过测试中的显式事务。
ps1: 只读测试也可以使用share/tests/db/select.lua进行,但只是简单的point select。
ps2: 我在用sysbench压的时候,在mysql后端会话里有时看到大量的query cache lock,如果使用的是uniform取样,最好把查询缓存关掉。当然如果是做两组性能对比压测,因为都受这个因素影响,关心也不大。
下面是上面语句的测试结果

[root@DS-VM-Node160 ~]# for i in 1 4 8 16 32 64; do sysbench --test=oltp --test=/usr/local/sysbench/tests/db/oltp.lua --db-driver=mysql --oltp-table-size=10000000 --mysql-db=sysbench --mysql-user=sysbench --mysql-password=lookback --mysql-host=10.10.231.149 --mysql-port=3317 --max-time=60 --max-requests=0 --oltp-read-only --oltp-skip-trx  --oltp-nontrx-mode=select --oltp-dist-type=uniform --oltp-test-mode=nontrx --report-interval=10 --num-threads=$i run; sleep 10; done
sysbench 0.5:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 1
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
 
 
Initializing worker threads...
 
Threads started!
 
[  10s] threads: 1, tps: 86.10, reads: 1205.98, writes: 344.39, response time: 12.78ms (95%), errors: 0.00, reconnects:  0.00
[  20s] threads: 1, tps: 80.30, reads: 1124.00, writes: 321.20, response time: 13.50ms (95%), errors: 0.00, reconnects:  0.00
[  30s] threads: 1, tps: 80.20, reads: 1122.70, writes: 320.80, response time: 13.72ms (95%), errors: 0.00, reconnects:  0.00
[  40s] threads: 1, tps: 80.30, reads: 1124.10, writes: 321.20, response time: 13.63ms (95%), errors: 0.00, reconnects:  0.00
[  50s] threads: 1, tps: 79.70, reads: 1117.00, writes: 319.10, response time: 13.76ms (95%), errors: 0.00, reconnects:  0.00
[  60s] threads: 1, tps: 78.00, reads: 1091.90, writes: 311.70, response time: 14.22ms (95%), errors: 0.00, reconnects:  0.00
OLTP test statistics:
    queries performed:
        read:                            67858
        write:                           19388
        other:                           9694
        total:                           96940
    transactions:                        4847   (80.78 per sec.)
    read/write requests:                 87246  (1454.00 per sec.)
    other operations:                    9694   (161.56 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)
 
General statistics:
    total time:                          60.0040s
    total number of events:              4847
    total time taken by event execution: 59.9929s
    response time:
         min:                                 10.15ms
         avg:                                 12.38ms
         max:                                112.96ms
         approx.  95 percentile:              13.65ms
 
Threads fairness:
    events (avg/stddev):           4847.0000/0.00
    execution time (avg/stddev):   59.9929/0.00
 
sysbench 0.5:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 4
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
 
 
Initializing worker threads...
 
Threads started!
 
[  10s] threads: 4, tps: 299.69, reads: 4199.52, writes: 1199.48, response time: 15.47ms (95%), errors: 0.00, reconnects:  0.00
[  20s] threads: 4, tps: 299.70, reads: 4197.30, writes: 1198.90, response time: 14.89ms (95%), errors: 0.00, reconnects:  0.00
[  30s] threads: 4, tps: 300.90, reads: 4207.30, writes: 1202.80, response time: 15.22ms (95%), errors: 0.00, reconnects:  0.00
[  40s] threads: 4, tps: 295.20, reads: 4134.80, writes: 1180.90, response time: 15.72ms (95%), errors: 0.00, reconnects:  0.00
[  50s] threads: 4, tps: 287.30, reads: 4025.80, writes: 1150.10, response time: 16.49ms (95%), errors: 0.00, reconnects:  0.00
[  60s] threads: 4, tps: 298.90, reads: 4181.90, writes: 1194.60, response time: 16.48ms (95%), errors: 0.00, reconnects:  0.00
OLTP test statistics:
    queries performed:
        read:                            249494
        write:                           71284
        other:                           35642
        total:                           356420
    transactions:                        17821  (296.96 per sec.)
    read/write requests:                 320778 (5345.30 per sec.)
    other operations:                    35642  (593.92 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)
 
General statistics:
    total time:                          60.0113s
    total number of events:              17821
    total time taken by event execution: 239.9966s
    response time:
         min:                                 10.87ms
         avg:                                 13.47ms
         max:                                122.42ms
         approx.  95 percentile:              15.66ms
 
Threads fairness:
    events (avg/stddev):           4455.2500/9.44
    execution time (avg/stddev):   59.9992/0.00
 
sysbench 0.5:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 8
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
 
 
Initializing worker threads...
 
Threads started!
 
[  10s] threads: 8, tps: 485.19, reads: 6799.80, writes: 1941.77, response time: 22.12ms (95%), errors: 0.00, reconnects:  0.00
[  20s] threads: 8, tps: 481.50, reads: 6744.80, writes: 1926.80, response time: 23.56ms (95%), errors: 0.00, reconnects:  0.00
[  30s] threads: 8, tps: 480.10, reads: 6715.70, writes: 1918.80, response time: 24.27ms (95%), errors: 0.00, reconnects:  0.00
[  40s] threads: 8, tps: 452.50, reads: 6340.60, writes: 1811.60, response time: 24.72ms (95%), errors: 0.00, reconnects:  0.00
[  50s] threads: 8, tps: 480.40, reads: 6722.80, writes: 1921.40, response time: 24.54ms (95%), errors: 0.00, reconnects:  0.00
[  60s] threads: 8, tps: 485.20, reads: 6796.00, writes: 1942.00, response time: 24.75ms (95%), errors: 0.00, reconnects:  0.00
OLTP test statistics:
    queries performed:
        read:                            401198
        write:                           114628
        other:                           57314
        total:                           573140
    transactions:                        28657  (477.27 per sec.)
    read/write requests:                 515826 (8590.92 per sec.)
    other operations:                    57314  (954.55 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)
 
General statistics:
    total time:                          60.0432s
    total number of events:              28657
    total time taken by event execution: 480.2772s
    response time:
         min:                                 11.03ms
         avg:                                 16.76ms
         max:                                294.31ms
         approx.  95 percentile:              24.07ms
 
Threads fairness:
    events (avg/stddev):           3582.1250/9.12
    execution time (avg/stddev):   60.0346/0.00
 
sysbench 0.5:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 16
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
 
 
Initializing worker threads...
 
Threads started!
 
[  10s] threads: 16, tps: 755.09, reads: 10587.34, writes: 3021.85, response time: 30.39ms (95%), errors: 0.00, reconnects:  0.00
[  20s] threads: 16, tps: 753.80, reads: 10553.58, writes: 3014.79, response time: 30.25ms (95%), errors: 0.00, reconnects:  0.00
[  30s] threads: 16, tps: 694.90, reads: 9728.53, writes: 2778.51, response time: 35.96ms (95%), errors: 0.00, reconnects:  0.00
[  40s] threads: 16, tps: 571.10, reads: 8001.37, writes: 2290.79, response time: 33.51ms (95%), errors: 0.00, reconnects:  0.00
[  50s] threads: 16, tps: 563.60, reads: 7883.93, writes: 2249.71, response time: 32.86ms (95%), errors: 0.00, reconnects:  0.00
[  60s] threads: 16, tps: 756.50, reads: 10586.50, writes: 3025.50, response time: 30.67ms (95%), errors: 0.00, reconnects:  0.00
OLTP test statistics:
    queries performed:
        read:                            573524
        write:                           163864
        other:                           81932
        total:                           819320
    transactions:                        40966  (682.58 per sec.)
    read/write requests:                 737388 (12286.43 per sec.)
    other operations:                    81932  (1365.16 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)
 
General statistics:
    total time:                          60.0165s
    total number of events:              40966
    total time taken by event execution: 960.0691s
    response time:
         min:                                 12.99ms
         avg:                                 23.44ms
         max:                               2295.61ms
         approx.  95 percentile:              32.15ms
 
Threads fairness:
    events (avg/stddev):           2560.3750/33.23
    execution time (avg/stddev):   60.0043/0.01
 
sysbench 0.5:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 32
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
 
 
Initializing worker threads...
 
Threads started!
 
[  10s] threads: 32, tps: 891.19, reads: 12504.40, writes: 3568.44, response time: 54.01ms (95%), errors: 0.00, reconnects:  0.00
[  20s] threads: 32, tps: 998.60, reads: 13975.92, writes: 3992.61, response time: 51.92ms (95%), errors: 0.00, reconnects:  0.00
[  30s] threads: 32, tps: 962.60, reads: 13476.78, writes: 3849.79, response time: 48.25ms (95%), errors: 0.00, reconnects:  0.00
[  40s] threads: 32, tps: 1046.50, reads: 14653.70, writes: 4187.60, response time: 46.25ms (95%), errors: 0.00, reconnects:  0.00
[  50s] threads: 32, tps: 1009.70, reads: 14140.21, writes: 4036.90, response time: 47.09ms (95%), errors: 0.00, reconnects:  0.00
[  60s] threads: 32, tps: 966.20, reads: 13520.91, writes: 3865.00, response time: 49.98ms (95%), errors: 0.00, reconnects:  0.00
OLTP test statistics:
    queries performed:
        read:                            822920
        write:                           235120
        other:                           117560
        total:                           1175600
    transactions:                        58780  (978.89 per sec.)
    read/write requests:                 1058040 (17620.08 per sec.)
    other operations:                    117560 (1957.79 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)
 
General statistics:
    total time:                          60.0474s
    total number of events:              58780
    total time taken by event execution: 1920.5471s
    response time:
         min:                                 14.57ms
         avg:                                 32.67ms
         max:                                732.59ms
         approx.  95 percentile:              49.49ms
 
Threads fairness:
    events (avg/stddev):           1836.8750/27.39
    execution time (avg/stddev):   60.0171/0.01
 
sysbench 0.5:  multi-threaded system evaluation benchmark
 
Running the test with following options:
Number of threads: 64
Report intermediate results every 10 second(s)
Random number generator seed is 0 and will be ignored
 
 
Initializing worker threads...
 
Threads started!
 
[  10s] threads: 64, tps: 1094.98, reads: 15400.07, writes: 4391.91, response time: 101.24ms (95%), errors: 0.00, reconnects:  0.00
[  20s] threads: 64, tps: 1052.40, reads: 14737.81, writes: 4204.60, response time: 106.62ms (95%), errors: 0.00, reconnects:  0.00
[  30s] threads: 64, tps: 1129.60, reads: 15817.40, writes: 4522.60, response time: 98.67ms (95%), errors: 0.00, reconnects:  0.00
[  40s] threads: 64, tps: 956.60, reads: 13404.34, writes: 3840.78, response time: 111.78ms (95%), errors: 0.00, reconnects:  0.00
[  50s] threads: 64, tps: 1088.30, reads: 15224.31, writes: 4339.80, response time: 102.06ms (95%), errors: 0.00, reconnects:  0.00
[  60s] threads: 64, tps: 1135.50, reads: 15880.44, writes: 4535.51, response time: 101.39ms (95%), errors: 0.00, reconnects:  0.00
OLTP test statistics:
    queries performed:
        read:                            904932
        write:                           258552
        other:                           129276
        total:                           1292760
    transactions:                        64638  (1076.69 per sec.)
    read/write requests:                 1163484 (19380.45 per sec.)
    other operations:                    129276 (2153.38 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)
 
General statistics:
    total time:                          60.0339s
    total number of events:              64638
    total time taken by event execution: 3841.3044s
    response time:
         min:                                 16.69ms
         avg:                                 59.43ms
         max:                               1045.31ms
         approx.  95 percentile:             103.48ms
 
Threads fairness:
    events (avg/stddev):           1009.9688/19.97
    execution time (avg/stddev):   60.0204/0.01
 
[root@DS-VM-Node160 ~]#

 


我们一般关注的用于绘图的指标主要有:
response time avg: 平均响应时间。(后面的95%的大小可以通过--percentile=98的方式去更改)
transactions: 精确的说是这一项后面的TPS 。但如果使用了-oltp-skip-trx=on,这项事务数恒为0,需要用total number of events 去除以总时间,得到tps(其实还可以分为读tps和写tps)
read/write requests: 用它除以总时间,得到吞吐量QPS
当然还有一些系统层面的cpu,io,mem相关指标

时间: 2024-10-31 07:22:39

压测之sysbench安装和MySQL只读测试的相关文章

使用sysbench压测主机和数据库

交付服务器或数据库的时候,我们需要对服务器和数据库的性能有一定的了解.可以使用sysbench对系统做一些压测. sysbench sysbench下载 https://github.com/akopytov/sysbench 可以使用0.5版本,支持lua插件压测数据库 sysbench 数据库压测lua脚本例子 https://github.com/percona/sysbench-scripts Usage: sysbench --test=<test-name> [options]..

innodb compression原理以及性能压测

压缩算法:innodb plugin采用了 zlib library函式库的LZ77 的压缩算法来对数据进行压缩,这种算法已经很成熟,在cpu利用率,压缩比率在50%以上,更为重要的是无数据丢失: innodb的数据存储方式:innodb在数据储存上采用聚簇的方式(B-树)来组织数据,叶子节点上存放了表中定义的所有列数据:第二索引同样也是B-树结构,在索引列的后面会加上聚簇键列,用于索引列到聚簇索引查找数据: 压缩B-树:由于对B-树的频繁的更新,进而导致B-树的页节点的分裂,不断的对数据进行解

Http压测工具wrk使用指南

用过了很多压测工具,却一直没找到中意的那款.最近试了wrk感觉不错,写下这份使用指南给自己备忘用,如果能帮到你,那也很好. 安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持LuaJIT和OpenSSL,不过不用担心,大多数类Unix系统都支持.安装wrk非常简单,只要从github上下载wrk源码,在项目路径下执行make命令即可. git clone https://github.com/wg/wrk make make之后,会在项目路径下生成可执行文件wrk,随后

sysbench压测之MySQL压测的例子

基于OLTP的混合测试 大概是70%的读(select) 30%的写(insert, update, delete) 还是一样的分别对1 4 8 16 32 64线程做测试 [root@DS-VM-Node160 ~]# for i in 1 4 8 16 32 64; do sysbench --test=oltp --test=/usr/local/sysbench/tests/db/oltp.lua --db-driver=mysql --oltp-table-size=10000000

【工具】MySQL 压测工具之mydbtest

一 前言   本文介绍一款绿色免安装版本的数据库压测利器--mydbtest(mydbtest_linux64.bin,由楼方鑫大牛编写).该压测软件区别于sysbench ,tpcc 等常见压测工具软件,免安装,上手快,而且可以针对业务sql做定制化压测.二 如何使用2.1 随机数据生成器    我们在配置文件中指定随机数据的类型,取值范围 比如a int 10 30000 ,随机生成从10-30000的整数,注意 a 必须是where 条件中使用的值,比如where id=:a:,语法 va

MySQL压测工具mysqlslap的介绍与使用_Mysql

一.Mysqlslap介绍 mysqlslap是MySQL5.1之后自带的benchmark基准测试工具,类似Apache Bench负载产生工具,生成schema,装载数据,执行benckmark和查询数据,语法简单,灵活,容易使用.该工具可以模拟多个客户端同时并发的向服务器发出查询更新,给出了性能测试数据而且提供了多种引擎的性能比较.mysqlslap为mysql性能优化前后提供了直观的验证依据,笔者建议系统运维人员应该掌握一些常见的压力测试工具,这样才能较为准确的掌握线上系统能够支撑的用户

sysbench压测小记(r11笔记第99天)

对于很多线上业务而言,如果有新服务器,新的环境,新的业务,到底资源和预期的承载压力是否匹配,这个得用数据说话,或是通过严谨的论证来阐述. 比如一台新的服务器,一般都需要经过压力测试,我们也叫拷机测试.一般都会从多个维度来进行加压(比如CPU,内存,IO等等),看看服务器是否依旧坚挺,虽然这一点上如果产生了懈怠或者懒惰还是会被轻视,但是从身边的例子来看,还是会测试出一些问题来,如果发现了问题,就避免了后续的很多被动. sysbench就是这么一个工具,功能非常全面.是一个标准模块化,多线程的基准测

使用sysbench对mysql压力测试

sysbench是一个模块化的.跨平台.多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况.关于这个项目的详细介绍请看:https://github.com/akopytov/sysbench . 它主要包括以下几种方式的测试: cpu性能 磁盘io性能 调度程序性能 内存分配及传输速度 POSIX线程性能 数据库性能(OLTP基准测试) sysbench的数据库OLTP测试支持MySQL.PostgreSQL.Oracle,目前主要用于Linux操作系统,开源社区已经将sy

sysbench对mysql压力测试的详细教程_Mysql

前言 在对网站整体性能进行benchmark时,可以使用多种工具,比如大名鼎鼎的ab(Apache bench),http_load等工具.这里我们不关注他们的使用,如果你想了解,可以自行在网上找到答案. 重点来说MySQL的基准测试如何进行,也有很多种工具来供我们选择,比如mysqlslap.sysbench.Super Smack等,其中mysqlslap的使用MySQL官网给出了介绍,Super Smack是服务器压力测试强有力的工具,那么sysbench便是我们进行MySQL基准测试的很