LINUX主物理机+从虚拟机下MYSQL8负载均衡之主从复制亲测可用

本文详细讲述了在MySQL8中解决主从复制中服务器ID相同导致的问题,涉及my.cnf配置、server_id修改、UUID管理以及主从数据库的设置,包括grant权限和master设置,为读者提供了从测试、配置到解决常见问题的完整指南。

这里用的大版是MYSQL8,有些个别语法以实战为准

先在局域网中进行测试

主:192.168.1.194

从:192.168.1.164

主数据中打开/etc/my.cnf

[mysqld]
server-id       = 1(这个原来下面有),如果是虚拟机克隆过去的注意这里,改成2也不行,后来才发现下面有

可能的错误是

 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).

 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).

当时用的是set global

mysql> set global server_id=2;

stop/start slave;(有网友反着写的可能是不同版本的吧)

改后是mysql> show variables like '%server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 2     |
+---------------+-------+
1 row in set (0.01 sec)

UUID可能也会一样是虚拟机上克隆过去的,可能我这里194改成物理机后自动变了,记不清了

改的话在[/ww

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值