MySQL受限环境打压

1 硬件环境

2 启动脚本

MySQL启动后,要调整一下最大连接数(docker的MySQL默认150)

mysql -h 127.0.0.1 -P 13306 -u root -p

# 默认是151
SHOW VARIABLES LIKE '%max_con%';
+---------------------------------------+-------+
| Variable_name                         | Value |
+---------------------------------------+-------+
| max_connect_errors                    | 100   |
| max_connections                       | 151   |
| mysqlx_max_connections                | 100   |
| performance_schema_max_cond_classes   | 100   |
| performance_schema_max_cond_instances | -1    |
+---------------------------------------+-------+

# 修改为100
SET GLOBAL max_connections = 10000;

3 打压脚本

先安装sysbench

curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash
sudo apt -y install sysbench

执行打压脚本之前,一定要改一下nofile

ulimit -n 65535

4 单写

5 单读

5 读写混合

 

Leave a Reply

Your email address will not be published.