Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deal with second behind master inaccuracy in MySQL

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to deal with second behind master inaccuracy in MySQL", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to deal with second behind master inaccuracy in MySQL".

The event header of event (the first 4 bytes of event header) in the binglog log records the timestamp of the event. The time of SQL playback minus the time when the event is generated is the time of Seconds_Behind_Master. But this time is not accurate, sometimes the online delay is thousands of seconds (3600s), but suddenly becomes zero, this is the case.

Pt-heartbeat, download the general binary package

Create a monitoring database:

Mysql > create database monitor;Query OK, 1 row affected (0.02 sec)

Download and install

. / pt-heartbeat-D monitor-- update-uroot-p oracle-P3306-h 10.10.60.60-- create-table-- daemonize

The meaning of the parameter:

-- update means to update timestamped data in real time, which means that unlike the previous seconds_behind_master, seconds_behind_master is not a real-time update.

-- daemonize is put to the background for execution.

For the first time, create-table needs to create a table with a heartbeat name.

Pt-heartbeat creates a timestamped table, and because it is a master-slave, the table is copied to the slave.

And we can see that the timestamp and position change with each query.

The time difference between the ts column of the heartbeat table on the slave database and the ts column of the heartbeat table of the master library is the delay time of master-slave replication.

The monitor monitoring tool is also provided in the tool.

Monitoring:

. / pt-heartbeat-D monitor-- monitor-- master-server-id 603306-uroot-p oracle-P3306-h 10.10.60.60

Look at the first column exactly, and the last few columns are the delay time in 1min, 5min, and 15min, respectively.

The above is all the contents of the article "how to deal with inaccurate second behind master in MySQL". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report