热门标签 | HotTags
当前位置:  开发笔记 > 后端 > 正文

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

【MySQL案例】error.log的Warning:Ifacrashhappensthisconfigurationdoesnotguaranteethattherelaylo
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实例。

【参考资料】

l master.info和relay-log.info日志

在复制的Slave节点上会创建两个日志,分别是master.infor和relay-log.info,位于datadir目录中。在MySQL5.6和后续的版本中,可以通过设置master-info-file和relay-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模式。

推荐阅读
  • 在数据分析工作中,我们通常会遇到这样的问题,一个业务部门由若干业务组构成,需要筛选出每个业务组里业绩前N名的业务员。这其实是一个分组排序的 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • Oracle Database 10g许可授予信息及高级功能详解
    本文介绍了Oracle Database 10g许可授予信息及其中的高级功能,包括数据库优化数据包、SQL访问指导、SQL优化指导、SQL优化集和重组对象。同时提供了详细说明,指导用户在Oracle Database 10g中如何使用这些功能。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 本文详细介绍了MysqlDump和mysqldump进行全库备份的相关知识,包括备份命令的使用方法、my.cnf配置文件的设置、binlog日志的位置指定、增量恢复的方式以及适用于innodb引擎和myisam引擎的备份方法。对于需要进行数据库备份的用户来说,本文提供了一些有价值的参考内容。 ... [详细]
  • 本文由编程笔记小编整理,介绍了PHP中的MySQL函数库及其常用函数,包括mysql_connect、mysql_error、mysql_select_db、mysql_query、mysql_affected_row、mysql_close等。希望对读者有一定的参考价值。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • 本文介绍了使用postman进行接口测试的方法,以测试用户管理模块为例。首先需要下载并安装postman,然后创建基本的请求并填写用户名密码进行登录测试。接下来可以进行用户查询和新增的测试。在新增时,可以进行异常测试,包括用户名超长和输入特殊字符的情况。通过测试发现后台没有对参数长度和特殊字符进行检查和过滤。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • Java String与StringBuffer的区别及其应用场景
    本文主要介绍了Java中String和StringBuffer的区别,String是不可变的,而StringBuffer是可变的。StringBuffer在进行字符串处理时不生成新的对象,内存使用上要优于String类。因此,在需要频繁对字符串进行修改的情况下,使用StringBuffer更加适合。同时,文章还介绍了String和StringBuffer的应用场景。 ... [详细]
  • Oracle分析函数first_value()和last_value()的用法及原理
    本文介绍了Oracle分析函数first_value()和last_value()的用法和原理,以及在查询销售记录日期和部门中的应用。通过示例和解释,详细说明了first_value()和last_value()的功能和不同之处。同时,对于last_value()的结果出现不一样的情况进行了解释,并提供了理解last_value()默认统计范围的方法。该文对于使用Oracle分析函数的开发人员和数据库管理员具有参考价值。 ... [详细]
  • MyBatis错题分析解析及注意事项
    本文对MyBatis的错题进行了分析和解析,同时介绍了使用MyBatis时需要注意的一些事项,如resultMap的使用、SqlSession和SqlSessionFactory的获取方式、动态SQL中的else元素和when元素的使用、resource属性和url属性的配置方式、typeAliases的使用方法等。同时还指出了在属性名与查询字段名不一致时需要使用resultMap进行结果映射,而不能使用resultType。 ... [详细]
  • 本文详细介绍了在ASP.NET中获取插入记录的ID的几种方法,包括使用SCOPE_IDENTITY()和IDENT_CURRENT()函数,以及通过ExecuteReader方法执行SQL语句获取ID的步骤。同时,还提供了使用这些方法的示例代码和注意事项。对于需要获取表中最后一个插入操作所产生的ID或马上使用刚插入的新记录ID的开发者来说,本文提供了一些有用的技巧和建议。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
author-avatar
手机用户2502910651
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有