什么是二进制日志binlog:
记录着mysql数据库中的一些写入性操作,比如一些增删改,但不包括查询!
二进制日志有哪些功能:
数据复制和数据恢复的功能
查看网络状态:
netstat -natp
查看master或slave状态:
show processlist; // 配置主从连接后,根据状态判断是否配置成功
1、binlog(二进制日志):主机配置
relaylog(中继日志):从机
2、每个服务器都有id,也就是Mysql集群每个机器有一个唯一的标识
3、授权信息(用户、密码、ip地址)【微信sdk,将系统在平台申请,获取微信平台秘钥】
3.1、主服务器开通账户,设置权限
create user 'repl'@'172.17.0.%' identified by '123456';
grant replication slave on *.* to 'repl'@'172.17.0.%' identified by '123456';
所有库.所有表
flush privileges;
3.2、从服务器设置访问信息
stop slave; // 关闭同步线程(I/O thread):停止从主服务器继续同步主服务器的binarylog文件
show slave status\G; // 查看从服务器与主服务器通信情况
change master to master_host='主机IP',master_user='repl',master_password='123456',
master_log_file='mysql-bin.000001',master_log_pos=154;
start slave; // 开启同步线程
show slave status\G;
// show master status; 找到binlog文件
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
// 查看binlog文件内容
mysql> show binlog events in 'binlog文件名' from 0;
show slave status\G;</