Home Database Mysql Tutorial Zabbix监控MySQL主从复制

Zabbix监控MySQL主从复制

Jun 07, 2016 pm 05:22 PM
mysql master-slave replication zabbix

zabbix可能监控到mysql服务的运行情况,但确不能监控mysql的主从复制是否正常:有时候,同步已经停止,但管理人员却不知道。登陆

起因:zabbix可能监控到mysql服务的运行情况,但确不能监控mysql的主从复制是否正常:有时候,同步已经停止,但管理人员却不知道。
 
下手处:登陆mysql从服务器,通过执行 mysql> show slave status\G 查看其输出,即可判定主从复制是否正常。下面是某个从服务器的输出:

 mysql> show slave status\G
 *************************** 1. row ***************************
                Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.93.16
                  Master_User: rep1
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000004
          Read_Master_Log_Pos: 1752541
                Relay_Log_File: hy-mysql3-relay-bin.000088
                Relay_Log_Pos: 2339
        Relay_Master_Log_File: mysql-bin.000004
              Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
 这个输出,最关键处就是"Slave_IO_Running: Yes“和“Slave_SQL_Running: Yes”,这两个值全是"Yes"就表明主从复制正常,否则就是有问题。
 操作步骤:
 1、在主数据库服务器增加一个用户,给予较低的权限,操作为
 mysql > grant Replication client on *.* to    'zabbix'@'%' identified by 'zabbix';   
mysql> flush privileges;
 2、登陆从服务器验证一下,,看是否正常。操作为:
mysql -uzabbix -pzabbix -e "show slave stutas\G"   
3、在从服务器安装 zabbix_agentd,然后在配置文件zabbix_agentd.conf加入一行
 UserParameter=mysql.slave,/opt/scripts/check_mysql_slave |grep OK -c
 4、编写脚本/opt/scripts/check_mysql_slave(这是监控其作用的核心),其内容如下:
 #!/bin/sh
 declare -a    slave_is
 slave_is=($(/usr/local/mysql/bin/mysql -uzabbix -pzabbix    -e "show slave status\G"|grep Running |awk '{print $2}'))
 if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ]
      then
      echo "OK -slave is running"
      exit 0
 else
      echo "Critical -slave is error"
      exit 2
 fi
 
5、修改配置item、trigger,并测试。

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to monitor redis memory in zabbix How to monitor redis memory in zabbix Jun 03, 2023 am 10:00 AM

1. Download the import template directly and import the template through the following steps: Click configuration->templates>import->Import the downloaded xml file. 2. Configure the client key on the monitored host, open the /etc/zabbix/zabbix_agentd.conf configuration file, and add in the last line: UserParameter=redis_stats[*],redis-cli-h127.0.0.1-p$1info |grep$2|cut-d:-f2 After the configuration is completed, pass /etc/init.d/zabbix_agentdre

What are the network devices that Zabbix 3.0 monitors? What are the network devices that Zabbix 3.0 monitors? Jun 04, 2023 am 08:44 AM

Introduction to SNMP 1 Overview of SNMP SNMP has developed to become the most widely used network management protocol. The currently applied versions mainly include SNMPv1, SNMPv2c and SNMPv3. The main differences between the versions are in the definition of information, the operation of communication protocols and the security mechanism. At the same time, two extensions of SNMP applications, remote network monitoring RMON (Remote Network Monitoring) and RMON2, have also appeared. From the perspective of the physical layer, using SNMP to manage the network should include: network management station (NMS), agent (Agent), and proxy server (proxy). NMS can generate commands and receive notification information. There must be at least one in the network management

Data backup and failure recovery: Discussion on the importance of MySQL master-slave replication in cluster mode Data backup and failure recovery: Discussion on the importance of MySQL master-slave replication in cluster mode Sep 08, 2023 am 09:03 AM

Data backup and failure recovery: Discussion on the importance of MySQL master-slave replication in cluster mode Introduction: In recent years, with the continuous growth of data scale and complexity, database backup and failure recovery have become particularly important. In distributed systems, MySQL master-slave replication is widely used in cluster mode to provide high availability and fault tolerance. This article will explore the importance of MySQL master-slave replication in cluster mode and give some code examples. 1. Basic principles and advantages of MySQL master-slave replication MySQL master-slave replication is a general

How zabbix monitors traceroute data How zabbix monitors traceroute data May 19, 2023 am 11:10 AM

1. Zabbixserver and proxy install the mtrmtr script and place it in the following path of zabbixserver and proxy: execute chownzabbix:zabbixmtrtrace.shzabbix to create the mtrtrace template: 5. Associate the host to the template and observe the data in zabbix: [monitoring]-[latestdata]:

Cope with high concurrency with ease: Analysis of the performance advantages of MySQL master-slave replication as a cluster technology Cope with high concurrency with ease: Analysis of the performance advantages of MySQL master-slave replication as a cluster technology Sep 10, 2023 pm 03:48 PM

Cope with high concurrency with ease: Analysis of the performance advantages of MySQL master-slave replication as a cluster technology. With the rapid development of the Internet, user visits to websites and applications have shown an explosive growth trend. In this high-concurrency situation, how to ensure system stability and performance has become an important task for every developer and system administrator. In databases, MySQL master-slave replication technology is widely used and has become one of the effective solutions to deal with high concurrency. This article will explore the performance advantages of MySQL master-slave replication as a cluster technology. first

Optimizing database performance: The best way to use MySQL master-slave replication in cluster technology Optimizing database performance: The best way to use MySQL master-slave replication in cluster technology Sep 10, 2023 am 08:24 AM

Optimizing database performance: The best way to use MySQL master-slave replication in cluster technology Abstract: With the rapid development of the Internet, database performance issues have become the focus of various enterprises and organizations. MySQL master-slave replication technology plays an important role in solving database performance bottlenecks. This article will introduce the concepts and principles of MySQL master-slave replication, as well as the best use methods in cluster technology, to help readers optimize database performance. 1. Introduction As the amount of data continues to increase, database performance problems have become increasingly prominent. How to optimize numbers

Decrypting MySQL master-slave replication: revealing its key implementation mechanism in cluster mode Decrypting MySQL master-slave replication: revealing its key implementation mechanism in cluster mode Sep 10, 2023 am 09:28 AM

Decrypting MySQL master-slave replication: Revealing its key implementation mechanism in cluster mode Introduction: In modern database systems, high availability and flexibility of data are very important. As an open source relational database management system, MySQL has a wide range of applications in meeting user needs. MySQL's master-slave replication is a very critical part of the MySQL database architecture and is used to achieve data backup and high availability. This article will focus on revealing the key implementation mechanism of MySQL master-slave replication, especially in cluster mode.

Using Zabbix for monitoring and management in Java API development Using Zabbix for monitoring and management in Java API development Jun 18, 2023 am 08:25 AM

In JavaAPI development, monitoring management is a very important part. In order to ensure the stability and reliability of the application, we need to monitor various indicators, such as CPU usage, memory usage, network traffic, etc., and respond in a timely manner. In this case, Zabbix is ​​an excellent monitoring tool. Zabbix is ​​an open source monitoring solution that can monitor various parameters and services, including networks, servers, applications, databases, etc. It provides a powerful We

See all articles