【MySQL案例】error.log的Warning:If a crash happens thisconfiguration does not guarantee that the relay lo

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-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模式。

【MySQL案例】error.log的Warning:If a crash happens thisconfiguration does not guarantee that the relay lo,布布扣,bubuko.com

时间: 2024-12-12 16:58:44

【MySQL案例】error.log的Warning:If a crash happens thisconfiguration does not guarantee that the relay lo的相关文章

谁记录了mysql error log中的超长信息

[问题] 最近查看MySQL的error log文件时,发现有很多服务器的文件中有大量的如下日志,内容很长(大小在200K左右),从记录的内容看,并没有明显的异常信息. 有一台测试服务器也有类似的问题,为什么会记录这些信息,是谁记录的这些信息,分析的过程比较周折. Status information: Current dir: Running threads: 2452  Stack size: 262144 Current locks: lock: 0x7f783f5233f0: Key c

【MySQL案例】ERROR 1665 (HY000)

1.1.1. ERROR 1665 (HY000) [环境描述] msyql5.6.14 [报错信息] 执行SQL语句的时候报错: ERROR 1665 (HY000): Cannot executestatement: impossible to write to binary log since BINLOG_FORMAT = STATEMENTand at least one table uses a storage engine limited to row-based logging.

【MySQL案例】ERROR 1418

1.1.1. ERROR 1418 [环境描述] mysql5.0.67 [问题描述] 创建存储过程的时候遇到ERROR 1418报错. # 创建函数的SQL语句 CREATE FUNCTION `xxx`( num01 int ) RETURNSint(11) begin declare mm  int default 0; if  (xx) then set mm = num01*num01*10; elseif  xxx then set mm = 10; else case num01

MYSQL 5.7 无法启动(Could not open error log file errno 2)

前两天电脑中毒, 病毒好像把mysql的 log.err 文件给删掉了.然后服务一直启动不了:Could not open error log file errno 2. 然后疯狂百度,搜索的结果大多都不是我这种情况,只有很少一部分和我的情况一样. 出现和我相同情况的同学: mysql启动错误之 Can't init tc log  Failed to open log (file '', errno 2) ... 发现他们的方法并不能解决我的问题〒_〒,忙活了一上午还是没有找到解决办法. 没有

【MySQL案例】ERROR 1786 (HY000)

1.1.1. ERROR 1786 (HY000) [环境描述] msyql5.6.14 [报错信息] 执行create table ... select的时候遇到报错: db1 [test] [23:01:58]> create tablelgmnr_bak select * from lgmnr; ERROR 1786 (HY000): CREATE TABLE ... SELECTis forbidden when @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1

【mysql案例】mysql5.6.14配置my.cnf多实例,mysql_install_db初始化不读取my.cnf配置文件

1.1.1. mysql5.6.14多实例my.cnf时,初始化不读取my.cnf配置文件 [环境描述] 在多实例配置的/etc/my.cnf环境中,执行mysql_install_db后,启动Mysql报错. [操作步骤] /etc/my.cnf配置文件: [mysqld3307] innodb_data_file_path =ibdata1:1G:autoextend 初始化数据库: [[email protected] home]# mysql_install_db--datadir=/h

Mysql slow query log

一.概念部分:  顾名思义,慢查询日志中记录的是执行时间较长的query,也就是我们常说的slow query,通过设--log-slow-queries[=file_name]来打开该功能并设置记录位置和文件名,默认文件名为hostname-slow.log,默认目录也是数据目录.     慢查询日志采用的是简单的文本格式,可以通过各种文本编辑器查看其中的内容.其中记录了语句执行的时刻,执行所消耗的时间,执行用户,连接主机等相关信息.MySQL还提供了专门用来分析满查询日志的工具程序mysql

MySQL5.7 error log时间显示问题

最近有两三套环境升级到了5.7.16,发现mysql.err中的时间好像有些问题,经查是mysql 5.7后的变更,如下: [email protected] [(none)]>select now();+---------------------+| now() |+---------------------+| 2017-01-01 14:52:05 |+---------------------+1 row in set (0.00 sec) 日志显示时间 [[email protecte

MySQL复制ERROR 1794 (HY000): Slave is not configured or failed to initialize properly.

ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log. error log中有类似日志:2016-05-10 17:21:25 1