Download and install Percona source, use Percona Toolkit or Innobackup later
Wget-n--no-check-certificate RPM-IVH percona-release-0.1-4.noarch.rpm
2. Installing the Percona Monitor plugin with Yum
Yum-y Install Percona-zabbix-templates
After the installation, most of the files are placed under the/var/lib/zabbix/percona directory
3. Create a new/conf.d/directory under the Zabbix_agent folder and copy the installation generated Percona monitoring profile to this directory
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. Configure the Percona monitoring script to refer to the specific parameters of the machine, the script uses sock to access the local database
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=$1host=localhostdir= ' dirname $ ' 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 $} ' | Tr ' \ n ', ' if [' $RES ' = ' Yes, yes ', ']; Then echo 1 else echo 0 fi
5. Edit the zabbix_agent configuration file to read the Conf of the Percona plugin
Vim/usr/local/zabbix_agent/conf/zabbix_agentd.conf
# # # option:include# You are Include individual files or all files in a directory in the configuration file.# Installing Zabbix would create include directory in/usr/local/etc, unless modified during the compile time.## mandatory:n o# 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. Restart Zabbix_agent
/etc/init.d/zabbix_agentd restart
7. Test whether the Pecona monitor script is running properly
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh GG
If configured correctly, a number will appear
8. Upload the XML template file from the/var/lib/percona/templates directory to the Zabbix_web
We'll be able to look at the surveillance graphics.
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/95/4E/wKioL1kT9hbg0wQ1AADVxNy7yd0048.png-wh_500x0-wm_ 3-wmp_4-s_470227156.png "title=" Qq20170511132329.png "alt=" Wkiol1kt9hbg0wq1aadvxny7yd0048.png-wh_50 "/>
Monitor MySQL in Zabbix using the Percona monitor plugin