首页 > 数据库 >15. sysbench和MySQL IO

15. sysbench和MySQL IO

时间:2024-03-25 22:55:06浏览次数:27  
标签:file 15 BACKGROUND thread -- innodb IO MySQL NULL

MySQL的IO使用情况

 

iotop

iotop -u mysql # -u 表示监控哪个user的进程,所以前提是你的mysql服务是用mysql用户启动的

该命令只能看到MySQL的线程ID(Thread ID)

 

performance_schema.threads

root@mysqldb 13:42:  [performance_schema]> select name, type, PROCESSLIST_ID,  THREAD_OS_ID from threads;
+---------------------------------------------+------------+----------------+--------------+
| name                                        | type       | PROCESSLIST_ID | THREAD_OS_ID |
+---------------------------------------------+------------+----------------+--------------+
| thread/sql/main                             | BACKGROUND |           NULL |         2462 |
| thread/innodb/io_ibuf_thread                | BACKGROUND |           NULL |         2475 |
| thread/innodb/io_read_thread                | BACKGROUND |           NULL |         2476 |
| thread/innodb/io_read_thread                | BACKGROUND |           NULL |         2477 |
| thread/innodb/io_write_thread               | BACKGROUND |           NULL |         2478 |
| thread/innodb/io_write_thread               | BACKGROUND |           NULL |         2479 |
| thread/innodb/page_flush_coordinator_thread | BACKGROUND |           NULL |         2480 |
| thread/innodb/log_checkpointer_thread       | BACKGROUND |           NULL |         2481 |
| thread/innodb/log_flush_notifier_thread     | BACKGROUND |           NULL |         2482 |
| thread/innodb/log_flusher_thread            | BACKGROUND |           NULL |         2483 |
| thread/innodb/log_write_notifier_thread     | BACKGROUND |           NULL |         2484 |
| thread/innodb/log_writer_thread             | BACKGROUND |           NULL |         2485 |
| thread/innodb/log_files_governor_thread     | BACKGROUND |           NULL |         2486 |
| thread/innodb/srv_lock_timeout_thread       | BACKGROUND |           NULL |         2491 |
| thread/innodb/srv_error_monitor_thread      | BACKGROUND |           NULL |         2492 |
| thread/innodb/srv_monitor_thread            | BACKGROUND |           NULL |         2493 |
| thread/innodb/buf_resize_thread             | BACKGROUND |           NULL |         2494 |
| thread/innodb/srv_master_thread             | BACKGROUND |           NULL |         2495 |
| thread/innodb/dict_stats_thread             | BACKGROUND |           NULL |         2496 |
| thread/innodb/fts_optimize_thread           | BACKGROUND |           NULL |         2497 |
| thread/mysqlx/worker                        | BACKGROUND |           NULL |         2498 |
| thread/mysqlx/worker                        | BACKGROUND |           NULL |         2499 |
| thread/mysqlx/acceptor_network              | BACKGROUND |           NULL |         2500 |
| thread/semisync/Ack_receiver                | BACKGROUND |           NULL |         2501 |
| thread/innodb/buf_dump_thread               | BACKGROUND |           NULL |         2505 |
| thread/innodb/clone_gtid_thread             | BACKGROUND |           NULL |         2506 |
| thread/innodb/srv_purge_thread              | BACKGROUND |           NULL |         2507 |
| thread/innodb/srv_worker_thread             | BACKGROUND |           NULL |         2508 |
| thread/sql/event_scheduler                  | FOREGROUND |              5 |         2510 |
| thread/sql/signal_handler                   | BACKGROUND |           NULL |         2511 |
| thread/mysqlx/acceptor_network              | BACKGROUND |           NULL |         2512 |
| thread/sql/compress_gtid_table              | FOREGROUND |              7 |         2514 |
| thread/sql/one_connection                   | FOREGROUND |              8 |         3977 |
+---------------------------------------------+------------+----------------+--------------+
33 rows in set (0.00 sec)

root@mysqldb 13:42:  [performance_schema]> show full processlist;
+----+-----------------+-----------+--------------------+---------+------+------------------------+-----------------------+
| Id | User            | Host      | db                 | Command | Time | State                  | Info                  |
+----+-----------------+-----------+--------------------+---------+------+------------------------+-----------------------+
|  5 | event_scheduler | localhost | NULL               | Daemon  |  672 | Waiting on empty queue | NULL                  |
|  8 | root            | localhost | performance_schema | Query   |    0 | init                   | show full processlist |
+----+-----------------+-----------+--------------------+---------+------+------------------------+-----------------------+

通过threads表中的信息,结合iotop -u mysql的输出,就可以知道某个线程的io使用情况

 

sysbench

安装

root@ubuntu:/home/gavin# apt install sysbench
root@ubuntu:/home/gavin# sysbench --version
sysbench 1.0.20

 

压测磁盘

root@ubuntu:/home/gavin# sysbench --test=fileio help 
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

fileio options:
  --file-num=N                  number of files to create [128]    创建文件数
  --file-block-size=N           block size to use in all IO operations [16384]    block size大小
  --file-total-size=SIZE        total size of files to create [2G]    文件数的大小总和
  --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}    测试模式 {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw} (顺序写,顺序读写,顺序读,随机读,随机写,随机读写)
  --file-io-mode=STRING         file operations mode {sync,async,mmap} [sync]    文件操作方式 {sync,async,mmap}
  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
  --file-extra-flags=[LIST,...] list of additional flags to use to open files {sync,dsync,direct} []    打开文件的额外标志 {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]    多少请求后执行fsync。默认是0,不执行
  --file-fsync-all[=on|off]     do fsync() after each write operation [off]    是否每次操作后都执行fsync
  --file-fsync-end[=on|off]     do fsync() at the end of test [on]    测完成后执行fsync,默认是on
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]    同步的方法 {fsync, fdatasync}默认是 [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]    最多多少IO请求被合并,默认为0,不合并
  --file-rw-ratio=N             reads/writes ratio for combined test [1.5]    读写比例默认是 [1.5],即 3:2


sysbench --test=fileio --file-num=4 --file-block-size=8K --file-total-size=1G --file-test-mode=rndrd --file-extra-flags=direct --max-requests=0 --time=3600 --threads=4 prepare
sysbench --test=fileio --file-num=4 --file-block-size=8K --file-total-size=1G --file-test-mode=rndrd --file-extra-flags=direct --max-requests=0 --time=3600 --threads=4 run
sysbench --test=fileio --file-num=4 --file-block-size=8K --file-total-size=1G --file-test-mode=rndrd --file-extra-flags=direct --max-requests=0 --time=3600 --threads=4 cleanup

 如果是真实的测试 runtime 设置成一周的时间,run 期间可以使用 iotop 或者 iostat 进行观察

 

压测数据库

-- Ubuntu
sysbench --table-size=1000000 --tables=10 --db-driver=mysql --mysql-user=root --mysql-password='<password>' --mysql-host=10.21.12.126 --mysql-db=sbtest --mysql-port=6446  --threads=32 --max-requests=0 --time=30 --report-interval=3  oltp_read_write.lua prepare

-- Centos
sysbench --oltp-table-size=1000000 --oltp-tables-count=10 --mysql-user=root --mysql-password='<password>' --mysql-host=10.20.12.158 --mysql-db=sbtest --mysql-port=3306  --threads=32 --max-requests=0 --time=30 --report-interval=3 /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua run

 

fio

fio -filename=/data/mysql/test.io -direct=1 -iodepth 1 -thread -rw=randrw -ioengine=psync -bs=16k -size=2G -numjobs=10 -runtime=10 -group_reporting -name=test

 

标签:file,15,BACKGROUND,thread,--,innodb,IO,MySQL,NULL
From: https://www.cnblogs.com/gavin-zheng/p/18095612

相关文章

  • MySQL索引18连问,谁能顶住
    前言过完这个节,就要进入金银季,准备了18道MySQL索引题,一定用得上。作者:感谢每一个支持:github1.索引是什么索引是一种数据结构,用来帮助提升查询和检索数据速度。可以理解为一本书的目录,帮助定位数据位置。索引是一个文件,它要占用物理空间。2.MySQL索引有哪些......
  • MySQL 数据库的日志管理、备份与恢复
    一.数据库备份1.数据备份的重要性 备份的主要目的是灾难恢复。在生产环境中,数据的安全性至关重要。任何数据的丢失都可能产生严重的后果。造成数据丢失的原因:程序错误人为,操作错误,运算错误,磁盘故障灾难(如火灾、地震)和盗窃.容灾概念:容灾(DisasterRecovery,DR)......
  • UNIQUE VISION Programming Contest 2024 Spring(AtCoder Beginner Contest 346)
    C我们用\(1\simK\)的和减去出现在\(1\simK\)中的数的和。intn,k,a[N],res;map<int,int>vis;signedmain(){ cin>>n>>k; _for(i,1,n)cin>>a[i]; res=k*(1+k)/2; _for(i,1,n)if(a[i]>=1&&a[i]<=......
  • docker-运行mysql服务
    环境说明linux系统版本:lsb_release-a  docker版本:docker-v  不同的操作系统以及软件版本,可能会遇到不一样的问题,一定要注意版本问题。 查看docker中mysql的版本,可以去官网,需要kx上网才能打开。https://hub.docker.com/ 最好是确认自己的服务器已经设置......
  • P1525 [NOIP2010 提高组] 关押罪犯
    带权并查集中,dist[]数组可以理解为一个向量,这样子比按照距离来理解更透彻:优秀学习资料:AcWing240.食物链(带权并查集)-AcWing即d[a]表示向量a->fa[a]这道题的并查集解法:#include<iostream>#include<stdio.h>#include<algorithm>#include<string>#include<cmath>......
  • 论文解读(UDA-GCN)《Unsupervised Domain Adaptive Graph Convolutional Networks》
    Note:[wechat:Y466551|可加勿骚扰,付费咨询]论文信息论文标题:UnsupervisedDomainAdaptiveGraphConvolutionalNetworks论文作者:论文来源:2020aRxiv论文地址:download 论文代码:download视屏讲解:click1-摘要图卷积网络(GCNs)在许多与图相关的分析任务中都取得了令人印......
  • The Mercedes Star Diagnostic Tool: Revolutionizing Garage Technology
    Intheever-evolvingworldofautomotivetechnology,Mercedes-Benzhasconsistentlybeenattheforefrontofinnovation.Asvehiclesbecomeincreasinglycomplex,diagnosingandrepairingthemrequiresadvancedtoolsandexpertise.Onesuchtoolthathasr......
  • Flink 流数据处理 基于Flink1.12.0版本 MapFunction 只适用于一对一的转换,而 FlatMap
    Flink流数据处理基于Flink1.12.0版本MapFunction只适用于一对一的转换,而FlatMapFunction中可以一对多,或者多对一序言基于官网教程整理的一个教程。基于Flink1.12.0版本。目前该版本的Flink支持的source与sink如下所示参考资料:https://ci.apache.org/projects/flink......
  • Flink: Function And Rich Function , 对比 Function ,Rich functions还提供了这些方法:o
    Flink:FunctionAndRichFunction,对比Function,Richfunctions还提供了这些方法:open、close、getRuntimeContext和setRuntimeContext序言    了解了Flink提供的算子,那我们就可以自定义算子了.自定义算子的目的是为了更加灵活的处理我们的业务数据,并将满足条件......
  • Flink API的四层抽象级别是什么?能用实际项目案例讲解一下吗? Flink API的四层抽象级别
    FlinkAPI的四层抽象级别是什么?能用实际项目案例讲解一下吗?首先,FlinkAPI的四层抽象级别是指:最底层抽象:ProcessFunctionAPI、核心API:DataStreamAPI、TableAPI、SQL。这四个抽象级别可以比作烹饪中的不同方式,从简单的速食制作到复杂的大餐烹饪。1.最底层抽象:ProcessFunctionAP......