찾다
데이터 베이스MySQL 튜토리얼【MySQL案例】error.log的Warning:If a crash happens thisconf

1.1.1.If a crash happens thisconfiguration does not guarantee that the relay log info will be consistent 【环境描述】 msyql5.6.14 【报错信息】 mysql的slave启动时,error.log中出现Warning警告: [Warning] Slave SQL: If a crash happensthis con

1.1.1. If a crash happens thisconfiguration does not guarantee that the relay log info will be consistent

【环境描述】

msyql5.6.14

【报错信息】

mysql的slave启动时,error.log中出现Warning警告:

[Warning] Slave SQL: If a crash happensthis configuration does not guarantee that the relay log info will beconsistent, Error_code: 0

这条Warning信息对Mysql和MySQL复制功能没有任何影响。

【报错原因】

         MySQL5.6版本开始支持把master.info和relay-log.info的内容写入到mysql库的表中,

                   master.info--> mysql.slave_master_info

                   relay-log.info--> mysql. slave_relay_log_info

         同时在MySQL5.6版本中,增加了 Slave crash-safe replication功能,为了保证mysql的replication能够crash-safe,slave_master_info和slave_relay_log_info表必须使用事务型的存储引擎(InnoDB),不要尝试去手动修改这两张表的内容。同时,Slave还要开启relay_log_recovery功能。

【解决方法】

         设置master_info_repository和relay_log_info_repository的值为TABLE,同时开启relay_log_recovery功能。

         修改/etc/my.cnf配置文件,添加以下3项:

                   master-info-repository=table     # 可以使用set global 动态修改

                   relay-log-info-repository=table   # 可以使用setglobal 动态修改

                   relay-log-recovery=1           # 只读参数,必须修改my.cnf重启mysql

         然后重启mysql实例。

 

【参考资料】

master.info和relay-log.info日志

         在复制的Slave节点上会创建两个日志,分别是master.infor和relay-log.info,位于datadir目录中。在MySQL5.6和后续的版本中,可以通过设置master-info-filerelay-log-info-file参数来指定写入到mysql的表中或者写入文件。

         这两个文件中包含一些类似showslave status输出的信息,当slave启动的时候会读取master.info和relay-log.info文件来确定从master读取binary log和读取relay log的信息。

         Slave的I/O线程负责更新维护master.info文件,

master.info

mysql.slave_master_info

SHOW SLAVE STATUS Column

Description

1

Number_of_lines

[None]

Number of lines in the file

2

Master_log_name

Master_Log_File

The name of the master binary log currently being read from the master

3

Master_log_pos

Read_Master_Log_Pos

The current position within the master binary log that have been read from the master

4

Host

Master_Host

The host name of the master

5

User

Master_User

The user name used to connect to the master

6

User_password

Password (not shown by SHOW SLAVE STATUS)

The password used to connect to the master

7

Port

Master_Port

The network port used to connect to the master

8

Connect_retry

Connect_Retry

The period (in seconds) that the slave will wait before trying to reconnect to the master

9

Enabled_ssl

Master_SSL_Allowed

Indicates whether the server supports SSL connections

10

Ssl_ca

Master_SSL_CA_File

The file used for the Certificate Authority (CA) certificate

11

Ssl_capath

Master_SSL_CA_Path

The path to the Certificate Authority (CA) certificates

12

Ssl_cert

Master_SSL_Cert

The name of the SSL certificate file

13

Ssl_cipher

Master_SSL_Cipher

The list of possible ciphers used in the handshake for the SSL connection

14

Ssl_key

Master_SSL_Key

The name of the SSL key file

15

Ssl_verify_server_cert

Master_SSL_Verify_Server_Cert

Whether to verify the server certificate

16

Heartbeat

[None]

Interval between replication heartbeats, in seconds

17

Bind

Master_Bind

Which of the slave's network interfaces should be used for connecting to the master

18

Ignored_server_ids

Replicate_Ignore_Server_Ids

The number of server IDs to be ignored, followed by the actual server IDs

19

Uuid

Master_UUID

The master's unique ID

20

Retry_count

Master_Retry_Count

Maximum number of reconnection attempts permitted Added in MySQL 5.6.1)

 

         Slave的SQL线程负责维护relay-log.info文件,在MySQL5.6中relay-log.info包含文件中的记录数和复制延迟的秒数。

relaylog.info

slave_relay_log_info

SHOW SLAVE STATUS

Description

1

Number_of_lines

[None]

Number of lines in the file or rows in the table

2

Relay_log_name

Relay_Log_File

The name of the current relay log file

3

Relay_log_pos

Relay_Log_Pos

The current position within the relay log file; events up to this position have been executed on the slave database

4

Master_log_name

Relay_Master_Log_File

The name of the master binary log file from which the events in the relay log file were read

5

Master_log_pos

Exec_Master_Log_Pos

The equivalent position within the master's binary log file of events that have already been executed

6

Sql_delay

SQL_Delay

The number of seconds that the slave must lag the master

 

设置master_info_repository和relay_log_info_repository参数:

SQL> stop slave;

SQL> set global master_info_repository=table;

SQL> set global relay_log_info_repository=table;

SQL> show variables like '%repository';

+--------------------------------------+---------+

| Variable_name           | Value |

+--------------------------------------+---------+

| master_info_repository    | TABLE |

| relay_log_info_repository  | TABLE |

+--------------------------------------+----------+

 

查看向Master读取日志的情况:

SQL> select * from slave_master_info;

查看Slave的Relay日志应用情况:

SQL> select * from slave_relay_log_info;

 

注意:
         master.info和relay-log.info内的数据会有一定的延迟,取决于mysql把slave信息刷到硬盘的时间,如果要获得slave的实时信息,可以查询slave_master_info和slave_relay_log_info表,或者执行show slave status查看。

 

l  master-info-repository

    master-info-repository={ FILE | TABLE },默认值是FILE,这个参数用于设置Slave节点上把master的信息写入到物理文件中还是写入到mysql. slave_master_info表中。

    如果设置为FILE,也是mysql的默认设置,Slave会在datadir/master.info文件中记录master的信息,从MySQL5.6版本开始,建议使用TABLE模式。

 

l  relay-log-info-reposity

         relay-log-info-reposity=file|table,默认值是FILE,这个参数用于设置slave节点上把relay-log.info的信息写入到datadir/relay-log.info文件或者mysql. slave_relay_log_info表。

    如果设置为FILE,也是mysql的默认设置,Slave会在datadir/master.info文件中记录master的信息,从MySQL5.6版本开始,建议使用TABLE模式。

 

l  relay-log-recovery

         relay-log-recover=0|1,默认值是0不开启,该参数用于设置是否开启relay log的自动恢复功能。当开启relay_log_recovery功能,slave数据库在启动的时候,会忽略未被执行的relay log,它会重新连接master获取relay log来进行恢复。

         当slave发生宕机的时候,建议开启该功能,可以有效避免slave执行了relay log里面的讹误记录。

         如果开启relay_log_recovery功能,必须同时把relay_log_info_reposity设置为TABLE模式。

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
图文详解mysql架构原理图文详解mysql架构原理May 17, 2022 pm 05:54 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于架构原理的相关内容,MySQL Server架构自顶向下大致可以分网络连接层、服务层、存储引擎层和系统文件层,下面一起来看一下,希望对大家有帮助。

mysql怎么替换换行符mysql怎么替换换行符Apr 18, 2022 pm 03:14 PM

在mysql中,可以利用char()和REPLACE()函数来替换换行符;REPLACE()函数可以用新字符串替换列中的换行符,而换行符可使用“char(13)”来表示,语法为“replace(字段名,char(13),'新字符串') ”。

mysql的msi与zip版本有什么区别mysql的msi与zip版本有什么区别May 16, 2022 pm 04:33 PM

mysql的msi与zip版本的区别:1、zip包含的安装程序是一种主动安装,而msi包含的是被installer所用的安装文件以提交请求的方式安装;2、zip是一种数据压缩和文档存储的文件格式,msi是微软格式的安装包。

mysql怎么去掉第一个字符mysql怎么去掉第一个字符May 19, 2022 am 10:21 AM

方法:1、利用right函数,语法为“update 表名 set 指定字段 = right(指定字段, length(指定字段)-1)...”;2、利用substring函数,语法为“select substring(指定字段,2)..”。

mysql怎么将varchar转换为int类型mysql怎么将varchar转换为int类型May 12, 2022 pm 04:51 PM

转换方法:1、利用cast函数,语法“select * from 表名 order by cast(字段名 as SIGNED)”;2、利用“select * from 表名 order by CONVERT(字段名,SIGNED)”语句。

MySQL复制技术之异步复制和半同步复制MySQL复制技术之异步复制和半同步复制Apr 25, 2022 pm 07:21 PM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了关于MySQL复制技术的相关问题,包括了异步复制、半同步复制等等内容,下面一起来看一下,希望对大家有帮助。

带你把MySQL索引吃透了带你把MySQL索引吃透了Apr 22, 2022 am 11:48 AM

本篇文章给大家带来了关于mysql的相关知识,其中主要介绍了mysql高级篇的一些问题,包括了索引是什么、索引底层实现等等问题,下面一起来看一下,希望对大家有帮助。

mysql怎么判断是否是数字类型mysql怎么判断是否是数字类型May 16, 2022 am 10:09 AM

在mysql中,可以利用REGEXP运算符判断数据是否是数字类型,语法为“String REGEXP '[^0-9.]'”;该运算符是正则表达式的缩写,若数据字符中含有数字时,返回的结果是true,反之返回的结果是false。

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경

SublimeText3 영어 버전

SublimeText3 영어 버전

권장 사항: Win 버전, 코드 프롬프트 지원!

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구