一、rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpmmysql
二、yum install -y zabbix zabbix-agentweb
三、cd /etc/zabbixsql
四、vi /etc/zabbix/zabbix_agentd.confbash
修改 server爲服務器ip服務器
修改hostname爲服務器設置的hostnameapp
修改serveractive 爲服務器ip:portsocket
保存,退出
五、添加測試
vi .my.cnf
# Zabbix Agent
[mysql]
host=localhost
user=zabbix
password=@Zabbix..0
socket=/data/mysql/mysql.sock
[mysqladmin]
host=localhost
user=zabbix
password=@Zabbix..0
socket=/data/mysql/mysql.sock
# mysql.sock文件經過find / -name mysql.sock找出路徑
六、# 修改userparameter_mysql.conf:
sudo sed -i ‘s@/var/lib/zabbix@/opt/zabbix/etc@g‘ /opt/zabbix/etc/zabbix_agentd.d/userparameter_mysql.conf
# 修改完成userparameter_mysql.conf內容以下:
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/opt/zabbix/etc mysql -N | awk '{print $$2}'
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 -N'
UserParameter=mysql.ping,HOME=/opt/zabbix/etc mysqladmin ping | grep -c alive
#HOME目錄爲新增.my.cnf文件所在目錄
七、加入開機啓動 spa
chkconfig zabbix-agent onrest
八、#重啓zabbix-agentd
zabbix_agent restart
九、安裝zabbix_get
yum list all |grep zabbix
返回一個列表,表中出現 zabbix-get.x86_84
.yum install zabbix-get.x86_64
十、#測試
# zabbix_get -s 127.0.0.1 -p 10050 -k mysql.ping
# /opt/zabbix/bin/zabbix_get -s 127.0.0.1 -p 10050 -k mysql.version
/data/mysql/bin/mysql Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using EditLine wrapper
#注意:若是測試的時候報錯:sh: mysql: command not found,sh: mysqladmin: command not found,修改userparameter_mysql.conf中mysql,mysqladmin命令的路徑,使用絕對路徑。
十一、Zabbix-web頁面設置
#Configuration—Hosts—Zabbix server—Tempaltes,搜索MySQL,添加彈出的模板,而後更新
#Monitoring—Graphs,選擇組,而後選擇host及展現的圖形
#利用Zabbix自帶模板監控MySQL完成。