mysql error 1594_【MySQL】解決mysql的 1594 錯誤-阿里云開發者社區

對于主從架構的mysql,當發生主機斷電或者其他原因異常crash的時候, slave的容易發生讀取binlog出錯的問題,最常見的是

show slave status \G;

Master_Log_File: mysql-bin.000029

Read_Master_Log_Pos: 3154083

Relay_Log_File: ?relay-bin.000478

Relay_Log_Pos: 633

Relay_Master_Log_File: mysql-bin.000027

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: 234663436

依據錯誤描述提示,顯然slave sql 進程讀取不到relay log。

解決該問題之前先了解幾個參數:

mysql的主從復制的原理可知,slave 的sql線程理論上來說是延遲于IO線程,show slave status 查詢時 Relay_Master_Log_File和Master_Log_File文件顯示的不是同一個文件。

Master_Log_File

The name of the master binary log file from which the I/O thread is currently reading.

slave的IO線程當前正在讀取的master二進制日志文件名。

Relay_Master_Log_File

The name of the master binary log file containing the most recent event executed by the SQL thread.

slave的Sql線程最近執行的master二進制日志文件名。(該文件有可能是滯后于IO線程正在讀取的二進制日志文件)

Read_Master_Log_Pos

The position in the current master binary log file up to which the I/O thread has read.

Exec_Master_Log_Pos

The position in the current master binary log file to which the SQL thread has read and executed, marking the start of the next transaction or event to be processed. You can use this value with the CHANGE MASTER TO statement's MASTER_LOG_POS option when starting a new slave from an existing slave, so that the new slave reads from this point. The coordinates given by (Relay_Master_Log_File, Exec_Master_Log_Pos) in the master's binary log correspond to the coordinates given by (Relay_Log_File, Relay_Log_Pos) in the relay log.

slave的Sql線程已經讀并且執行的master二進制日志文件的位置,標記下一個被執行的事務或事件的開始位置。

你可以將該值應用于兩臺slave演變為主從結構的應用場景中,新的slave可以在change master to語句中使用該值作為master_log_pos選項的值。master二進制日志文件的(Relay_Master_Log_File, Exec_Master_Log_Pos) 的坐標對應于slave中繼日志(Relay_Log_File,Relay_Log_Pos) 坐標.

#!/bin/bash

#created by yangyi

[ -z "$1" ] && exit 0 || PORT=$1

repair_1594()

{

local portlist=$1

for my_port in $portlist

do

Last_SQL_Errno=$(mysql -uroot -h127.0.0.1 -P${my_port} ?-Ae"show slave status \G" ?2>/dev/null | grep Last_SQL_Errno | awk '{print $2}' )

echo ${Last_SQL_Errno}

Master_Host=`mysql -uroot -h127.0.0.1 -P${PORT} -Ae"show slave status \G" | grep Master_Host |awk '{print $2}'`

Relay_Master_Log_File=`mysql -uroot -h127.0.0.1 -P${PORT} ?-Ae"show slave status \G" | grep Relay_Master_Log_File |awk '{print $2}'`

Exec_Master_Log_Pos=`mysql -uroot -h127.0.0.1 -P${PORT} ?-Ae"show slave status \G" | grep Exec_Master_Log_Pos ?|awk '{print $2}'`

sql="change master to master_host='${Master_Host}',master_port=$PORT, master_user='rep',master_password='yangyi@rac1',master_log_file='${Relay_Master_Log_File}',master_log_pos=${Exec_Master_Log_Pos};"

mysql -uroot -h127.0.0.1 -P$PORT -e " stop slave ; sleep 1; ${sql} ;start slave ;"

sleep 1

is_OK=`mysql -uroot -h127.0.0.1 -P$PORT -p123456 -e "show slave status ?\G"| grep Seconds_Behind_Master | awk '{print $2}'`

if [[ ${is_OK} -ge 0 ]];

then

echo ?"instance : $my_port is recovered !!!!'"

else

echo ?"instance : $my_port is not OK,PLS CHECK WITH MANUL !!!!'"

fi

done

}

repair_1594 $PORT

exit 0

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/530159.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/530159.shtml
英文地址,請注明出處:http://en.pswp.cn/news/530159.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

mysql innodb文件_MySQL的InnoDB文件介紹

MySQL一個顯著的特點是其可插拔的存儲引擎,因此MySQL文件分為兩種,一種是和MySQL數據庫本身相關 的文件,一種是和存儲引擎相關的文件。本文主要介紹和InnoDB存儲引擎相關的文件。表空間文件InnoDB在存儲上也模仿了Oracle的設計,數…

python中與label類似的控件是_python中tkinter的使用(控件整理)(一)

1、使用tkinter.Tk() 生成主窗口(windowtkinter.Tk()):window.title(標題名)修改框體的名字,也可在創建時使用className參數來命名;window.resizable(0,0)框體大小可調性,分別表示x,y方向的可變性;1表示可變,0表示不可…

jdbc dao 工具類mysql_Java基于JDBC實現事務,銀行轉賬及貨物進出庫功能示例

本文實例講述了Java基于JDBC實現事務,銀行轉賬及貨物進出庫功能。分享給大家供大家參考,具體如下:1. 轉賬業務轉賬必須執行2個sql語句(update更新)都成功的情況下,提交事務,如果有一個失敗,則2個都回滾事務…

冒險島單機版mysql_冒險島單機版

這款《冒險島單機版》經驗是盛大冒險島的100倍?最新盛大地圖及BOSS,甚至包括盛大沒有地圖BOSS及現金裝備,地圖包括新加坡,馬來西亞,臺灣,可口可樂城,鬧鬼宅邸,暹羅等等?。25駕坐騎&#xff0c…

python與html5搭建聊天室_html5 websocket 新版協議聊天室 服務端(python版)

網上找了很多代碼都是舊版協議的,研究了很久終于弄清楚了 現在發個用新版協議寫的服務端代碼出來(這個代碼是從網上舊版協議改過來的)最要就是握手協議和發送接受字符的方式變了# incodingutf-8import socketimport structimport hashlibimport threading,randomimp…

mysql數據庫開發筆記_MySQL數據庫生成數據庫說明文檔

在半年多前為一個MySQL數據庫生成過數據庫說明文檔,今天要重新生成一份,但是發現完全不記得當時是怎么生成的,只能在網上搜索重來一遍,所以今天特意把這個過程記錄一下。一、安裝使用MySQL數據庫表結構導出器DBExportDoc V1.0 For…

java 字符串緩沖區_詳解Java中字符串緩沖區StringBuffer類的使用

StringBuffer 是一個線程安全的可變的字符序列。它繼承于AbstractStringBuilder,實現了CharSequence接口。StringBuilder 也是繼承于AbstractStringBuilder的子類;但是,StringBuilder和StringBuffer不同,前者是非線程安全的&#…

rabbitmq java文檔_RabbitMQ文檔翻譯——Hello World!(上)

文章主要翻譯自RabbitMQ官方文檔,主要是為了練習英語翻譯,順便學習一下RabbitMQ😶其中也記錄了一些爬過的坑IntroductionRabbitMQ is a message broker. The principal idea is pretty simple: it accepts and forwards messages. You can th…

java string 包含http_Java中使用HttpPost上傳文件以及HttpGet進行API請求(包含HttpPost上傳文件)...

一、HttpPost上傳文件public static String getSuffix(final MultipartFile file){if(file null || file.getSize() 0){return null;}String fileName file.getOriginalFilename();return fileName.substring(fileName.lastIndexOf(".")1);}public static JSONObj…

java倒計時跳出窗口_java倒計時彈出框

直接使用java語言寫出一個運行時的彈出框倒計時:package test.dagong.testDecreaseDate;import java.awt.Container;import java.awt.FlowLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.sw…

jpa mysql存儲過程_Jpa調用存儲過程及參數

public List findAllEntityListBySearch(Long inputInfoId, int flag) throws Exception {List infoviewListnew ArrayList<>();EntityManager em emf.createEntityManager();try {StoredProcedureQuery storedProcedure em.createStoredProcedureQuery("存儲名稱&…

python從mongodb里取出數據進行可視化_python3 mongoDB數據庫的安裝配置與可視化

python3 mongoDB數據庫的安裝配置與可視化。前天說是要學習如何使用mongoDB的鏈接與安裝。安裝環境&#xff1a; wind10 還是盜版的 磁盤分析&#xff1a;只有一個C盤&#xff0c;步驟&#xff1a;1 . 下載這里下載了對應的msi文件&#xff0c;貌似.zip文件沒有了2 我默認把mon…

idea 注入mapper報錯報紅的幾種解決方案

文章目錄 前言方法1&#xff1a;為 Autowired 注解設置required false方法2&#xff1a;用 Resource 替換 Autowired方法3&#xff1a;在Mapper接口上加上Repository注解方法4&#xff1a;用Lombok方法5&#xff1a;把IDEA的警告關閉掉方法6&#xff1a;不用管他 前言 相信大…

java 調用對象的方法_JAVA調用對象方法的執行過程

JAVA調用對象方法的執行過程&#xff1a;①.編譯器查看對象的聲明類型和方法名。假設調用x.f(parameter), 且隱式參數x聲明為C類型的對象&#xff0c;有可能在C對象中存在多個參數類型和參數個數不同的f的方法{例如&#xff1a;f(int)、f(int,String)和f(String)}&#xff0c;…

java類默認權限_Java 訪問權限控制以及類初始化順序

一. Package在一個項目中&#xff0c;不可以有相同的兩個包名package語句必須是文件中除注釋外第一句程序代碼&#xff0c;否則不能通過編譯。二. Java訪問權限概述類成員&#xff1a;對于一個類&#xff0c;其成員(包括成員變量和成員方法)能否被其他類所訪問&#xff0c;取決…

java http頭 字符串轉日期_springboot~DTO字符字段與日期字段的轉換問題

不會自動轉換string與date主要是這個意思&#xff0c;前端提交的JSON里&#xff0c;日期是一個字符串&#xff0c;而對應后端的實體里&#xff0c;它是一個Date的日期&#xff0c;這兩個在默認情況下是不能自動轉換的&#xff0c;我們先看一下實體實體public class UserDTO {pr…

java super extends_Java繼承和super的用法

該樓層疑似違規已被系統折疊 隱藏此樓查看此樓繼承的關鍵字:extends格式如下: class 子類名 extends父類名{...}例如學生是繼承人類這一父類的.class student extends person{...}如果一個類的聲明沒有使用關鍵字extends,則這個類默認是繼承Object類的.Object是所有類的父類.Ob…

比較abc大小的java_比較abc大小java

比較abc大小java[2021-02-09 04:04:20] 簡介:php去除nbsp的方法&#xff1a;首先創建一個PHP代碼示例文件&#xff1b;然后通過“preg_replace("/(\s|\&nbsp\;| |\xc2\xa0)/", " ", strip_tags($val));”方法去除所有nbsp即可。推薦&#xff1a;《PH…

海天食品的java開發工作如何_再三個月就秋招了,我想找一份java開發工作,現在應該怎么準備一下?...

在找工作之前&#xff0c;大家都要做一些準備工作&#xff0c;java開發也是如此掌握核心JavaSE首先&#xff0c;從核心Java(JavaSE)開始學習&#xff0c;盡可能地掌握它。你應該了解和掌握一些基本概念&#xff0c;如循環&#xff0c;數組&#xff0c;運算符等等。此外&#xf…

java udp簡單聊天程序_Java基于UDP協議實現簡單的聊天室程序

最近比較閑&#xff0c;一直在抽空回顧一些java方面的技術應用。今天沒什么事做&#xff0c;基于udp協議&#xff0c;寫了一個非常簡單的聊天室程序。現在的工作&#xff0c;很少用到socket&#xff0c;也算是對java網絡編程方面的一個簡單回憶。先看一下效果&#xff1a;實現的…