master1和master2做主高可用
node1和master1组成主从复制,读写分离
node2和master2组成主从复制,读写分离

下面给出配置文件

1. master1: /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
default-authentication-plugin=mysql_native_password
character-set-server=utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidvalidate_password.check_user_name=OFF
validate_password.length=4
validate_password.mixed_case_count=0
validate_password.number_count=0
validate_password.policy=0
validate_password.special_char_count=0
#主从复制-主机21配置
# 主服务器唯一ID
server-id=21
# 启用二进制日志
log-bin=mysql-bin
# 设置不要复制的数据库(可设置多个)
binlog-ignore-db=sys
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
# 设置需要复制的数据库(可设置多个)
binlog-do-db=testdb
binlog-do-db=testdb2
binlog-do-db=testdb3
binlog-do-db=testdb4
# 设置logbin格式
binlog_format=STATEMENT
# 写入操作更新二进制日志文件
log-slave-updates
wait_timeout=31536000
interactive_timeout=31536000

2. node1: /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
default-authentication-plugin=mysql_native_password
character-set-server=utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidvalidate_password.check_user_name=OFF
validate_password.length=4
validate_password.mixed_case_count=0
validate_password.number_count=0
validate_password.policy=0
validate_password.special_char_count=0
# 主从复制-从机26配置
# 从服务器唯一ID
server-id=26
# 启用中继日志
relay-log=mysql-relaywait_timeout=31536000
interactive_timeout=31536000

3. master2: /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8
validate_password.check_user_name=OFF
validate_password.length=4
validate_password.mixed_case_count=0
validate_password.number_count=0
validate_password.policy=0
validate_password.special_char_count=0#主从复制-主机22配置
# 主服务器唯一ID
server-id=22
# 启用二进制日志
log-bin=mysql-bin
# 设置不要复制的数据库(可设置多个)
binlog-ignore-db=sys
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
# 设置需要复制的数据库(可设置多个)
binlog-do-db=testdb
binlog-do-db=testdb2
binlog-do-db=testdb3
binlog-do-db=testdb4
# 设置logbin格式
binlog_format=STATEMENT
# 写入操作更新二进制日志文件
log-slave-updates
wait_timeout=31536000
interactive_timeout=31536000

4. node2: /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
default-authentication-plugin=mysql_native_password
character-set-server=utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pidvalidate_password.check_user_name=OFF
validate_password.length=4
validate_password.mixed_case_count=0
validate_password.number_count=0
validate_password.policy=0
validate_password.special_char_count=0
# 主从复制-从机27配置
# 从服务器唯一ID
server-id=27
# 启用中继日志
relay-log=mysql-relay
wait_timeout=31536000
interactive_timeout=31536000
  1. 总结
    底层走的是binlog进行复制的。
    从库需要给从库账号和密码让其访问。

mysql主从复制、读写分离集群/etc/my.cnf配置文件相关推荐

  1. Maxscale Keepalived MySQL实现高可用读写分离集群

    图片是模拟两个从节点down是否正常提供服务 访问http://ip:8989端口,登录名admin,密码mariadb 环境说明: IP地址 数据库服务 读写分离代理服务 负载均衡服务 虚拟IP 1 ...

  2. Maxscale读写分离集群过渡PXC集群

    一.实验环境 第一次写博客,欢迎大家交流指正!!! 不喜勿喷!!! 操作系统 : Centos7.5虚拟机 数据库软件 : mysql-5.7.17 主机名 ip地址 角色 web33 192.168 ...

  3. MySQL8读写分离集群

    文章目录 前言 MySQL读写分离原理 搭建MySQL读写分离集群 MySQL8.0之前 MySQL8.0之后 后记 前言 上一期介绍并实现了MySQL的主从复制,由于主从复制架构仅仅能解决数据冗余备 ...

  4. 数据库高性能读写分离集群操作说明

    1.系统概述 在一个高并发的事务型系统中,当写事务占的比例相对读事务相对较小时,可以借助DM7的主备系统备机可读的特点,将读事务转移到备机执行,减少单节点的并发压力,通过增加备机节点资源,提高系统的并 ...

  5. mysql proxy 主从_【MYSQL知识必知必会】MySQL主从复制读写分离(基于mysql-proxy实现)...

    MySQL主从复制读写分离(基于mysql-proxy实现) http://mirror.bit.edu.cn/mysql/Downloads/MySQL-Proxy/mysql-proxy-0.8. ...

  6. Windows 2012 always on 读写分离集群搭建配置

    Windows 2012 always on 读写分离集群搭建配置. Always on简介 AlwaysOn 可用性组 (SQL Server) AlwaysOn 可用性组功能是一个提供替代数据库镜 ...

  7. 金仓数据库KingbaseES主备和读写分离集群使用手册(日常运维管理)

    对应10小节作的整改,包括但不限于一键启动的检查项目.对属于一键启动的检查项作个说明即可,比如 本检查属于一键启动默认检查项. 目录 7.1. 集群启停 ¶ 7.1.1. 一键启停方式 ¶ 7.1.2 ...

  8. 达梦-主备与读写分离集群

    DM8-主备与读写分离集群 文章目录 DM8-主备与读写分离集群 1. 基本概念 1.1 DM集群 1.2 DM归档类型 2. 数据守护集群 2.1 概念 2.2 数据守护集群架构及原理 2.3 守护 ...

  9. mysql拉荐_荐 一步一步教你MySQL主从复制读写分离

    本次我们通过docker搭建环境 虚拟机搭建对机器配置有要求,并且安装mysql步骤繁琐 一台机器上可以运行多个Docker容器 Docker容器之间相互独立,有独立ip,互不冲突 Docker使用步 ...

最新文章

  1. Android 自定义 —— View moveTo与 rMoveTo 的区别
  2. 来聊聊双目视觉的基础知识(视觉深度、标定、立体匹配)
  3. RocketMQ的发展历史
  4. r语言 python 书_推荐关于R的几本书
  5. EFCore Lazy Loading + Inheritance = 干净的数据表 (一)
  6. androidpn的一次亲密接触(二)
  7. L1-013. 计算阶乘和-PAT团体程序设计天梯赛GPLT
  8. python AES对称加密文件、解密文件
  9. BEA Tuxedo中间件应用初探
  10. maven添加阿里云仓库
  11. Flutter实战】文本组件及五大案例
  12. 记录一次 JS 解密去混淆的经历 -- 如何破解加密的 JS 代码(一)
  13. 所有失去的都会以另一种方式归来
  14. 金士顿固态硬盘不认盘修复_上海金士顿固态硬盘维修 上海台电固态硬盘不识别数据恢复中心...
  15. 关于安卓如何实现计时器chronometer的暂停和继续计时功能
  16. [汇编语言]标志寄存器
  17. 程序员副业——接私活的网站和其他路径
  18. linux下文件与Windows下文件格式的区别与转换
  19. 遥感学报(湖泊遥感专刊)投稿历程
  20. 创新链接未来,安全赋能发展——区块链技术网络安全应用创新大赛圆满落幕

热门文章

  1. 软件需求工程五组工作日记——开篇:项目简介
  2. 初学编程者必知的五个网站
  3. c#dataview遍历_[C#] DataView用法
  4. java中jdk的下载与安装
  5. 再添新彩!忆享科技成为腾讯蓝鲸智云官方服务商
  6. 用日志构建坚固的数据基础设施/为什么双写不好
  7. Linux双网卡双ip配置
  8. 【控制理论】MPC(一)
  9. 2009年计算机统考考研试题及参考答案
  10. vue能做什么以及特点