MySQL主备复制搭建(使用mysqld(3)


150510  1:35:41 [Note] Error reading relay log event: slave SQL thread was killed
150510  1:35:41 [Note] Slave I/O thread killed while reading event
150510  1:35:41 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000006', position 316

--------------------------------------------------------------------------------


    在这期间,主库mysql3307进行了flush logs操作,重新生成了mysql-bin日志,并对表进行添加,删除操作。然后启动从库的复制,进行查看。

--------------------------------------------------------------------------------

150510  1:42:48 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000005' at position 408, relay log '/var/lib/mysql3308/mysql-relay-bin.000012' position: 553
150510  1:42:48 [Note] Slave I/O thread: connected to master 'replication@localhost:3307',replication started in log 'mysql-bin.000005' at position 408


150510  1:43:04 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000006' at position 316, relay log '/var/lib/mysql3309/mysql-relay-bin.000015' position: 461
150510  1:43:04 [Note] Slave I/O thread: connected to master 'replication@localhost:3307',replication started in log 'mysql-bin.000006' at position 316

--------------------------------------------------------------------------------
    说明:从库从停止的时间点重新补回了停止期间的所有数据。


6.进行异常测试:
      停掉从库mysql3308和mysql3309的复制,并对主库进行日志清除操作:

--------------------------------------------------------------------------------
flush logs
delete from sky where;
purge binary logs to 'mysql-bin.000010';

--------------------------------------------------------------------------------
    然后重新启动从库的复制,日志进行报错,数据丢失,主从失败。

--------------------------------------------------------------------------------
150510  1:50:53 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file', Error_code: 1236


--------------------------------------------------------------------------------
解决方法:
    只能停止从数据库,然后重新在从数据库中CHANGE MASTER TO 开始,指向正确的二进制文件及偏移量

--------------------------------------------------------------------------------
change master  to  master_log_file='mysql-bin.000001',master_log_pos=106;

--------------------------------------------------------------------------------
    之后的数据会恢复正常主从同步。

--------------------------------------分割线 --------------------------------------

MySQL5.7.3.0安装配置图解教程

Ubuntu 14.04下安装MySQL

《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主从服务器

Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二进制安装

--------------------------------------分割线 --------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/fe7e56f08aac91c485cc8aeda0f721c1.html