Mysql5.7基于GTID部署数据库主从模式
· 技术积累 · Linux Mysql

centos7系统下 mysql5.7使用gtid复制,搭建主从模式

服务器2台:192.168.16.200 (主) | 192.168.16.201 (从)
mysql版本:mysql-5.7.34-linux-glibc2.12

准备:2台服务器上都安装好mysql

修改(主)mysql配置文件,然后重启下服务

##master

·······
# gitd
server-id=200
gtid-mode=on
enforce-gtid-consistency=on

# binlog
log-bin = mysql-bin
binlog_format=Row
log-slave-updates=1
log_bin_trust_function_creators=1

# 不同步的数据库
binlog-ignore-db=mysql,sys,performance_schema,information_schema
·······

修改(从)mysql配置文件,只有server-id不一样,然后重启下服务

##slave

·······
# gitd
server-id=201
gtid-mode=on
enforce-gtid-consistency=on

# binlog
log-bin = mysql-bin
binlog_format=Row
log-slave-updates=1
log_bin_trust_function_creators=1

# 并行复制
relay_log_recovery=ON
relay_log_info_repository=TABLE
master_info_repository=TABLE
sync_master_info=1
slave_parallel_workers=2
slave_parallel_type=logical_clock

# 不复制的数据库
replicate_wild_ignore_table=mysql.%
replicate_wild_ignore_table=sys.%
replicate_wild_ignore_table=performance_schema.%
replicate_wild_ignore_table=information_schema.%
·······

登录(主)mysql,创建用于同步的用户

##master

mysql> grant replication slave on *.* to 'master'@'%' identified by "1q2w3e4r";

登录(从)mysql,配置用户连接到主mysql

##slave

mysql> stop slave;
mysql> change master to master_host='192.168.16.200' ,master_user='master',master_password='1q2w3e4r',master_auto_position=1;
mysql> start slave;

查看状态信息是否正常

Mysql5.7基于GTID部署数据库主从模式

新建数据查看是否同步正常

Mysql5.7基于GTID部署数据库主从模式


本文最后更新时间 2024-03-30
文章链接地址:
https://me.jinchuang.org/archives/966.html
本站文章除注明[转载|引用],均为本站原创内容,转载前请注明出处
统计文本中每个字符出现的次数
Nali 离线ip数据库文件
苹果CMS v10内容管理系统搭建
SQLSTATE[HY000]: General error: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like'

Mysql5.7基于GTID部署数据库主主模式,并配置nginx负载均衡转发访问

ctop 一个容器监控查看命令

留言列表

  1. 肖申克的救赎
    Windows 10 Google Chrome
    中国上海市电信

    # 并行复制
    relay_log_recovery=ON
    relay_log_info_repository=TABLE
    master_info_repository=TABLE
    sync_master_info=1
    slave_parallel_workers=2
    slave_parallel_type=logical_clock

    请问这些配置在主库里需要写吗

    1. Awking
      Windows 10 Google Chrome
      中国上海市电信

      主库不用,写从库里的

我要留言