您好,登錄后才能下訂單哦!
mysql數據庫突然不同步數據了
查看slave的狀態
show slave status\G
查看日志
2019-03-11 18:40:03 10283 [ERROR] Slave SQL: Error 'Duplicate entry '39' for key 'PRIMARY'' on query. Default database: 'db_jd'. Query: 'insert into tb_goods values (null,'ty','10.45','27','')', Error_code: 1062
2019-03-11 18:40:03 10283 [Warning] Slave: Duplicate entry '39' for key 'PRIMARY' Error_code: 1062
2019-03-11 18:40:03 10283 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000003' position 10743.
網上說是可能在slave里進行了寫操作
解決辦法是
mysql> stop slave ;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> start slave ;
發現還是不行,對了我的數據庫是雙主模型 slave當然可以寫了
又看到網上說是binlog的格式不對 然后檢查了my.cnf
發現確實少了幾條,紅框里的內容是原來沒有的,后來添加上去的
然后重啟mysql
查看日志
又有報錯
2019-03-11 19:34:36 454 [ERROR] Slave SQL: Slave failed to initialize relay log info structure from the repository, Err or_code: 1872
網上說是由之前的殘留文件,于是刪除了這兩個文件
rm -rf slave-relay-bin.index
rm -rf relay-log.info
再重啟mysql
然后重新配置一下mysql同步進入mysql1
mysql> stop slave;
Query OK, 0 rows affected (0.05 sec)
在mysql2上查看mysql-bin和position
mysql> show master status;
mysql> change master to master_host='192.168.255.57',master_port=3306,master_user='zhangsan',master_password='123456',m aster_log_file='mysql-bin.000006',master_log_pos=120;
Query OK, 0 rows affected, 2 warnings (0.41 sec)
mysql> start slave;
Query OK, 0 rows affected (0.05 sec)
mysql> show slave status\G;
mysql2也重新配置
mysql> stop slave;
Query OK, 0 rows affected (0.05 sec)
在mysql1上查看mysql-bin和position
mysql> show master status;
mysql> change master to master_host='192.168.255.52',master_port=3306,master_user='zhangsan',master_password='123456',m aster_log_file='mysql-bin.000008',master_log_pos=120;
Query OK, 0 rows affected, 2 warnings (0.30 sec)
mysql> start slave;
Query OK, 0 rows affected (0.03 sec)
mysql> show slave status\G;
然后向數據庫里插入數據就可以同步了~~
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。