使用mytop监控mysql

mytop 是一个不错的实时查看mysql 状态的命令行工具,使用简单

安装

yum install -y mytop

环境准备

docker-compose 创建服务

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

启动mysql

docker-compose up -d

配置mytop

使用配置文件 ~/.mytop

user=gogs
pass=dalongrong
host=127.0.0.1
db=gogs
delay=5
port=3306
header=1
color=1
idle=1

一个简单的压力测试

使用sysbench , 具体的安装以及使用可以参考相关文章

  • 创建测试数据库
create databse test;
  • 准备测试数据
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
  • 运行压力测试
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 效果

 

 

 

 

  • 清理数据
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

posted on   荣锋亮  阅读(554)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2018-11-28 使用netlify-statuskit 进行系统业务状态报告
2018-11-28 heptio scanner kubernetes 集群诊断工具部署说明
2018-11-28 graalvm 简单试用
2018-11-28 使用 Prometheus 监控minio 性能指标信息&&docker-compose 方式运行
2018-11-28 Monitor Minio server with Prometheus
2018-11-28 Stream processing with Apache Flink and Minio

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示