반응형

MySQL 관련하여 추가로 Percona 에서 제공하는 템플릿을 추가 함으로써

다양한 모니터링이 가능하다.


진행가능한 방법은 아래 사이트에서 확인하고 진행하면 된다.

https://www.percona.com/doc/percona-monitoring-plugins/LATEST/zabbix/index.html


yum으로 Install 할 수 있는데...직접 진행해 본 결과 yum으로는 진행이 안되어서 rpm 으로 설치를 직접 진행 하였다.


아래 사이트는 직접 파일을 다운받아 진행할 수 있다.

https://www.percona.com/downloads/percona-monitoring-plugins/LATEST/


Installation Instructions

Configure Zabbix Agent

  1. Install the package from Percona Software Repositories:

    yum install percona-zabbix-templates
    

    or:

    apt-get install percona-zabbix-templates
    

    It will place files under /var/lib/zabbix/percona/. Alternatively, you can grab the tarball and copy folderszabbix/scripts/ and zabbix/templates/ into /var/lib/zabbix/percona/. See below for the URL.

  2. Copy Zabbix Agent config:

    mkdir -p /etc/zabbix_agentd.conf.d/
    cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix_agentd.conf.d/userparameter_percona_mysql.conf
    
  3. Ensure /etc/zabbix_agentd.conf contains the line: Include=/etc/zabbix_agentd.conf.d/

  4. Restart Agent:

    service zabbix-agent restart
    

Configure MySQL connectivity on Agent

On this step we need to configure and verify MySQL connectivity with localhost on the Agent node.

  1. Create .cnf file /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf as described at configuration file

    Example:

    <?php
    $mysql_user = 'root';
    $mysql_pass = 's3cret';
    
  2. Test the script:

    [root@centos6 main]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
    405647
    

    Should return any number. If the password is wrong in .cnf file, you will get something like:

    [root@centos6 ~]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
    ERROR: run the command manually to investigate the problem: /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
    [root@centos6 ~]# /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
    ERROR: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[root@centos6 ~]#
    
  3. Configure ~zabbix/.my.cnf

    Example:

    [client]
    user = root
    password = s3cret
    
  4. Test the script:

    [root@centos6 ~]# sudo -u zabbix -H /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
    0
    

    Should return 0 or 1 but not the “Access denied” error.

Configure Zabbix Server

  1. Grab the latest tarball from the Percona Software Downloads directory to your desktop.
  2. Unpack it to get zabbix/templates/ folder.
  3. Import the XML template using Zabbix UI (Configuration -> Templates -> Import) by additionally choosing “Screens”.
  4. Create/edit hosts by assigning them “Percona Templates” group and linking the template “Percona MySQL Server Template” (Templates tab).

You are done.



위의 내용은 단순히 복사해서 왔다. 이 이상도 이 이하도 아니다.

다만, 3. Configure ~zabbix/.my.cnf 는 사실 zabbix mysql 를 설치했을 때 의미인 것 같다.

그래서 나는 /etc/my.cnf 에 user 와 password 를 작성 후 진행 하였다.


이 후 Test 스크립트를 진행하게 되면 예시와 동일하게 값이 나왔다.



Import 를 진행 후 보는바와 같이 Percona MySQL Server Template 가 뜬 것을 확인할 수 있다.



MySQL 모니터링을 보게 되면 많은 Item 이 추가 된 것도 확인할 수 있다.

다양한 부분에 대해서 모니터링을 진행할 수 있다.


이 이상으로 추가로 Zabbix 관련 모니터링이 있는지 검색해 봐야겠다.



반응형

+ Recent posts