Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the first event 'mysql-bin.001266' at 1769121, the last event read from './mysql-bin.001266' at 1769200, the last byte read from './mysql-bin.001266' at 1769472.'
到备库执行如下操作
mysql federated 引用其它库的表时,做主从同步时,只能在源库更新这张表,不能在引用的位置更新;因为在引用位置更新时就已经对源库进行了操作,从库去同步时源库已经被修改,再做同样的操作会导致从库崩溃,陷入无限重启失败的情况。
systemctl start mariadb
mysql -u root -e "GRANT ALL PRIVILEGES ON *.* to 'root'@'localhost' IDENTIFIED BY 'Password' WITH GRANT OPTION;" #这种格式可以不登录数据库进行命令操作,设置root用户密码且root只能在localhost环境下登录。
mysql -u root -pPassword -e "GRANT ALL PRIVILEGES ON *.* to 'root'@'%' IDENTIFIED BY 'Password' WITH GRANT OPTION;" #设置root用户在任何环境下都能登录。
mysql -u root -pPassword -e "GRANT REPLICATION SLAVE ON *.* to 'mysync'@'%' identified by 'password';"
mysql>set global rpl_semi_sync_master_enabled=on ; #主库
mysql>set global rpl_semi_sync_slave_enabled=on ; #从库
mysql>stop slave;
mysql>start slave;
vi /etc/my.cnf
[mysqld]
...
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000
...
vi /etc/my.cnf
[mysqld]
...
rpl_semi_sync_slave_enabled=1
mysql> show variables like '%rpl_semi%';
Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
>show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.153
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000016
Read_Master_Log_Pos: 548
Relay_Log_File: in-ser-12-relay-bin.000009
Relay_Log_Pos: 9572368
Relay_Master_Log_File: mysql-bin.000014 #这个binlog文件名记录下来,后面重新连接需要用到
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1594
Last_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
Skip_Counter: 0
Exec_Master_Log_Pos: 101422689 #同步失败的pos值,也需要记录下来,
Relay_Log_Space: 9728728
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1594
Last_SQL_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 093d63ce-026d-11e9-91fa-54bf64719b1f
Master_Info_File: /mydata/mysql/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 190305 09:28:40
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
mysql stop slave;
reset slave all;
change master to master_host='192.168.1.153',master_port=3306,master_user='root',master_password='123456',master_log_file='mysql-bin.000014',master_log_pos=101422689;
start slave;
expire_logs_days = x #x表示过期天数;
show variables like '%expire_logs_days%'; #查看一下默认过期时间,默认一般是为0 ,表示永不过期
set global expire_logs_days=10; #设置过期时间为10天,自动删除超过10天的binlog
flush logs # 触发expire_logs_days配置,会自动重新生成一个新的binlog文件;
purge master logs to 'mysql-bin.000010'
purge master logs to 'mysql-bin.000020'
purge master logs to 'mysql-bin.000030'
purge master logs to 'mysql-bin.000040'
PURGE MASTER logs to 'mysql-bin.000010'
stop slave;
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.001266',MASTER_LOG_POS=1769472; # 根据错误提示更正binlog和log_pos的值
start slave;
show slave status\G