配置Mysql主从服务实现实例
### 配置主数据库 my.cnf
server-id=1log-bin=master-binlog-bin-index=master-bin.index |
### 在主数据库上创建同步账号
create user backup;GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.%.%' IDENTIFIED BY 'mysql'; |
### 配置从数据库 my.cnf
server-id=2relay-log-index=slave-relay-bin.indexrelay- log=slave-relay-bin |
### 重启mysql服务
service mysqld restart |
### 连接Master服务
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服务
start slave; |
### 查看Master服务状态
SHOW MASTER STATUS; |
### 查看Slave服务状态
SHOW slave STATUS /G; |
### 检查server_id是否一样,需要不一样
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=******************** 是否一样的,要改为不一样
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
新闻热点
疑难解答