2015-03-31 17 views
0

MySQL複製對我來說有點新,但它看起來像我一直在努力,直到我不明白的一些錯誤。奇怪的MySQL複製更新錯誤(Magento)

一些背景:我將所有數據庫(通過SSL)從MySQL 5.6.22服務器複製到MariaDB 10.0.15服務器,該服務器除了作爲專用的從服務器之外沒有其他任何功能。它執行一些查詢,但隨後遇到Magento數據庫的更新問題。如果我跳過這個查詢,它會碰到一個類似的查詢導致相同的錯誤。

這是從狀態給我的錯誤:

無法執行Update_rows上表magento_db.log_visitor事件;列'visitor_id'不能爲空,Error_code:1048;在'log_visitor'中找不到記錄,Error_code:1032;列'visitor_id'不能爲空,Error_code:1048;處理程序錯誤HA_ERR_KEY_NOT_FOUND;事件的主日誌的mysql-bin.000121,end_log_pos 7656個

Exec_Master_Log_Pos是7215,但我認爲這是無關緊要的,錯誤的是,在未來的查詢(/事務塊)。

這裏是一塊(詳細)mysqlbinlog可以的:

COMMIT/*!*/; 
 
# at 7215 
 
#150330 2:19:45 server id 1 end_log_pos 7292 CRC32 0xf975481b \t Query \t thread_id=25 \t exec_time=0 \t error_code=0 
 
SET TIMESTAMP=1427674785/*!*/; 
 
BEGIN 
 
/*!*/; 
 
# at 7292 
 
# at 7358 
 
#150330 2:19:45 server id 1 end_log_pos 7358 CRC32 0x0312921e \t Table_map: `magento_db`.`log_url_info` mapped to number 2528 
 
#150330 2:19:45 server id 1 end_log_pos 7497 CRC32 0xe3704a8b \t Write_rows: table id 2528 flags: STMT_END_F 
 
### INSERT INTO `magento_db`.`log_url_info` 
 
### SET 
 
### @1=12534083 /* LONGINT meta=0 nullable=0 is_null=0 */ 
 
### @2='http://www.myshop.com/catalog/category/view/id/29?cat=31&color=22&dir=desc&order=position&price=9-' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */ 
 
### @3=NULL /* VARSTRING(765) meta=765 nullable=1 is_null=1 */ 
 
# at 7497 
 
# at 7565 
 
#150330 2:19:45 server id 1 end_log_pos 7565 CRC32 0x340012cd \t Table_map: `magento_db`.`log_visitor` mapped to number 2513 
 
#150330 2:19:45 server id 1 end_log_pos 7656 CRC32 0xd3d2e26f \t Update_rows: table id 2513 flags: STMT_END_F 
 
### UPDATE `magento_db`.`log_visitor` 
 
### WHERE 
 
### @1=3036630 /* LONGINT meta=0 nullable=0 is_null=0 */ 
 
### SET 
 
### @2='deq65v4ks7tgahp2lvih8s74j1' /* VARSTRING(192) meta=192 nullable=0 is_null=0 */ 
 
### @3=1427667585 /* TIMESTAMP(0) meta=0 nullable=1 is_null=0 */ 
 
### @4=1427667585 /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */ 
 
### @5=12534083 /* LONGINT meta=0 nullable=0 is_null=0 */ 
 
### @6=1 /* SHORTINT meta=0 nullable=0 is_null=0 */ 
 
# at 7656 
 
# at 7714 
 
#150330 2:19:45 server id 1 end_log_pos 7714 CRC32 0xc1eee09b \t Table_map: `magento_db`.`log_url` mapped to number 2529 
 
#150330 2:19:45 server id 1 end_log_pos 7770 CRC32 0xf7bcccad \t Write_rows: table id 2529 flags: STMT_END_F 
 
### INSERT INTO `magento_db`.`log_url` 
 
### SET 
 
### @1=12534083 /* LONGINT meta=0 nullable=0 is_null=0 */ 
 
### @2=3036630 /* LONGINT meta=0 nullable=1 is_null=0 */ 
 
### @3=1427667585 /* TIMESTAMP(0) meta=0 nullable=0 is_null=0 */ 
 
# at 7770 
 
#150330 2:19:45 server id 1 end_log_pos 7801 CRC32 0x51775dd4 \t Xid = 29537 
 
COMMIT/*!*/; 
 
# at 7801 
 
#150330 2:19:53 server id 1 end_log_pos 7886 CRC32 0xd6d724c7 \t Query \t thread_id=26 \t exec_time=0 \t error_code=0 
 
SET TIMESTAMP=1427674793/*!*/;

visitor_id是第一列表示在phpMyAdmin,但是當我執行SHOW COLUMNS FROM log_visitor;也,所以我猜此列映射到'@ 1'(無法找到如何驗證這一點)。但是當我用visitor_id 3036630搜索一條記錄時,它只找到一條記錄。請注意,這不是由於外部查詢,當我再次執行START SLAVE;時,它會掛起相同的錯誤。另外,我嘗試在slave上運行mysql_upgrade,但除了一些警告之外,這沒有任何解決辦法。

底線是:我不知道如何解釋這個錯誤,我可能看錯了查詢嗎?我覺得應該不會有錯誤,也許有些不兼容?

歡迎任何建議!

編輯:按照要求,一個SHOW CREATE TABLE,這似乎在兩臺服務器上相同做一個差異後,除了增量指標:

CREATE TABLE `log_visitor` (
 
`visitor_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Visitor ID', 
 
`session_id` varchar(64) NOT NULL COMMENT 'Session ID', 
 
`first_visit_at` timestamp NULL DEFAULT NULL COMMENT 'First Visit Time', 
 
`last_visit_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Last Visit Time', 
 
`last_url_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'Last URL ID', 
 
`store_id` smallint(5) unsigned NOT NULL COMMENT 'Store ID', 
 
PRIMARY KEY (`visitor_id`) 
 
) ENGINE=InnoDB AUTO_INCREMENT=3036631 DEFAULT CHARSET=utf8 COMMENT='Log Visitors Table'

奴隸被創造刪除所有數據庫(我已經嘗試了多次),在獲得對主服務器的讀鎖定之後,對所有數據庫執行mysqldump,將其導入到從服務器,然後在正確的位置啓動從服務器。它做了一些查詢,當我看,它已經得到了像這裏描述的更新錯誤。

+0

這兩個DB的表格模式是否完全相同?由於列定義的差異,這些錯誤會提示在主服務器上工作的更新不適用於從服務器。 – 2015-03-31 19:49:45

+0

請提供'SHOW CREATE TABLE'。 – 2015-03-31 20:55:52

+0

更新了這個問題,因爲我明顯登出了 – Mike 2015-03-31 22:02:49

回答

1

這似乎是我找到了解決方案。我曾經爲master寫過一個很好的my.cnf,其中包括MySQL 5.6設置「binlog_row_image = MINIMAL」。這會導致binlog跳過UPDATE的SET-clause中的列,這些列已經在WHERE子句中並且保持不變。 MariaDB似乎沒有實現此設置,並且默認的binlog ROW格式需要所有字段的值。