mysql5.7 mariadb10.1,percona5.7 性能调优,高可用,监控

mysql安装


mysql管理之道
image.png

添加jemalloc管理内存
[mysqld_safe]
malloc-ib=/usr/lib64/libjemalloc.so

5.7比5.6读写性能高2-3倍

--
安装ssl加密


mysql管理之道
image.png

mysql生成免密登录,maria没这个功能


mysql管理之道
image.png

mysql管理之道
image.png

grant all on . to 'xx'@'%' identified by 'aa';

innodb_undo_ logs 日志分割功能配置

innodb_print_all_deadlocks=1 把死锁信息打印到错误日志里

支持json

杀死执行超过2秒的查询语句


mysql管理之道
image.png

mysql管理之道
image.png

线程池的作用大概就是等于一个交通警察指挥

--开启线程池
thread_handling=pool-of-threads
thread_pool_max_threads=500

还要修改ulimit 文件

开启审计功能

install plugin server_audit soname 'server_audit.so'

半同步模式,主从都得配置

mysql管理之道
image.png

-性能测试
sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=900000 --max-requests=10000 --num-threads=100 --mysql-host=ip --mysql-port= --mysql-user= --mysql-password= --mysql-db=test --mysql-socket=/xxx

innodb=xtradb
数据库:磁盘和内存
mysql的瓶颈:慢查询、buffer_pool、磁盘
innodb_buffer_pool_size 内存70%

sar:
sar -u 1 3 cpu
sar -p 1 3 每个cpu
sar -q 负载
sar -r 内存
sar -W swap
sar -b io
sar -d 磁盘
sar -n DEV
sar -n SOCK
sar -n TCP UDP


mysql管理之道
image.png

查询写操作频繁的表


mysql管理之道
image.png

binlog_format 格式statement row mixed

-------------------误删ibdata数据文件
-------------------update\delete忘记添加where

--用替换.frm表结构文件的方式修改表
myisam 和 innodb的区别


mysql管理之道
image.png

slow_query_log = 1
slow_query_log_file = mysql.slow
long_query_time = 2
1、语句优化 避免子查询
配置文件优化:
read_buffer_size 128k
read_rnd_buffer_size 256k
sort_buffer_size 256k
thread_stack 256k
join_buffer_size 256k
max_connections 512-1000
innodb_buffer_pool_size 物理内存的60-70%
innodb_log_buffer_size 16-64M


主从,一主多从,my-proxy主从,cluster主从
在从机上做备份,
1\冷备份

相关文章:

  • 2021-11-30
  • 2021-11-21
  • 2021-10-04
  • 2021-04-07
猜你喜欢
  • 2021-12-23
  • 2021-05-20
  • 2021-12-10
  • 2021-05-21
  • 2021-06-16
相关资源
相似解决方案