mysql relay log 查看_Mysql-relay log

最近发现一测试库中一大堆relay log文件,没有做主从为何有这么多中继日志?查了相关资料,问题解决:原因在于,前面升级时做过3307对3306的复制,然后切换,切换之后,删除了master.info和relay.info后,未重启,所以,每次flush log(慢查询有个脚本会每天去刷新),就产生很多relay log

贴一些手册资料:

14.3.2. The Slave Relay Log

The relay log, like the binary log, consists of a set of numbered files containing events that describe database changes, and an index file that contains the names of all used relay log files.

中继日志同二进制一样的格式和命名方式,由一个索引文件来记录。

The term "relay log file" generally denotes an individual numbered file containing database events. The term "relay log" collectively denotes the set of numbered relay log files plus the index file.

Relay log files have the same format as binary log files and can be read using mysqlbinlog (see Section 4.6.6, "mysqlbinlog — Utility for Processing Binary Log Files").

中继日志也可通过mysqlbinlog 工具读出来

By default, relay log file names have the form host_name-relay-bin.nnnnnn in the data directory, where host_name is the name of the slave server host and nnnnnn is a sequence number. Successive relay log files are created using successive sequence numbers, beginning with 000001 (001 in MySQL 4.0 or older). The slave uses an index file to track the relay log files currently in use. The default relay log index file name is host_name-relay-bin.index in the data directory.

默认情况,中继日志命名为host_name-relay-bin.nnnnn,并存放在数据目录,编号从00001连续计数,索引文件名为:host_name-relay-bin.index

The default relay log file and relay log index file names can be overridden with, respectively, the --relay-log and --relay-log-index server options (see Section 14.8, "Replication and Binary Logging Options and Variables").

中继日志和索引文件名称可通过参数relay-log 和relay-log-index进行更改,如果一个从机采用默认的名称,当修改主机名称时将导致复制错误。为防止同步错误的出现,可以在配置时指定中继日志以及索引文件的名称。

If a slave uses the default host-based relay log file names, changing a slave's host name after replication has been set up can cause replication to fail with the errors Failed to open the relay log and Could not find target log during relay log initialization. This is a known issue (see Bug #2122). If you anticipate that a slave's host name might change in the future (for example, if networking is set up on the slave such that its host name can be modified using DHCP), you can avoid this issue entirely by using the --relay-log and --relay-log-index options to specify relay log file names explicitly when you initially set up the slave. This will make the names independent of server host name changes.

A slave server creates a new relay log file under the following conditions:

Each time the I/O thread starts.

When the logs are flushed; for example, with FLUSH LOGS or mysqladmin flush-logs. (This creates a new relay log only as of MySQL 4.0.14.)

When the size of the current relay log file becomes "too large," determined as follows:

If the value of max_relay_log_size is greater than 0, that is the maximum relay log file size.

If the value of max_relay_log_size is 0, max_binlog_size determines the maximum relay log file size. max_binlog_size always determines the relay log size before MySQL 4.0.14, the first version in which max_relay_log_size appears.

从机在以下情况产生新的日志文件:

1.I/O线程启动时

2.日志刷新时

3.中继日志大小到达max_relay_log_size(默认为0,由binlog最大值来决定,大于0则对中继日志最大文件大小起作用)

The SQL thread automatically deletes each relay log file as soon as it has executed all events in the file and no longer needs it. There is no explicit mechanism for deleting relay logs because the SQL thread takes care of doing so. However, as of MySQL 4.0.14, FLUSH LOGS rotates relay logs, which influences when the SQL thread deletes them.

从机的SQL自动删除已经在库中执行完成的中继日志,flush logs命名将产生新的中继日志。中继日志的刷新无固定的频率

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值