简单易用的 MySQL 官方压测工具_数据库压测工具(2),2024年最新kotlin教学视频

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新HarmonyOS鸿蒙全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img

img
img
htt

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上鸿蒙开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip204888 (备注鸿蒙)
img

正文

  • 调度程序性能测试
  • 内存分配及传输速度测试
  • POSIX 线程性能测试

数据库性能测试(OLTP 基准测试,需要通过 /usr/share/sysbench/ 目录中的 Lua 脚本执行,例如 oltp_read_only.lua 脚本执行只读测试)。

sysbench 还可以通过运行命令时指定自己的 Lua 脚本来自定义测试。

2、查看sysbench工具的帮助选项

[root@mysql ~]# sysbench --helpUsage:sysbench [options]… [testname] [command] Commands implemented by most tests: prepare run cleanup help # 可用的命令,四个 General options: # 通用选项--threads=N 要使用的线程数,默认 1 个 [1]–events=N 最大允许的事件个数 [0]--time=N 最大的总执行时间,以秒为单位 [10]–forced-shutdown=STRING 在 --time 时间限制到达后,强制关闭之前等待的秒数,默认“off”禁用(number of seconds to wait after the --time limit before forcing shutdown, or ‘off’ to disable) [off]--thread-stack-size=SIZE 每个线程的堆栈大小 [64K]–rate=N 平均传输速率。0 则无限制 [0]--report-interval=N 以秒为单位定期报告具有指定间隔的中间统计信息 0 禁用中间报告 [0]–report-checkpoints=[LIST,…] 转储完整的统计信息并在指定的时间点重置所有计数器。参数是一个逗号分隔的值列表,表示从测试开始经过这个时间量时必须执行报告检查点(以秒为单位)。报告检查点默认关闭。[]--debug[=on|off] 打印更多 debug 信息 [off]–validate[=on|off] 尽可能执行验证检查 [off]--help[=on|off] 显示帮助信息并退出 [off]–version[=on|off] 显示版本信息并退出 [off]--config-file=FILENAME 包含命令行选项的文件–tx-rate=N 废弃,改用 --rate [0]--max-requests=N 废弃,改用 --events [0]–max-time=N 废弃,改用 --time [0]--num-threads=N 废弃,改用 --threads [1] Pseudo-Random Numbers Generator options: # 伪随机数发生器选项–rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special]--rand-spec-iter=N number of iterations used for numbers generation [12]–rand-spec-pct=N percentage of values to be treated as ‘special’ (for special distribution) [1]--rand-spec-res=N percentage of 'special' values to use (for special distribution) [75]–rand-seed=N seed for random number generator. When 0, the current time is used as a RNG seed. [0]--rand-pareto-h=N parameter h for pareto distribution [0.2]Log options: # 日志选项--verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3]–percentile=N percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95]--histogram[=on|off] print latency histogram in report [off] General database options: # 通用的数据库选项–db-driver=STRING 指定要使用的数据库驱动程序 (‘help’ to get list of available drivers)--db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] --db-debug[=on|off] print database-specific debug information [off]Compiled-in database drivers: # 內建的数据库驱动程序,默认支持 MySQL 和 PostgreSQLmysql - MySQL driverpgsql - PostgreSQL driver mysql options: # MySQL 数据库专用选项--mysql-host=[LIST,...] MySQL server host [localhost]–mysql-port=[LIST,…] MySQL server port [3306]--mysql-socket=[LIST,...] MySQL socket–mysql-user=STRING MySQL user [sbtest]--mysql-password=STRING MySQL password []–mysql-db=STRING MySQL database name [sbtest]--mysql-ssl[=on|off] use SSL connections, if available in the client library [off]–mysql-ssl-cipher=STRING use specific cipher for SSL connections []--mysql-compression[=on|off] use compression, if available in the client library [off]–mysql-debug[=on|off] trace all client library calls [off]--mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205]–mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off] pgsql options: # PostgreSQL 数据库专用选项--pgsql-host=STRING PostgreSQL server host [localhost]–pgsql-port=N PostgreSQL server port [5432]--pgsql-user=STRING PostgreSQL user [sbtest]–pgsql-password=STRING PostgreSQL password []--pgsql-db=STRING PostgreSQL database name [sbtest] Compiled-in tests: # 內建测试类型fileio - File I/O testcpu - CPU performance testmemory - Memory functions speed testthreads - Threads subsystem performance testmutex - Mutex performance test See ‘sysbench help’ for a list of options for each test.

3、sysbench测试MySQL数据库性能

1)准备测试数据

#查看sysbench自带的lua脚本使用方法[root@mysql ~]# sysbench /usr/share/sysbench/oltp_common.lua help #必须创建sbtest库,sbtest是sysbench默认使用的库名[root@mysql ~]# mysqladmin -uroot -p123 create sbtest; #然后,准备测试所用的表,这些测试表放在测试库sbtest中。这里使用的lua脚本为/usr/share/sysbench/oltp_common.lua。[root@mysql ~]# sysbench --mysql-host=127.0.0.1 \–mysql-port=3306 ``–mysql-user=root ``–mysql-password=123 ``/usr/share/sysbench/oltp_common.lua ``–tables=10 ``–table_size=100000 ``prepare #其中–tables=10表示创建10个测试表,#--table_size=100000表示每个表中插入10W行数据,#prepare表示这是准备数的过程。

2)确认测试数据以存在

[root@mysql ~]# mysql -uroot -p123 sbtest; #登录到sbtest库`` ``mysql> show tables; #查看相应的表``±-----------------+``| Tables_in_sbtest |``±-----------------+``| sbtest1 |``| sbtest10 |``| sbtest2 |``| sbtest3 |``| sbtest4 |``| sbtest5 |``| sbtest6 |``| sbtest7 |``| sbtest8 |``| sbtest9 |``±-----------------+``10 rows in set (0.00 sec)

mysql> select count() from sbtest1; #随机选择一个表,确认其有100000条数据+----------+| count() |+----------+| 100000 |+----------+1 row in set (0.01 sec)

3)数据库测试和结果分析

稍微修改下之前准备数据的语句,就可以拿来测试了。需要注意的是,之前使用的lua脚本为oltp_common.lua,它是一个通用脚本,是被其它lua脚本调用的,它不能直接拿来测试。

所以,我这里用oltp_read_write.lua脚本来做读、写测试。还有很多其它类型的测试,比如只读测试、只写测试、删除测试、大批量插入测试等等。可找到对应的lua脚本进行调用即可。

#执行测试命令如下:[root@mysql ~]# sysbench --threads=4 \–time=20 ``–report-interval=5 ``–mysql-host=127.0.0.1 ``–mysql-port=3306 ``–mysql-user=root ``–mysql-password=123 ``/usr/share/sysbench/oltp_read_write.lua ``–tables=10 ``–table_size=100000 ``run

上述命令返回的结果如下:

[root@mysql ~]# sysbench --threads=4 --time=20 --report-interval=5 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123 /usr/share/sysbench/oltp_read_write.lua --tables=10 --table_size=100000 run sysbench 1.0.17 (using system LuaJIT 2.0.4)Running the test with following options:Number of threads: 4Report intermediate results every 5 second(s)Initializing random number generator from current timeInitializing worker threads...Threads started! #以下是每5秒返回一次的结果,统计的指标包括:# 线程数、tps(每秒事务数)、qps(每秒查询数)、# 每秒的读/写/其它次数、延迟、每秒错误数、每秒重连次数[ 5s ] thds: 4 tps: 1040.21 qps: 20815.65 (r/w/o: 14573.17/4161.25/2081.22) lat (ms,95%): 7.17 err/s: 0.00 reconn/s: 0.00[ 10s ] thds: 4 tps: 1083.34 qps: 21667.15 (r/w/o: 15165.93/4334.55/2166.68) lat (ms,95%): 6.55 err/s: 0.00 reconn/s: 0.00[ 15s ] thds: 4 tps: 1121.57 qps: 22429.09 (r/w/o: 15700.64/4485.30/2243.15) lat (ms,95%): 6.55 err/s: 0.00 reconn/s: 0.00[ 20s ] thds: 4 tps: 1141.69 qps: 22831.98 (r/w/o: 15982.65/4566.16/2283.18) lat (ms,95%): 6.09 err/s: 0.00 reconn/s: 0.00 SQL statistics: queries performed:read: 307146 # 执行的读操作数量write: 87756 # 执行的写操作数量other: 43878 # 执行的其它操作数量 total: 438780transactions: 21939 (1096.57 per sec.) # 执行事务的平均速率queries: 438780 (21931.37 per sec.) # 平均每秒能执行多少次查询ignored errors: 0 (0.00 per sec.)reconnects: 0 (0.00 per sec.) General statistics:total time: 20.0055s # 总消耗时间total number of events: 21939 # 总请求数量(读、写、其它) Latency (ms):min: 1.39avg: 3.64max: 192.0595th percentile: 6.67 # 采样计算的平均延迟sum: 79964.26 Threads fairness:events (avg/stddev): 5484.7500/15.12execution time (avg/stddev): 19.9911/0.00

4、cpu/io/内存等测试

sysbench内置的几个测试指标如下:

[root@mysql ~]# sysbench fileio helpsysbench 1.0.17 (using system LuaJIT 2.0.4) fileio options:–file-num=N number of files to create [128]--file-block-size=N block size to use in all IO operations [16384]–file-total-size=SIZE total size of files to create [2G]--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}–file-io-mode=STRING file operations mode {sync,async,mmap} [sync]--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} []--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]–file-fsync-all[=on|off] do fsync() after each write operation [off]--file-fsync-end[=on|off] do fsync() at the end of test [on]–file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]–file-rw-ratio=N reads/writes ratio for combined test [1.5]

可以直接help输出测试方法,例如,fileio测试:

[root@mysql ~]# sysbench fileio helpsysbench 1.0.17 (using system LuaJIT 2.0.4) fileio options:–file-num=N number of files to create [128]--file-block-size=N block size to use in all IO operations [16384]–file-total-size=SIZE total size of files to create [2G]--file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}–file-io-mode=STRING file operations mode {sync,async,mmap} [sync]--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} []--file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]–file-fsync-all[=on|off] do fsync() after each write operation [off]--file-fsync-end[=on|off] do fsync() at the end of test [on]–file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]--file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]–file-rw-ratio=N reads/writes ratio for combined test [1.5]

1)测试io性能

例如,创建5个文件,总共2G,每个文件大概400M。

[root@mysql ~]# sysbench fileio --file-num=5 --file-total-size=2G prepare[root@mysql ~]# ll -lh test*-rw------- 1 root root 410M May 26 16:05 test_file.0-rw------- 1 root root 410M May 26 16:05 test_file.1-rw------- 1 root root 410M May 26 16:05 test_file.2-rw------- 1 root root 410M May 26 16:05 test_file.3-rw------- 1 root root 410M May 26 16:05 test_file.4

然后运行测试:

[root@mysql ~]# sysbench --events=5000 ``–threads=16 ``fileio ``–file-num=5 ``–file-total-size=2G ``–file-test-mode=rndrw ``–file-fsync-freq=0 ``–file-block-size=16384 ``run

返回的结果如下:

Running the test with following options:Number of threads: 16Initializing random number generator from current timeExtra file open flags: (none)5 files, 409.6MiB each2GiB total file sizeBlock size 16KiBNumber of IO requests: 5000Read/Write ratio for combined random IO test: 1.50Calling fsync() at the end of test, Enabled.Using synchronous I/O modeDoing random r/w testInitializing worker threads… Threads started! File operations:reads/s: 9899.03writes/s: 6621.38fsyncs/s: 264.33Throughput: # 吞吐量read, MiB/s: 154.66 #表示读带宽written, MiB/s: 103.46 #表示写的带宽 General statistics:total time: 0.3014stotal number of events: 5000 Latency (ms):min: 0.00avg: 0.81max: 53.5695th percentile: 4.10sum: 4030.48 Threads fairness:events (avg/stddev): 312.5000/27.64``execution time (avg/stddev): 0.2519/0.02

2)测试cpu性能

[root@mysql ~]# sysbench cpu --threads=40 --events=10000 --cpu-max-prime=20000 run

压测时,还请小心谨慎!!!!

`黑客&网络安全如何学习

今天只要你给我的文章点赞,我私藏的网安学习资料一样免费共享给你们,来看看有哪些东西。

1.学习路线图

攻击和防守要学的东西也不少,具体要学的东西我都写在了上面的路线图,如果你能学完它们,你去就业和接私活完全没有问题。

2.视频教程

网上虽然也有很多的学习资源,但基本上都残缺不全的,这是我自己录的网安视频教程,上面路线图的每一个知识点,我都有配套的视频讲解。

内容涵盖了网络安全法学习、网络安全运营等保测评、渗透测试基础、漏洞详解、计算机基础知识等,都是网络安全入门必知必会的学习内容。

(都打包成一块的了,不能一一展开,总共300多集)

因篇幅有限,仅展示部分资料,需要点击下方链接即可前往获取

CSDN大礼包:《黑客&网络安全入门&进阶学习资源包》免费分享

3.技术文档和电子书

技术文档也是我自己整理的,包括我参加大型网安行动、CTF和挖SRC漏洞的经验和技术要点,电子书也有200多本,由于内容的敏感性,我就不一一展示了。

因篇幅有限,仅展示部分资料,需要点击下方链接即可前往获取

CSDN大礼包:《黑客&网络安全入门&进阶学习资源包》免费分享

4.工具包、面试题和源码

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注鸿蒙)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

入研究,那么很难做到真正的技术提升。**

需要这份系统化的资料的朋友,可以添加V获取:vip204888 (备注鸿蒙)
[外链图片转存中…(img-ZVmmSfvB-1713422361605)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值