MySQL运维

日志

错误日志

MySQL运维_第1张图片

show VARIABLES like '%log_error%';
使用
tail -f  错误文件路径
可以查看具体错误

二进制日志

show variables like '%log_bin%';

MySQL运维_第2张图片
在my.ini文件下的mysqlID下添加

log_bin=mysql-bin
binlog-format=ROW

重启就开启binlog了
MySQL运维_第3张图片

show VARIABLES like '%binlog_format%';

MySQL运维_第4张图片

mysqlbinlog -v logfilename

显示出来的更新日志长这样
MySQL运维_第5张图片
MySQL运维_第6张图片
MySQL运维_第7张图片

查询日志

MySQL运维_第8张图片

show VARIABLES like '%general%';

开启查询日志同理

general_log=1
genera_log_file=/var/lib/mysql/mysql_query.log

重启mysql服务

慢查询日志

MySQL运维_第9张图片

主从复制

概述

MySQL运维_第10张图片

原理

MySQL运维_第11张图片

搭建

MySQL运维_第12张图片

主库配置

MySQL运维_第13张图片


server-id=1
read-only=0

MySQL运维_第14张图片


#创建账户并设置密码
create USER 'han'@'%' IDENTIFIED WITH mysql_native_password BY '0071hanxiaolei';


#为创建的账号分配主从复制的权限
GRANT REPLICATION SLAVE ON *.* TO 'han'@'%';
show master status;

MySQL运维_第15张图片

从库配置

MySQL运维_第16张图片

MySQL运维_第17张图片

CHANGE MASTER TO MASTER_HOST='172.17.0.3', MASTER_PORT=23306,MASTER_USER='han1',MASTER_PASSWORD='0071hanxiaolei',MASTER_LOG_FILE='binlog.000001',MASTER_LOG_POS=372;

MySQL运维_第18张图片
MySQL运维_第19张图片
MySQL运维_第20张图片

分库分表

概述

MySQL运维_第21张图片

拆分策略

MySQL运维_第22张图片

垂直拆分

MySQL运维_第23张图片

水平拆分

MySQL运维_第24张图片

分库分表的实现技术

MySQL运维_第25张图片

Mycat

概述

MySQL运维_第26张图片
MySQL运维_第27张图片
MySQL运维_第28张图片
MySQL运维_第29张图片

简单案例

MySQL运维_第30张图片
MySQL运维_第31张图片
MySQL运维_第32张图片

MySQL运维_第33张图片
MySQL运维_第34张图片
MySQL运维_第35张图片

你可能感兴趣的:(mysql,运维,android)