Mysql集群安装部署,Slave-Mater-Master-Slave模式
来源:互联网 发布:金融数据上报客户端 编辑:程序博客网 时间:2024/06/05 12:59
1、同步模式
一共4台主机,分别Slave-Mater-Master-Slave模式。双Master保障可靠性,多Slave进行同步,读写分离。
Mysql版本5.7.16,主机操作系统版本Centos 6.8。
主机A 10.3.1.101 Slave
主机B 10.3.1.102 Master
主机C 10.3.1.103 Master
主机D 10.3.1.104 Slave
同步模式 双Master B和C双向同步,B<->C。Master-Slave单向同步,B->A, C->D。
2、配置文件 /etc/my.cnf
-------------------------------------------------------
主机A 10.3.1.101
[mysqld]
server-id=101
relay_log=/usr/local/mysql/log/mysql-relay-bin
log_slave_updates=1
read_only=1
-------------------------------------------------------
主机B 10.3.1.102
[mysqld]
server-id=102
log-bin=/usr/local/mysql/log/mysql-bin
max_binlog_size=1024M
expire-logs-days=15
binlog_cache_size=4M
max_binlog_cache_size=512M
relay_log=/usr/local/mysql/log/mysql-relay-bin
log_slave_updates=1
read_only=0
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1
-------------------------------------------------------
主机C 10.3.1.103
[mysqld]
server-id=103
log-bin=/usr/local/mysql/log/mysql-bin
max_binlog_size=1024M
expire-logs-days=15
binlog_cache_size=4M
max_binlog_cache_size=512M
relay_log=/usr/local/mysql/log/mysql-relay-bin
log_slave_updates=1
read_only=1
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2
-------------------------------------------------------
[mysqld]
server-id=104
relay_log=/usr/local/mysql/log/mysql-relay-bin
log_slave_updates=1
read_only=0
3、在各个Mysql上创建同步用户
FLUSH PRIVILEGES;
CREATE USER repl IDENTIFIED BY 'repl123';
CREATE USER repl@localhost IDENTIFIED BY 'repl123';
CREATE USER repl@'HOSTNAME' IDENTIFIED BY 'repl123';
grant all privileges on *.* to repl with grant option;
grant all privileges on *.* to repl@localhost with grant option;
grant all privileges on *.* to repl@'HOSTNAME' with grant option;
FLUSH PRIVILEGES;
4、设置Master
分别在各个主机上设置对应的Master,在SQL命令窗口执行。
在101上执行:
change master to MASTER_HOST='10.3.1.102',
MASTER_USER='repl',
MASTER_PASSWORD='repl123',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;
在102上执行:
change master to MASTER_HOST='10.3.1.103',
MASTER_USER='repl',
MASTER_PASSWORD='repl123',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;
在103上执行:
change master to MASTER_HOST='10.3.1.102',
MASTER_USER='repl',
MASTER_PASSWORD='repl123',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;
在104上执行:
change master to MASTER_HOST='10.3.1.103',
MASTER_USER='repl',
MASTER_PASSWORD='repl123',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;
5、查看Salve同步信息
show slave status \G;
6、如果有错误信息,查看具体错误,可跳过错误,再同步
stop slave;
set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
start slave;
show slave status \G;
- Mysql集群安装部署,Slave-Mater-Master-Slave模式
- mysql master-slave模式部署
- MySQL数据库集群Master-Slave模式安装摘要
- mysql模式:master/slave
- mysql master/slave 模式
- mysql的master-slave模式
- mysql模式:master/slave(二)
- Mysql配置master-slave模式
- mysql配置master/slave模式
- mysql master slave 主从安装
- MySQL的Master/Slave集群安装和配置
- MySQL的Master/Slave集群安装和配置
- MySQL Master Slave 数据同步,集群。
- RocketMQ多Master多Slave模式部署
- OpenLDAP Master/Slave部署
- window下mysql配置MASTER/SLAVE模式
- redis master-slave模式
- master-slave模式
- 数据库备份与恢复
- spark streaming 2.02 Receiver 运行executor的调度算法
- C语言基础(十二)- 数据结构概览
- Intellij Idea 2016 提示Java home is different.无法正常编译Android项目的解决办法
- 【PHP】php的伪静态的实现
- Mysql集群安装部署,Slave-Mater-Master-Slave模式
- CvCreateImage函数说明
- plist文件的增删改查
- java虚拟机的生命周期
- C指针编程之道(一)- 指针与数组
- CCF权限查询
- php表单加入Token防止重复提交
- android亮屏、暗屏、解锁、关闭系统对话的监听事件
- C指针编程之道(二)- 指针与函数