### 配置主数据库 my.cnf
1
2
3
|
server- id =1 log-bin=master-bin log-bin-index=master-bin.index |
### 在主数据库上创建同步账号
1
2
|
create user backup; GRANT REPLICATION SLAVE ON *.* TO 'backup' @ '192.168.%.%' IDENTIFIED BY 'mysql' ; |
### 配置从数据库 my.cnf
1
2
3
|
server- id =2 relay-log-index=slave-relay-bin.index relay- log=slave-relay-bin |
### 重启mysql服务
1
|
service mysqld restart |
### 连接Master服务
1
2
3
|
change master to master_host= '192.168.91.128' , master_port=3306,master_user= 'backup' ,master_password= 'mysql' , master_log_file= 'master-bin.000001' ,master_log_pos=0; |
### 启动slave服务
1
|
start slave; |
### 查看Master服务状态
1
|
SHOW MASTER STATUS; |
### 查看Slave服务状态
1
|
SHOW slave STATUS \G; |
### 检查server_id是否一样,需要不一样
1
|
show variables like 'server_id' ; |
常见错误
错误: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
解决方式: 检查data目录中的auto.cnf中的server-uuid=******************** 是否一样的,要改为不一样
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
原文链接:https://my.oschina.net/Kxvz/blog/715113