Using pt-heartbeat to monitor the replication latency of MySQL, pt-heartbeatmysql

Source: Internet
Author: User
Tags percona

Using pt-heartbeat to monitor the replication latency of MySQL, pt-heartbeatmysql

Pt-heartbeat

During database master-slave replication, whether the replication status and data delay are normal is a critical indicator. How can we monitor it?

Pt-heartbeat is a centralized tool developed by PERCONA to monitor replication latency of MySQL and PostgreSQL.

Mature, such as Uber and other large companies.

I will not talk about it here. Let's take a look at the detailed introduction:

Monitoring Principles

Create a heartbeat table in the master, with a timestamp field. pt-heartbeat periodically modifies the timestamp value.

Slave copies the heartbeat table, which contains the timestamp when the master executes the modification action and compares it with the local time of the slave. A difference is the value of replication latency, to determine whether the replication status is normal and whether the delay time is as expected.

Pt-heartbeat is calculated based on the actual replication record, so he does not care about how you use replication.

Pt-heartbeat can monitor any depth of replication level. Because the heartbeat table has the server_id field, you can specify the server_id to be referenced when monitoring the latency of a slave, for example, you can specify the server_id of the Target master if you want to know the latency of the slave and its master.

Because pt-heartbeat is strictly dependent on time, you must note that the time between the master and slave must be synchronized.

Example

Execute the create heartbeat table operation on the master node, execute the cyclic update operation, and execute the command:

The master connection information is specified,--create-table -D master1 A heartbeat table is created in the database master1. The following parameters specify the interval at which update is executed.

Then you can monitor the slave and run the following command:

-- The monitor parameter indicates that the monitoring is to be performed, and the previous monitoring target information, including the slave connection information, database and table name.

Example of output information:


0.00 s indicates the current delay information. [0.00 s, 0.00 s, 0.00 s] indicates the average values of 1 m, 5 m, and 15 m.

Installation Process

The Installation Process in CentOS7 is as follows:


Pt-heartbeat official documentation: https://www.percona.com/doc/percona-toolkit/2.1/pt-heartbeat.html

Summary

The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.