[mysqld]
server_id = 1
binlog-do-db = test #需要同的数据库
log_bin = mysql-bin # 开启log_bin
mysql> grant replication slave on *.* to 'repl'@'192.168.1.%' identified by 'repl..2017';
mysql> show master status \G;
*************************** 1. row ***************************
File: mysql-bin.000002
Position: 4707
Binlog_Do_DB: test
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
service mysqld restart
[mysqld]
server_id = 2 #服务器id,必须唯一
replicate-do-db = test # 需要同步的数据库
service mysqld restart
mysql > change master to master_host='192.168.1.151',master_port=3306,master_user='repl',master_password='repl',master_log_file='mysql-bin.000002',master_log_pos=3703;
mysql > start slave;
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.151
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 4707
Relay_Log_File: localhost-relay-bin.000004
Relay_Log_Pos: 1503
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: test
Replicate_Ignore_DB:
Replicate_Do_Table:
1 row in set (0.00 sec)
# 状态中,`Slave_IO_Running: Yes` 和 `Slave_SQL_Running: Yes` 同时保证为 yes 即可判断成功。
本文为 Ellison 个人笔记,文章来自于网络或个人总结,转载无需和我联系,但请注明来自 Ellison`s Blog https://www.ruoxiaozh.com
Laravel 框架中前端如何使用 CSRF Laravel 5.6 单设备登录 Laravel 5.6 使用 UUID CURL 类封装 Laravel Eloquent 必备的实用技巧 提高安全性的最佳 Nginx 配置 Vagrant SSH 的登录总结 Laravel 跨域解决方案 CORS 跨域的概念与 TP5 的解决方案 MySQL 千万级大数据 SQL 查询优化技巧详解 数据库 30 条军规 JavaScript 判断访问客户端是 PC 端还是移动端 PHP 的笛卡尔积算法实现 API 文档编写 - APIDOC Linux MySQL 定时备份并上传到 git 仓库 Laravel 5.5 之 Api Resource Laravel 实现文章浏览次数统计 如何在 Laravel 项目中使用 Swagger 构建 Api 文档 如何编写基于 Swagger-PHP 的 API 文档 网站加载动画 Markdown 语法说明 见过世面的人,从不说这3句话 PHP7 新特性 - 完结篇 阿里云 Redis 开发规范 Nginx 负载均衡设置 PHP 生成随机红包算法 规范的 README 需要哪些内容 PHP 代码规范之 PSR-2 Ubuntu 14/16 下的 Laravel LNMP 线上环境自动部署脚本 PHP 闭包 不会,找人教你就够了? PHP 新特性 - 命名空间