当前位置:Gxlcms > 数据库问题 > mysql-主从复制

mysql-主从复制

时间:2021-07-01 10:21:17 帮助过:4人阅读

mysql> start slave; #启动slave

mysql> stop  slave; #停止

mysql> show slave status \G; #查看slave状态

mysql> reset slave; #重置slave配置

mysql> show master status; #查看bin-log状态

 

配置实现:

master配置(在my.cnf):

server-id=129

log-bin=mysql-bin

binlog-format=mixed

 

slave配置(在my.cnf

server-id=130

relay-log=mysql-relay

在master上创建账号并授权:

mysql> grant replication client,replication slave on *.* to ‘repl‘@‘172.%.%.%‘ identified by ‘repl‘;

mysql> FLUSH PRIVILEGES;

 

在slave上设置:

mysql> change master to

    -> master_host=‘172.16.24.129‘,

    -> master_user=‘tianbao‘,

    -> master_password=‘tianbao‘,

    -> master_log_file=‘mysql-bin.000002‘,

    -> master_log_pos=1099;

mysql> start slave;

 

遇到的问题:

#查看servid和配置文件中是否一致
ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO

#重置slave(reset slave),并且从新配置,然后启动slave
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log

#状态不对。检查授权账号信息,检查日志文件的起始位置master_log_pos是否和master的一致。 show master status 查看bin-log信息
Slave_IO_State: Connecting to master .

 

 

mysql-主从复制

标签:

人气教程排行