关于mysql:mysql主备环境搭建

44次阅读

共计 590 个字符,预计需要花费 2 分钟才能阅读完成。

1. 主库 /etc/my.cnf 减少如下配置
binlog-do-db=test
binlog-ignore-db=mysql
log-bin=mysql-bin
server=129
2. 从库 etc/my.cnf 减少如下配置
server-id=130
replicate-do-db=test
replicate-ignore-db=mysql
3. 主节点创立公共用户并受权
mysql -uroot -p123456
create user ‘test’@’%’identified with mysql_native_password by ‘123456’;
grant all privileges on . to ‘root’@’%’ with grant option;
flush privileges;

4. 查看状态,能够看以后主库以后同步日志的信息
show master status;
5. 从节点对 master 的配置,依据上一步的配置
mysql -uroot -p123456
CHANGE MASTER TO

     MASTER_HOST='182.92.172.80',
     MASTER_USER='test',
     MASTER_PASSWORD='123456',
     MASTER_LOG_FILE='mysql-bin.000003',
     MASTER_LOG_POS=73;

6. 开启同步并显示状态
start slave;
show slave status\G

正文完
 0