热门标签 | 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状态。

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


推荐阅读
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 本文介绍了一款用于自动化部署 Linux 服务的 Bash 脚本。该脚本不仅涵盖了基本的文件复制和目录创建,还处理了系统服务的配置和启动,确保在多种 Linux 发行版上都能顺利运行。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 本文深入探讨了Linux系统中网卡绑定(bonding)的七种工作模式。网卡绑定技术通过将多个物理网卡组合成一个逻辑网卡,实现网络冗余、带宽聚合和负载均衡,在生产环境中广泛应用。文章详细介绍了每种模式的特点、适用场景及配置方法。 ... [详细]
  • 使用Vultr云服务器和Namesilo域名搭建个人网站
    本文详细介绍了如何通过Vultr云服务器和Namesilo域名搭建一个功能齐全的个人网站,包括购买、配置服务器以及绑定域名的具体步骤。文章还提供了详细的命令行操作指南,帮助读者顺利完成建站过程。 ... [详细]
  • 本文介绍如何在 Android 中通过代码模拟用户的点击和滑动操作,包括参数说明、事件生成及处理逻辑。详细解析了视图(View)对象、坐标偏移量以及不同类型的滑动方式。 ... [详细]
  • 本文详细介绍了Java中org.neo4j.helpers.collection.Iterators.single()方法的功能、使用场景及代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • 优化ListView性能
    本文深入探讨了如何通过多种技术手段优化ListView的性能,包括视图复用、ViewHolder模式、分批加载数据、图片优化及内存管理等。这些方法能够显著提升应用的响应速度和用户体验。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 本文基于刘洪波老师的《英文词根词缀精讲》,深入探讨了多个重要词根词缀的起源及其相关词汇,帮助读者更好地理解和记忆英语单词。 ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • 从 .NET 转 Java 的自学之路:IO 流基础篇
    本文详细介绍了 Java 中的 IO 流,包括字节流和字符流的基本概念及其操作方式。探讨了如何处理不同类型的文件数据,并结合编码机制确保字符数据的正确读写。同时,文中还涵盖了装饰设计模式的应用,以及多种常见的 IO 操作实例。 ... [详细]
  • 本文介绍了如何通过 Maven 依赖引入 SQLiteJDBC 和 HikariCP 包,从而在 Java 应用中高效地连接和操作 SQLite 数据库。文章提供了详细的代码示例,并解释了每个步骤的实现细节。 ... [详细]
  • andr ... [详细]
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社区 版权所有