2022-10-27 326
背景
测试mysql5.7和mysql8.0 分别在读写、只读、只写模式下不同并发时的性能(tps,qps)
前提
环境
机器
cat/etc/redhat-release|xargsecho'版本'&&dmidecode-ssystem-product-name|xargsecho'是否虚拟化'&&cat/proc/cpuinfo|grep"processor"|wc-l|xargsecho'cpu核数' 版本CentOSLinuxrelease7.5.1804(Core) 是否虚拟化KVM cpu核数4
myql5.7.22
5.7.22-log innodb_buffer_pool_size128M innodb_log_buffer_size64M innodb_log_file_size48M binlog_formatROW log_binON transaction_isolationREPEATABLE-READ
mysql8.0.15
8.0.15 innodb_buffer_pool_size128M innodb_log_buffer_size64M innodb_log_file_size48M binlog_formatROW log_binON transaction_isolationREPEATABLE-READ
sysbench
sysbench-V sysbench1.1.0(usingbundledLuaJIT2.1.0-beta3)
测试
双1模式下
SHOWGLOBALVARIABLESWHEREVariable_nameIN('sync_binlog','innodb_flush_log_at_trx_commit'); +--------------------------------+-------+ |Variable_name|Value| +--------------------------------+-------+ |innodb_flush_log_at_trx_commit|1| |sync_binlog|1| +--------------------------------+-------+
mysql5.7和mysql8.0 在读写模式下的表现
mysql5.7和mysql8.0 在只读模式下的表现
mysql5.7和mysql8.0 在只写模式下的表现
0 2 模式下
SHOWGLOBALVARIABLESWHEREVariable_nameIN('sync_binlog','innodb_flush_log_at_trx_commit'); +--------------------------------+-------+ |Variable_name|Value| +--------------------------------+-------+ |innodb_flush_log_at_trx_commit|2| |sync_binlog|0| +--------------------------------+-------+
mysql5.7和mysql8.0 在读写模式下的表现
mysql5.7和mysql8.0 在只读模式下的表现
mysql5.7和mysql8.0 在只写模式下的表现
结论
注意
sysbench 需要设置–db-ps-mode=disable 禁用预编译语句,不然并发测试线程多时会报下面的错误
FATAL:mysql_stmt_prepare()failed FATAL:MySQLerror:1461"Can'tcreatemorethanmax_prepared_stmt_countstatements(currentvalue:16382)" FATAL:mysql_stmt_prepare()failed FATAL:MySQLerror:1461"Can'tcreatemorethanmax_prepared_stmt_countstatements(currentvalue:16382)" FATAL:thread_init'functionfailed:/usr/local/share/sysbench/oltp_common.lua:288:SQLAPIerrorFATAL:mysql_stmt_prepare()failedFATAL:MySQLerror:1461"Can'tcreatemorethanmax_prepared_stmt_countstatements(currentvalue:16382)"FATAL:thread_init'functionfailed:/usr/local/share/sysbench/oltp_common.lua:288:SQLAPIerror FATAL:mysql_stmt_prepare()failed
使用脚本
catsysbench_test_mysql5.7_8.0_tps_qps.sh #!/bin/bash #用于sysbench测试在读写模式、只读模式、只写模式下mysql5.7和mysql8.0的tps,qps #nohupbash$0>/tmp/sysbench_test2>&1& # user=admin passwd=admin ports="801557222" host=127.0.0.1 sysbench_test_mode="oltp_read_writeoltp_read_onlyoltp_write_only" sysbench_test_info_path=/tmp/sysbench-test functionred_echo(){ localwhat="$*" echo-e"$(date+%F-%T)\e[1;31m${what}\e[0m" } functioncheck_las_comm(){ if[$1-ne0];then red_echo$2 exit1 fi } functionrestart_mysqld(){ servicemysqld${1}restart sleep2 } functionpurge_binlog(){ port=$1 mysql-u$user-p$passwd-P$port-h$host<<EOF purgebinarylogsbeforenow(); EOF } functionclean_os_cache(){ echo3>/proc/sys/vm/drop_caches } functionsysbench_with_diff_thread(){ thread_num=$1 port=$2 order=$3 test_mode=$4 sysbench/usr/local/share/sysbench/${test_mode}.lua--mysql_storage_engine=innodb--table-size=100000--tables=20--mysql-db=test_1--mysql-user=$user--mysql-password=$passwd--mysql-port=$port--mysql-host=$host--threads=$thread_num--time=60--report-interval=2--db-ps-mode=disable--events=0--db-driver=mysql$order } functionmain(){ fortest_modein$sysbench_test_mode;do forportin$ports;do forthread_numin{5,10,20,30,40,80,120,200};do restart_mysqld"$port" check_las_comm"$?""restartmysqld${port}failed" clean_os_cache purge_binlog"$port" red_echo"sysbench$thread_numthreadscleanupmysqld${port}" sysbench_with_diff_thread"$thread_num""$port""cleanup""$test_mode">/dev/null red_echo"sysbench$thread_numthreadspreparemysqld${port}" sysbench_with_diff_thread"$thread_num""$port""prepare""$test_mode">/dev/null mkdir-p$sysbench_test_info_path red_echo"sysbench$thread_numthreadsrunmysqld${port}$test_mode" sysbench_with_diff_thread"$thread_num""$port""run""$test_mode">$sysbench_test_info_path/${test_mode}_${thread_num}_$port #servicemysqld{port}stop done done done } main
原文链接:https://77isp.com/post/10192.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态