下载并安装percona源,以后用percona toolkit或者innobackup能用到
创新互联基于分布式IDC数据中心构建的平台为众多户提供遂宁服务器托管 四川大带宽租用 成都机柜租用 成都服务器租用。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.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监控脚本是否正常运行
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg若配置无误,会出现一个数字
8.将/var/lib/percona/templates目录中的xml模板文件上传到zabbix_web
就能查看到监控图形了
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。