您好,登錄后才能下訂單哦!
下載并安裝percona源,以后用percona toolkit或者innobackup能用到
wget -N --no-check-certificate rpm -ivh percona-release-0.1-4.noarch.rpm
2.使用Yum安裝percona監控插件
yum -y install percona-zabbix-templates
安裝完后,大部分文件都放到了/var/lib/zabbix/percona目錄下面
3.在zabbix_agent文件夾下面新建/conf.d/目錄,并將安裝生成的percona監控配置文件復制到此目錄
mkdir -p /usr/local/zabbix_agent/conf.d/ cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /usr/local/zabbix/conf.d/ chown -R zabbix.zabbix /usr/local/zabbix_agent/
4.配置percona監控腳本中涉及到本機的具體參數,腳本使用sock訪問本地數據庫
vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
# ============================================================================ $mysql_user = 'mpm'; $mysql_pass = '123456'; $mysql_port = 3306; $mysql_socket = '/data/mysql/3306/tmp/mysql3306.sock'; $mysql_flags = 0;
vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
ITEM=$1 HOST=localhost DIR=`dirname $0` CMD="/usr/bin/php -q $DIR/ss_get_mysql_stats.php --host $HOST --items gg" CACHEFILE="/tmp/$HOST-mysql_cacti_stats.txt" if [ "$ITEM" = "running-slave" ]; then # Check for running slave RES=`/usr/local/mysql/bin/mysql -umpm -p123456 -S /data/mysql/3306/tmp/mysql3306.sock -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ','` if [ "$RES" = " Yes, Yes," ]; then echo 1 else echo 0 fi
5.編輯zabbix_agent配置文件,讓其讀到percona插件的conf
vim /usr/local/zabbix_agent/conf/zabbix_agentd.conf
### Option: Include # You may include individual files or all files in a directory in the configuration file. # Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. # # Mandatory: no # Default: # Include= # Include=/usr/local/etc/zabbix_agentd.userparams.conf # Include=/usr/local/etc/zabbix_agentd.conf.d/ Include=/usr/local/zabbix_agent/conf.d/
6.重新啟動zabbix_agent
/etc/init.d/zabbix_agentd restart
7.測試pecona監控腳本是否正常運行
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
若配置無誤,會出現一個數字
8.將/var/lib/percona/templates目錄中的xml模板文件上傳到zabbix_web
就能查看到監控圖形了
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。