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 realize Master-Slave delay Monitoring by Mysql

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces Mysql how to achieve master-slave delay monitoring, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Mysql master-slave delay monitoring pt-heartbeat-uroot-proot-D chenmh-- create-table-- update-- daemonize

-u: the user who connects to the main library

-p: user password to connect to the main library

-D: a database that exists on the main library, which can be specified at will, but must exist

-- create-table: by default, a "heartbeat" table is created in the database specified by the main library

two。 Monitoring slave library

Pt-heartbeat-uroot-proot-D chenmh-table=heartbeat-master-server-id=10-monitor-h 192.168.137.20-interval=1

Except for-- master-server-id is the serverid of the master library, all the other parameters refer to the slave library. Pay special attention to-- master-server-id must not be written wrong, otherwise the result will be wrong. After recording the log, you can monitor and warn this value.

3. Write the monitoring log for early warning analysis

Pt-heartbeat-uroot-proot-D chenmh-- table=heartbeat-- master-server-id=10-- monitor-h 192.168.137.20-- interval=1-- file=/tmp/heart.logcat / tmp/heart.log | awk-F "s"'{print $1}'

4. Stop background update operation

Pt-heartbeat-stop

When you stop the background update process, a pt-heartbeat-sentinel file will be generated in the / tmp directory. You must delete the file before starting the background process next time, otherwise you will not be able to start it.

Rm-rf / tmp/pt-heartbeat-sentinel

Parameters.

Usage: pt-heartbeat [OPTIONS] [DSN]-- update |-- monitor |-- check |-- stop where-- update,-- moniter,--check,--stop are used separately, and-- update,-- monitor, and-- check are mutually exclusive--daemonize and-- check are mutually exclusive. There is still mutual exclusion between them. Options:-- ask-pass prompts when using password for mysql connection-- default character option for charset=s-A-- check execution ends with monitoring from the library-- check-read-only if it is a read-only server, use this option to keep inserts-- config=An is separated by commas. If specified, this parameter is used as the first option on the command line-create-table if the table does not exist create table heartbeat-daemonize create background update shell-- database=s-D specifies the connected database-- dbi-driver=s Specify a driver for the connection Mysql and Pg are supported (default mysql)-- defaults-file=s-F makes a mysql connection through the file provided-- file=s outputs the latest-- monitor monitoring information to the specified file-- frames=s sets the time period (default 1m 5m) 15m)-- help displays help information-- host=s-h specifies the host of the connection-- [no] insert-heartbeat-row inserts a record into the table heartbeat by default when using-- tables if the record row does not exist in the table-- interval=f specifies that the frequency of updating and monitoring the heartbeat table defaults to 1s-- Log=s outputs all the information to the specified file when using daemonized for background update operation-- master-server-id=s specifies the master server-id-- monitor monitors the parameter options of the slave server-- password=s-p specifies the password-- pid=s creates the pid file-- Port=i-P specifies the port to be used when connecting-- print-master-server-id printout master-server-id-- recurse=i Check slaves recursively to this depth in-- check mode-- recursion-method=a Preferred recursion method used to find slaves (default processlist Hosts)-- replace is replaced by replace-- UPDATE operation-- run-time=m specifies the duration of monitoring Units are: s=seconds, m=minutes, h=hours, d=days If the default is to continue monitoring in seconds than the specified one-- sentinel=s Exit if this file exists (default / tmp/pt- heartbeat-sentinel)-- set-vars=A Set the MySQL variables in this comma-separated list of variable=value pairs-- skew=f specifies that the delay for performing slave check is 0.5 by default. -- socket=s-S specifies the socket file to be used for the connection-- stop stops the background update process and generates-- the file specified by sentinel-- table=s specifies the updated table (default is heartbeat)-- update updates the main heartbeat table This parameter is a required parameter for background processes. You can also use-- replace instead of-- user=s-u to specify a user name-- utc ignores system time and only uses UTC-- version to display version information-- [no] version-check Check for the latest version of Percona Toolkit, MySQL. And other programs (default yes) Thank you for reading this article carefully. I hope the article "how to achieve Master-Slave delay Monitoring in Mysql" shared by the editor is helpful to everyone. At the same time, I also hope that you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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