mytop is a nice view real-time status of mysql command-line tool, simple to use
installation
yum install -y mytop
Preparing the Environment
docker-compose create a service
version: "3"
services:
mysql:
image: mysql:5.7.16
ports:
- 3306:3306
volumes:
- "./my.cnf:/etc/mysql/my.cnf"
environment:
MYSQL_ROOT_PASSWORD: dalongrong
MYSQL_DATABASE: gogs
MYSQL_USER: gogs
MYSQL_PASSWORD: dalongrong
TZ: Asia / Shanghai
mysql config
[mysqld]
max_connections=4000
collation_server=utf8mb4_unicode_ci
character-set-server=utf8mb4
Start mysql
docker-compose up -d
Configuration mytop
Using a configuration file ~/.mytop
user=gogs
pass=dalongrong
host=127.0.0.1
db=gogs
delay=5
port=3306
header=1
color=1
idle=1
A simple stress test
Use sysbench, specific installation and use can refer to related articles
- Create a test database
create databse test;
- Preparation of test data
sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=dalongrong --table_size=500000 --tables=10 --threads=30 --time=60 --report-interval=10 --db-driver=mysql prepare
- Run stress tests
sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=dalongrong --table_size=500000 --tables=10 --threads=30 --time=60 --report-interval=10 --db-driver=mysql run
- mytop effect
- Cleanse data
sysbench oltp_read_write.lua --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-db=test --mysql-user=root --mysql-password=dalongrong --table_size=500000 --tables=10 --threads=30 --time=60 --report-interval=10 --db-driver=mysql cleanup
参考资料
https://www.digitalocean.com/community/tutorials/how-to-use-mytop-to-monitor-mysql-performance
https://www.howtoing.com/how-to-use-mytop-to-monitor-mysql-performance
https://github.com/akopytov/sysbench