반응형

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 관련 모니터링이 있는지 검색해 봐야겠다.



반응형
반응형

테스트 중에 나의 주요 목적인 MySQL 모니터링이 제대로 되고 있는지 확인해 보았다.


역시나 Server down.....OTL....

너란 녀석은 정말 힘들구나...


먼저 로그를 보는게 가장 좋다.

zabbix_agentd.log (/var/log/zabbix) 확인을 해 보았다.


여러 에러가 있었지만 이 부분이 가장 화근이었다.



보는 바와 같이 아래 에러를 이해하면 될 듯 싶다.

이미 존재한다고 한다......으응??????????????하아.....존재한다고..먼말이야;;;;

설마 존재하더라도 또 실행해도 되는거 아닌가....ㅠㅠ

이 내용을 빨리 이해했다면 시간을 허비하지 않아도 되었을텐데;;;

 9347:20160718:174922.943 using configuration file: /etc/zabbix/zabbix_agentd.conf

  9347:20160718:174922.973 cannot add user parameter "mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -N | awk '{print $$2}'": key "mysql.status" already exists



 zabbix_agentd.conf 확인

- 여기서 해결되었다.

- 아래보면 Include 에서 나는 2개 동시를 include 하였다.

그래서 아래와 같이 하나만 실행되도록 하고 나머지는 모두 막았다.



이후 다시 실행 해 봤더니 되었다...(사실 에러가 발생하면 zabbix agent가 실행이 안되는 것을 확인 가능하다)


아래와 같이 MySQL 관련 항목들이 모두 받아 오고 있는 것을 확인 가능하다.




 결론 : 


zabbix_agentd.conf 에서 include를 2번이나 실행하면 안된다.


참고사항: https://www.zabbix.com/forum/showthread.php?t=40870



userparameter_mysql.conf


여기에는 추가적으로 이것저것 설정할 수 있다.

아래는 내가 테스트로 추가하다가 다 주석하고 제대로 된 default는 아니지만 참고 하면 된다.


mysql 또는 mysqladmin 에 문법에 맞춰 user와 패스워드를 작성해 줬다.

그리고 문법은 검색하면 나오지만 아래 사이트 참고하면 좋을 듯 싶다.


참고사항 : http://zabbix.dothome.co.kr/doku.php/manual/appendix/recipes


UserParameter=변수명,문법


인데...문법만 실행하면 해당 결과 값이 리턴되어 나온다.

리턴된 값을 변수에 담게 되고  zabbix 에서 사용하는 것으로 예상된다.

그래서 자신의 문법이 틀렸는지 여부는 바로 서버에서 확인하면 될 듯 싶다.


이 부분에서 에러생기면 또 실행이 안되니 이 점 필히 체크 필요하다.


UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -N | awk '{print $$2}'

# Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].

# Key syntax is mysql.size[<database>,<table>,<type>].

# Database may be a database name or "all". Default is "all".

# Table may be a table name or "all". Default is "all".

# Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".

# Database is mandatory if a table is specified. Type may be specified always.

# Returns value in bytes.

# 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table

UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -N'

UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin -uzabbix --password=zabbix ping | grep -c alive

UserParameter=mysql.version,mysql -V

#UserParameter=mysql.ping,mysqladmin -uzabbix --password=zabbix ping | grep alive | wc -l | tr -d " "

#UserParameter=mysql.uptime,mysqladmin -uzabbix --password=zabbix status | cut -f2 -d ":" | cut -f1 -d "T" | tr -d " "

#UserParameter=mysql.threads,mysqladmin -uzabbix --password=zabbix status | cut -f3 -d ":" | cut -f1 -d "Q" | tr -d " "

#UserParameter=mysql.questions,mysqladmin -uzabbix --password=zabbix status | cut -f4 -d ":"|cut -f1 -d "S" | tr -d " "

#UserParameter=mysql.slowqueries,mysqladmin -uzabbix --password=zabbix status | cut -f5 -d ":" | cut -f1 -d "O" | tr -d " "

#UserParameter=mysql.qps,mysqladmin -uzabbix --password=zabbix status | cut -f9 -d ":" | tr -d " "

#UserParameter=mysql.version,mysql -V





반응형
반응형

아는만큼 보인다고..

나는 서버만 구성완료 하고 정작 제대로 되는지를 알지 못해서

뻘짓을 하고 있었다.


Zabbix 모니터링 중 Last 20 issues 에서 Zabbix agent on Zabbix server is unreachable for 5 minutes 라는 문구가 떠 있는것을 확인 하였다.


하지만 난 단순히 Zabbix server is running 이라고 되어 있어서 운용이 되는 줄 알았다.


전혀 Agent 와 통신을 못하고 있었던 것이다.


만약 Zabbix 서버가 다른곳에 있었으며, 해당 서버와 현재 Agent 와 통신을 하는 것이었다면 오히려 운용이 되었을 수 있다.

하지만 그게 아니었기에 내 서버는 지금 모니터링이 안되고 있었던 것이다.


이 말이 무엇이냐하면...


우리가 Agent 를 설치한 후 vi /etc/zabbix/zabbix_agentd.conf 를 수정하게 된다.


여기서 Server 부분을 수정하게 된다.



나는 현재 127.0.0.1 로 자신을 바라보게 되어 있다.

(만약 Zabbix Server와 Agent가 다른곳에 되어 있다면..대부분 다 그렇겠지만...해당 Zabbix Server IP를 작성하게 된다)


이후, zabbix 웹페이지에서 추가 수정 시 맞춰서 작성해 줘야 한다.



이 부분은 어디까지나 내가 테스트한 환경에 의한 것이고,

수정이 필요한 부분이다.


이 부분을 해결하고 나면 어떠한 에러도 나지 않을 것이다.


반응형
반응형

Zabbix 설치 중에 yum으로 install 에서 에러가 발생하는 경우가 있다.


첫번째 실패 후 기존 테섭이 아닌 신규 서버에 설치를 해서 Zabbix 를 설치 하였다.


이 후, 3버전에 설치하기 위해서 기존 테섭에 설치를 진행을 시도 중 동일한 에러를 찾았고

이번에는 너무 쉽게 해결했다...(기존에는 3시간 넘게 찾다가 포기했는데...ㅠ 오늘은 10분만에 해결..ㅠ)


먼저 사이트 공유

https://www.zabbix.com/forum/archive/index.php/t-41058.html



 yum install zabbix-server-mysql zabbix-web-mysql


여기서 첫번째 설치는 넘어간다.

하지만 두번째 zabbix-web-mysql 에서 에러가 생긴다.


...
---> Package net-snmp.x86_64 1:5.3.2.2-25.el5_11 set to be updated
--> Processing Dependency: libsensors.so.3()(64bit) for package: net-snmp
---> Package php-common.x86_64 0:5.1.6-45.el5_11 set to be updated
---> Package php-pdo.x86_64 0:5.1.6-45.el5_11 set to be updated
---> Package php53.x86_64 0:5.3.3-26.el5_11 set to be updated
--> Processing Dependency: php53-cli = 5.3.3-26.el5_11 for package: php53
--> Processing Dependency: php53-common = 5.3.3-26.el5_11 for package: php53
---> Package php53-bcmath.x86_64 0:5.3.3-26.el5_11 set to be updated
---> Package php53-gd.x86_64 0:5.3.3-26.el5_11 set to be updated
---> Package php53-mbstring.x86_64 0:5.3.3-26.el5_11 set to be updated
---> Package php53-xml.x86_64 0:5.3.3-26.el5_11 set to be updated
---> Package unixODBC.x86_64 0:2.2.11-10.el5 set to be updated
---> Package zabbix.x86_64 0:2.2.13-1.el5 set to be updated
--> Running transaction check
---> Package lm_sensors.x86_64 0:2.10.7-9.el5 set to be updated
---> Package php53-cli.x86_64 0:5.3.3-26.el5_11 set to be updated
---> Package php53-common.x86_64 0:5.3.3-26.el5_11 set to be updated
--> Processing Conflict: php53-common conflicts php-common
--> Finished Dependency Resolution
php53-common-5.3.3-26.el5_11.x86_64 from updates has depsolving problems
  --> php53-common conflicts with php-common
Error: php53-common conflicts with php-common
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.
....


여러 뻘짓을 다했지만 아래와 같이 진행하면 끝!!


[root@devDB:/root]#  yum remove php php-common php-cli

Loaded plugins: fastestmirror

Setting up Remove Process

No Match for argument: php

Loading mirror speeds from cached hostfile

 * base: ftp.kaist.ac.kr

 * extras: ftp.kaist.ac.kr

 * updates: ftp.kaist.ac.kr

Package(s) php available, but not installed.

No Match for argument: php-common

Package(s) php-common available, but not installed.

No Match for argument: php-cli

Package(s) php-cli available, but not installed.

No Packages marked for removal

[root@devDB:/root]#

[root@devDB:/root]#

[root@devDB:/root]# yum install php53

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: ftp.kaist.ac.kr

 * extras: ftp.kaist.ac.kr

 * updates: ftp.kaist.ac.kr

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package php53.x86_64 0:5.3.3-26.el5_11 set to be updated

--> Processing Dependency: php53-cli = 5.3.3-26.el5_11 for package: php53

--> Processing Dependency: httpd-mmn = 20051115 for package: php53

--> Processing Dependency: php53-common = 5.3.3-26.el5_11 for package: php53

--> Processing Dependency: httpd for package: php53

--> Running transaction check

---> Package httpd.x86_64 0:2.2.3-91.el5.centos set to be updated

---> Package php53-cli.x86_64 0:5.3.3-26.el5_11 set to be updated

---> Package php53-common.x86_64 0:5.3.3-26.el5_11 set to be updated

--> Finished Dependency Resolution

....


지우고 다시 설치다....하지만 난 저것도 해봤는데 안되었을까....


어쨋든 해결했다.ㅠ


반응형
반응형

난 CentOS 6.6 에 설치를 진행 하였다.


또한 어쩌다가 보니 Zabbix 2.2 로 설치를 진행하였다.(의도한 것은 아니다;;;;;)


설치 페이지는 잘 나와 있으며 의외로 심플하다.


아래 사이트를 참고하면 정말 쉽게 설치 할 수 있을 것이다.

https://www.zabbix.com/documentation/2.2/manual/installation/install_from_packages


또한 설치 전에 MySQL이 설치되어 있어야 하며, Script 를 제대로 보진 않았지만, MySQL 5버전 이상을 설치가 되어 있어야 한다.

테스트 서버는 3버전이 설치되어 있는데...문법에서 여러에러가 생기는 것을 확인하였다.


한번 3버전에 설치를 다시 진행해 볼 예정이다.


어쨋든 위의 사이트를 참고하는 것이 어떤 블로그를 보는것보다 쉬울것으로 예상된다.

반응형
반응형


Zabbix 에 대해 설치해 보았다.

마음 같아서는 개발 서버에(mysql 이 멀티로 엄청 올라가 있기에 테스트가 좋음...) 올리고 싶었지만 안올라가더군...


가장 찾기 힘들다고 생각하는 rpm 호환성에서...


그래서 설치가 제 1차 목적이기에 VM에 설치하여 보았다.


정말 yum으로 설치하니....너무 편했다....소스로 설치하고 싶지만...정보가 부족하기에...ㅠ


여기에 문제가 발생하였다.


Zabbix Server is running 에서 Value 값이 No라고 나온 것을 확인 가능하다


검색해 보니 conf 파일들에 대해서 127.0.0.1 로 변경하라고 해서 해 봤지만, 전혀 해결이 되지 않았다.


혹시 나처럼 문제가 있는 사람들은 conf 파일들을 수정하기 전에 먼저 방화벽 을 확인해 보기 바란다.


vi /etc/sysconfig/iptables


-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT


를 우리는 가장 많이 확인한다.


물론 여기에도 추가를 해 놔야 하지만..(난 이미 추가를 해 봤지만 안되었다.)


여기서 우리는 웹페이지를 제공받고 그 해당 웹페이지를 통해서 본다.


즉, 웹페이지 관련 방화벽도 확인해 봐야 한다!


vi /etc/sysconfig/ip6tables


-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT


service ip6tables restart


를 한 후 확인하면 어느새 아래와 같이 Yes 가 된 것을 확인 할 수 있다.



이제 이것저것 확인해 봐야겠다.

반응형

+ Recent posts