博客
关于我
mysql8主从复制
阅读量:686 次
发布时间:2019-03-17

本文共 1277 字,大约阅读时间需要 4 分钟。

技术文档:主从复制服务器配置指南

主服务器配置

1. 登陆主服务器

连接到主服务器IP地址信息(192.168.2.84):

[root@youyun-284 mysql]# mysql -uroot -p

2. 创建复制服务用户

使用数据库权限管理命令创建‘repl’用户:

CREATE USER 'repl'@'%' IDENTIFIED BY '*********';flush privileges;

3. 配置my.cnf文件

定zenith定期修改my.cnf文件,确保以下设置:

server-id = 1binlog_format = mixedlog-bin = master-a-binexpire_logs_days = 7max_binlog_size = 100mbinlog_cache_size = 4mmax_binlog_cache_size = 512mbinary_do_db = pay-order#binlog_do_db = pay-channel

4. 授权从服务器账号

在主服务器上授予从服务器复制权限:

GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';flush privileges;

5. 重启MySQL服务

# 使用 systemctl 命令(CentOS/RedHat]systemctl restart mysql# 或者使用 systemctl# systemctl stop mysql && systemctl start mysql

从服务器配置

6. 记录主服务器信息

在从服务器上设置主服务器详细信息:

change master to  master_host='IP地址信息',  master_port=3306,  master_user='repl',  master_password='*********',  master_log_file='master-bin.000001',  master_log_pos=10000;

7. 启动从服务器

mysql> start slave;

8. 查看从服务器状态

验证从服务状态:

show slave status \G;

重点关注以下状态 ```Slave_IO_State: Waiting for master to send eventSlave_IO_Running: YesSlave_SQL_Running: Yes

### 9. 解锁主表```bashmysql> unlock table;

通用注意事项

  • 数据同步锁表:在启动复制前,对目标数据库表进行锁定,确保只读模式直到备用服务器就绪。
  • 错误排查:如同步异常,检查各错误信息(Last_Error,Last_SQL_Error)以确定具体问题。
  • 日志管理:合理设置expire_logs_days和max_binlog_size,防止磁盘使用过多。

如需进一步帮助,可参考具体数据库文档或技术支持。

转载地址:http://hlxhz.baihongyu.com/

你可能感兴趣的文章
pytorch介绍
查看>>
pprint 排序字典但不是集合?
查看>>
pptp拨号上网
查看>>
ppt上的倒计时小工具_PPT中有哪些「看似很 LOW,实则惊艳」的小工具
查看>>
PPT添加视频的路径问题
查看>>
PPT美化插件 islide 安装过程问题“加载com加载项时运行出现错误”
查看>>
Prefix Tuning:详细解读Optimizing Continuous Prompts for Generation
查看>>
PreparedStatement 与Statement 的区别,以及为什么推荐使用 PreparedStatement ?
查看>>
PreparedStatement 查询 In 语句 setArray 等介绍。
查看>>
presentModalViewController显示半透明的一个view
查看>>
PresentViewController切换界面
查看>>
PyTorch之torch.utils.data.DataLoader解读
查看>>
PyTorch之DataLoader杂谈
查看>>
presto、druid、sparkSQL、kylin的对比分析
查看>>
Presto分布式大数据查询引擎
查看>>
Presto架构及原理
查看>>
Presto(一)集群部署
查看>>
Presto(二)开启安全认证
查看>>
Pricing procedure Steps and Details in SAP MM (from SCN)
查看>>
Prim 算法在不同权重范围内的性能分析及其实现
查看>>