Install configuration Zabbix to monitor Mysql's basic tutorials _mysql

Source: Internet
Author: User
Tags snmp create database import database

Simple installation configuration instructions for Zabbix
1. Install Zabbix on the basis of existing lamp or LNMP, install some dependent packages:

Yum-y Install Mysql-devel libcurl-devel net-snmp-devel

2, add Users:

Groupadd Zabbix
useradd zabbix-g Zabbix

3, create a database, add authorized Account

Create database Zabbix character set UTF8;
Grant all privileges on zabbix.* to zabbix@localhost identified by ' Zabbix ';

4. Compile and install Zabbix
Download Address:

wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.0/zabbix-2.2.0.tar.gz
Tar ZXF zabbix-2.2.0.tar.gz
cd zabbix-2.2.0
./configure--prefix=/usr/local/zabbix--enable-server-- enable-agent \
--with-mysql--with-net-snmp--with-libcurl make
Install

5. Import Database

Mysql-uzabbix-pzabbix-hlocalhost Zabbix < database/mysql/schema.sql
Mysql-uzabbix-pzabbix-hlocalhost Zabbix < Database/mysql/images.sql
Mysql-uzabbix-pzabbix-hlocalhost Zabbix < Database/mysql/data.sql

6, modify the configuration file

CP misc/init.d/fedora/core/zabbix_server/etc/init.d/
CP misc/init.d/fedora/core/zabbix_agentd/etc/init.d/
cp-r Frontends/php/var/www/html/zabbix
sed-i ' s/^dbuser=.*$/dbuser=zabbix/g '/usr/local/zabbix/etc/ zabbix_server.conf
sed-i ' s/^.*dbpassword=.*$/dbpassword=zabbix/g '/usr/local/zabbix/etc/zabbix_server.conf
sed-i ' s/basedir=\/usr\/local/basedir=\/usr\/local\/zabbix/g '/etc/init.d/zabbix_server
sed-i ' s/ Basedir=\/usr\/local/basedir=\/usr\/local\/zabbix/g '/etc/init.d/zabbix_agentd

7, add service port:

Cat >>/etc/services <<eof
zabbix-agent 10050/tcp Zabbix agent zabbix-agent 10050/udp Zabbix agent<
C3/>zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
EOF

8, start the service

/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
echo "/etc/init.d/zabbix_server start" > >/etc/rc.local
echo "/etc/init.d/zabbix_agentd start" >>/etc/rc.local

9, Web page configuration, configure HTTP access after the Web landing: Http://ip/zabbix

Zabbix Monitor MySQL Performance
by getting the MySQL status values to pass these status values to the server and painting the picture, you can look at MySQL's work and usually need to get a status variable with the following

    • Number of updates performed by Com_update:mysql
    • Number of queries executed by Com_select:mysql
    • Com_insert:mysql the number of inserts performed
    • Com_delete: Number of deletions performed
    • Com_rollback: Number of actions performed for rollback
    • bytes_received: Number of bytes accepted
    • Bytes_sent: Number of bytes Sent
    • Slow_queries: Number of slow query statements

1, create MySQL performance monitoring script

#!/bin/bash #Create by Zhengdazhi 2014.09.22 mysql_dir=/usr/local/mysql Mysql=${mysql_dir}/bin/mysql MYSQLADMIN=${  
  Mysql_dir}/bin/mysqladmin mysql_sock= "/tmp/mysql.sock" Mysql_user=root mysql_pwd=root ARGS=1 if [$#-ne "$ARGS"];then echo "Please input one arguement:" Fi case $ in Uptime) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd 
    -S $MYSQL _sock status|cut-f2-d ":" |cut-f1-d "T" ' echo $result;; com_update) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Com_updat 
    E "|cut-d" | "-f3 ' echo $result;; slow_queries) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-s $MYSQL _sock status |cut-f5-d ': ' |cut-f1-d ' O ' 
  ' Echo $result;; Com_select) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Com_select ' 
  |cut-d "|"-f3 ' echo $result;; Com_rollback) result= ' ${mysqladmin}-U${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w "com_rollback" |cut-d "|"-f3 ' echo $result 
  ;; 
        Questions) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock status|cut-f4-d ":" |cut-f1-d "S" ' 
  echo $result;; Com_insert) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Com_insert ' 
  |cut-d "|"-f3 ' echo $result;; Com_delete) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Com_delete ' 
  |cut-d "|"-f3 ' echo $result;; Com_commit) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Com_commit ' 
  |cut-d "|"-f3 ' echo $result;;  bytes_sent) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Bytes_sent ' 
  |cut-d "|"-f3 ' echo $result;; Bytes_received) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Bytes_receiv 
  Ed "|cut-d" | "-f3 ' echo $result;; Com_begin) result= ' ${mysqladmin}-u${mysql_user}-p${mysql_pwd}-S $MYSQL _sock extended-status |grep-w ' Com_begin ' |c 
 
    Ut-d "|"-f3 ' echo $result;; *) echo "usage:$0" (uptime| com_update| slow_queries| Com_select| com_rollback| 
Questions) ";;
 Esac

2, modify the client configuration file
View the Zabbix MySQL monitor template with its own

You can see that the template is a key that reads Mysql.status, so the custom key name added to the client configuration file should also be Mysql.status

vim/usr/local/zabbix_agentd/etc/zabbix_agentd.conf
#开启用户自定义配置
unsafeuserparameters=1
#添加mysql监控
userparameter=mysql.status[*],/usr/local/zabbix_agent/bin/checkmysqlperformance.sh $ $

Restart Client
3, testing

[Root@localhost bin]#./zabbix_get-s 127.0.0.1-k Mysql.status[com_update]
77503

4, the template to join the host

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.