配置Mysql主从服务实现实例
### 配置主数据库 my.cnf
server-id=1 log-bin=master-bin log-bin-index=master-bin.index
### 在主数据库上创建同步账号
create user backup; GRANT REPLICATION SLAVE ON *.* TO 'backup'@'192.168.%.%' IDENTIFIED BY 'mysql';
### 配置从数据库 my.cnf
server-id=2 relay-log-index=slave-relay-bin.index relay- 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=******************** 是否一样的,要改为不一样
相关推荐:
以上就是配置Mysql主从服务实例的详细内容,更多请关注php中文网其它相关文章!
……