下載并安裝percona源,以后用percona toolkit或者innobackup能用到
創(chuàng)新互聯(lián)基于分布式IDC數(shù)據(jù)中心構(gòu)建的平臺為眾多戶提供遂寧服務(wù)器托管 四川大帶寬租用 成都機(jī)柜租用 成都服務(wù)器租用。2.使用Yum安裝percona監(jiān)控插件
yum -y install percona-zabbix-templates安裝完后,大部分文件都放到了/var/lib/zabbix/percona目錄下面
3.在zabbix_agent文件夾下面新建/conf.d/目錄,并將安裝生成的percona監(jiān)控配置文件復(fù)制到此目錄
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監(jiān)控腳本中涉及到本機(jī)的具體參數(shù),腳本使用sock訪問本地?cái)?shù)據(jù)庫
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.shITEM=$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 fi5.編輯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 restart7.測試pecona監(jiān)控腳本是否正常運(yùn)行
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg若配置無誤,會出現(xiàn)一個數(shù)字
8.將/var/lib/percona/templates目錄中的xml模板文件上傳到zabbix_web
就能查看到監(jiān)控圖形了
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。