热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

【MySQL案例】error.log的Warning:Ifacrashhappensthisconfigurationdoesnotguaranteethattherelaylo

1.1.1. Ifacrashhappensthisconfigurationdoesnotguaranteethattherelayloginfowillbeconsistent

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状态。

版权声明:本文博主原创文章。博客,未经同意不得转载。


推荐阅读
  • 闲话少说,直接切入主题,之前也是用一下其他的IDE,但是总是在vi和IDE之间来回切换,比较麻烦,于是乎,找了几个插件亲身体验,功能挺不错;1、安装vi7.0vim的官方网站是:www.vmuni ... [详细]
  • MySQL重大Bug!自增主键竟然不是连续递增?
    MySQL重大Bug!自增主键竟然不是连续递增? ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 本文介绍了Redis的基础数据结构string的应用场景,并以面试的形式进行问答讲解,帮助读者更好地理解和应用Redis。同时,描述了一位面试者的心理状态和面试官的行为。 ... [详细]
  • Metasploit攻击渗透实践
    本文介绍了Metasploit攻击渗透实践的内容和要求,包括主动攻击、针对浏览器和客户端的攻击,以及成功应用辅助模块的实践过程。其中涉及使用Hydra在不知道密码的情况下攻击metsploit2靶机获取密码,以及攻击浏览器中的tomcat服务的具体步骤。同时还讲解了爆破密码的方法和设置攻击目标主机的相关参数。 ... [详细]
  • python-去除字符串中特定字符一、去掉字符串两端字符:strip(,rstrip(,lstrip(s.strip(#删除两边(头尾空字符,默认是空字符s. ... [详细]
  • 高并发网站架构的核心原则其实就一句话“把所有的用户访问请求都尽量往前推“,即:能缓存在用户电脑本地的,就不要让他去访问CDN。能缓存CDN服务器上的,就不要让CDN去访问源(静态服 ... [详细]
  • 开发笔记:OpenCV基础图形绘制
    本文由编程笔记#小编为大家整理,主要介绍了OpenCV基础---图形绘制相关的知识,希望对你有一定的参考价值。图形绘制OpenCV提供了直线,矩形,圆 ... [详细]
  • 自定义_自定义AXIIP核(转)
    本文由编程笔记#小编为大家整理,主要介绍了自定义AXI-IP核(转)相关的知识,希望对你有一定的参考价值。 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了logistic回归(线性和非线性)相关的知识,包括线性logistic回归的代码和数据集的分布情况。希望对你有一定的参考价值。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • Linux服务器密码过期策略、登录次数限制、私钥登录等配置方法
    本文介绍了在Linux服务器上进行密码过期策略、登录次数限制、私钥登录等配置的方法。通过修改配置文件中的参数,可以设置密码的有效期、最小间隔时间、最小长度,并在密码过期前进行提示。同时还介绍了如何进行公钥登录和修改默认账户用户名的操作。详细步骤和注意事项可参考本文内容。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 本文介绍了在rhel5.5操作系统下搭建网关+LAMP+postfix+dhcp的步骤和配置方法。通过配置dhcp自动分配ip、实现外网访问公司网站、内网收发邮件、内网上网以及SNAT转换等功能。详细介绍了安装dhcp和配置相关文件的步骤,并提供了相关的命令和配置示例。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
author-avatar
丁城雨
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有