实战:mysql5.6复制延迟监控_MySQL
#repdelay.sh #!/bin/sh #ocpyang@126.com #查看复制延迟具体多少event #set mysql evn MYSQL_USER_MASTER=root MYSQL_PASS_MASTER='password' MYSQL_HOST_MASTER=192.168.2.188 MYSQL_USER_SLAVE=root MYSQL_PASS_SLAVE='password' MYSQL_HOST_SLAVE=192.168.2.14 tmpfile_01="tmp01.`date +%Y%m%d%H%M%S`.txt" tmpfile_02="tmp02.`date +%Y%m%d%H%M%S`.txt" mysql -h${MYSQL_HOST_MASTER} -u${MYSQL_USER_MASTER} -p${MYSQL_PASS_MASTER} -e"SHOW BINARY LOGS;" >${tmpfile_01} mysql -h${MYSQL_HOST_SLAVE} -u${MYSQL_USER_SLAVE} -p${MYSQL_PASS_SLAVE} -e"SHOW SLAVE STATUS\G;" >${tmpfile_02} #tail -1 ${tmpfile_01} | grep -v "Log_name" #cat ${tmpfile_02} | grep -E 'Master_Log_File|Read_Master_Log_Pos|Exec_Master_Log_Pos' | grep -v "Relay_Master_Log_File" |sed 's/^[ ]*//g' a=`tail -1 ${tmpfile_01} | grep -v "Log_name" |awk '{print $1}'|awk -F "." '{print $2}'` b=`sed -n "/\<Master_Log_File\>/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'|awk -F "." '{print $2}'` bhtime=`sed -n "/\<Seconds_Behind_Master\>/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'` if [ "$b" = "$a" ];then c=`tail -1 ${tmpfile_01} | grep -v "Log_name" |awk '{print $2}'` d=`sed -n "/\<Read_Master_Log_Pos\>/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'` e=`expr $c - $d` if [ "${e}" -eq 0 -a "${bhtime}" -eq 0 ]; then echo "*****************************************************************************" echo -e "\e[1;31m &&&&&&&Synchronization has been completed!&&&&&&& \e[0m" echo "*****************************************************************************" elif [ "${e}" -eq 0 -o "${bhtime}" -eq 0 ];then echo "*****************************************************************************" echo -e "\e[1;31m Has been synchronized to the same log file! Wait a moment \e[0m" echo -e "\e[1;31m Not synchronized binlog events is:${e},behind master tims is ${bhtime} \e[0m" echo "*****************************************************************************" fi elif [ ${b} -lt ${a} ];then f=`sed -n "/\<Read_Master_Log_Pos\>/p" ${tmpfile_02} |sed 's/^[ ]*//g' |awk -F ":" '{print $2}'` g=`awk '$1 >= "$b" {print $2}' ${tmpfile_01} |awk 'BEGIN{total=0}{total+=$1}END{print total}'` re=`expr $g - $f` echo -e "\e[1;31m There are multiple log files are not synchronized,the events is:${re} \e[0m" fi rm -rf ${tmpfile_01} rm -rf ${tmpfile_02}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP Practice: Code Example to Quickly Implement the Fibonacci Sequence The Fibonacci Sequence is a very interesting and common sequence in mathematics. It is defined as follows: the first and second numbers are 0 and 1, and from the third Starting with numbers, each number is the sum of the previous two numbers. The first few numbers in the Fibonacci sequence are 0,1,1.2,3,5,8,13,21,...and so on. In PHP, we can generate the Fibonacci sequence through recursion and iteration. Below we will show these two

Java Development Practice: Integrating Qiniu Cloud Storage Service to Implement File Upload Introduction With the development of cloud computing and cloud storage, more and more applications need to upload files to the cloud for storage and management. The advantages of cloud storage services are high reliability, scalability and flexibility. This article will introduce how to use Java language development, integrate Qiniu cloud storage service, and implement file upload function. About Qiniu Cloud Qiniu Cloud is a leading cloud storage service provider in China, providing comprehensive cloud storage and content distribution services. Users can use Qiniu Yunti

MySQL table design practice: Create an e-commerce order table and product review table. In the database of the e-commerce platform, the order table and product review table are two very important tables. This article will introduce how to use MySQL to design and create these two tables, and give code examples. 1. Design and creation of order table The order table is used to store the user's purchase information, including order number, user ID, product ID, purchase quantity, order status and other fields. First, we need to create a table named "order" using CREATET

This article brings you relevant knowledge about uniapp cross-domain, and introduces issues related to subcontracting of uniapp and mini programs. Each mini program that uses subcontracting must contain a main package. The so-called main package is where the default startup page/TabBar page is placed, and some public resources/JS scripts are required for all sub-packages; while sub-packages are divided according to the developer's configuration. I hope it will be helpful to everyone.

The data export function is a very common requirement in actual development, especially in scenarios such as back-end management systems or data report export. This article will take the Golang language as an example to share the implementation skills of the data export function and give specific code examples. 1. Environment preparation Before starting, make sure you have installed the Golang environment and are familiar with the basic syntax and operations of Golang. In addition, in order to implement the data export function, you may need to use a third-party library, such as github.com/360EntSec

In-depth study of Elasticsearch query syntax and practical introduction: Elasticsearch is an open source search engine based on Lucene. It is mainly used for distributed search and analysis. It is widely used in full-text search of large-scale data, log analysis, recommendation systems and other scenarios. When using Elasticsearch for data query, flexible use of query syntax is the key to improving query efficiency. This article will delve into the Elasticsearch query syntax and give it based on actual cases.

Vue Practical Combat: Date Picker Component Development Introduction: The date picker is a component often used in daily development. It can easily select dates and provides various configuration options. This article will introduce how to use the Vue framework to develop a simple date picker component and provide specific code examples. 1. Requirements analysis Before starting development, we need to conduct a requirements analysis to clarify the functions and characteristics of the components. According to the common date picker component functions, we need to implement the following function points: Basic functions: able to select dates, and

Golang dynamic library practice: case sharing and practical skills In Golang (Go language), using dynamic libraries can achieve functions such as modular development, code reuse, and dynamic loading. This article will introduce how to use dynamic libraries in Golang through case sharing and practical tips, and how to use dynamic libraries to improve the flexibility and maintainability of code. What is a dynamic library A dynamic library is a file that contains functions and data that can be loaded at runtime. Unlike static libraries that need to be linked into the application at compile time, dynamic libraries can be
