{"id":561,"date":"2021-06-28T11:32:11","date_gmt":"2021-06-28T03:32:11","guid":{"rendered":"https:\/\/twocups.cn\/?p=561"},"modified":"2021-06-28T19:17:40","modified_gmt":"2021-06-28T11:17:40","slug":"43","status":"publish","type":"post","link":"https:\/\/twocups.cn\/index.php\/2021\/06\/28\/43\/","title":{"rendered":"\u3010Zabbix\u7cfb\u5217\u3011\u7b2c\u516d\u7ae0\uff1aZabbix\u76d1\u63a7\u591a\u7aef\u53e3Mysql"},"content":{"rendered":"\n<p><img width=\"80\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2019\/12\/logo%E6%A8%AA.png\" alt=\"\">\u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3a\u535a\u4e3b\u539f\u521b\u6587\u7ae0\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\uff1a<a href=\"https:\/\/twocups.cn\/index.php\/2021\/06\/28\/43\/\">https:\/\/twocups.cn\/index.php\/2021\/06\/28\/43\/<\/a><\/p>\n\n\n\n<h2>\u60c5\u51b5\u8bf4\u660e<\/h2>\n\n\n\n<p>Zabbix \u662f\u539f\u751f\u652f\u6301\u76d1\u63a7\u673a\u5668\u4e0a\u7684\u5355\u4e2a Mysql \u7684\uff0c\u8fd9\u4e2a\u7f51\u4e0a\u6559\u7a0b\u5f88\u591a\uff0c\u53ef\u4ee5\u81ea\u5df1\u53bb\u67e5\u9605\u4e00\u4e0b\u3002\u4f46\u662f\u539f\u751f\u7684 Zabbix \u76d1\u63a7\u5e76\u4e0d\u652f\u6301\u4e00\u53f0\u673a\u5668\u4e0a\u7684\u4e00\u4e9b\u7aef\u53e3\u4e0a\u90fd\u90e8\u7f72\u4e86 Mysql \u5b9e\u4f8b\u7684\u60c5\u51b5\u3002\u6bd4\u5982\uff0c\u670d\u52a1\u5668\u4e0a\u768420120\u300120121\u300120122\u7b49\u5341\u51e0\u4e2a\u7aef\u53e3\u90fd\u90e8\u7f72\u4e86 Mysql \u5b9e\u4f8b\u3002<\/p>\n\n\n\n<p>Zabbix \u7248\u672c\uff1a5.0 LTS<\/p>\n\n\n\n<p>Mysql\u7248\u672c\uff1a\u4efb\u610f<\/p>\n\n\n\n<h2>\u6d41\u7a0b\u7b80\u4ecb<\/h2>\n\n\n\n<p>Zabbix \u670d\u52a1\u7aef\u4e3b\u52a8\u5411 Zabbix \u5ba2\u6237\u7aef\u53d1\u9001\u76d1\u63a7\u8bf7\u6c42\uff0cZabbix \u5ba2\u6237\u7aef\u6536\u5230\u8bf7\u6c42\u540e\u8fd0\u884c\u6211\u4eec\u81ea\u5b9a\u4e49\u7684\u811a\u672c\uff0c\u901a\u8fc7 socket \u6587\u4ef6\u5411\u672c\u673a\u5185\u6307\u5b9a\u7aef\u53e3\u7684 Mysql \u5b9e\u4f8b\u53d1\u9001\u8bf7\u6c42\u3002Zabbix \u5ba2\u6237\u7aef\u5f97\u5230 Mysql \u8fd4\u56de\u7684\u6570\u636e\u540e\uff0c\u518d\u5c06\u5176\u53d1\u9001\u7ed9 Zabbix \u670d\u52a1\u7aef\u3002<\/p>\n\n\n\n<h2>\u539f\u7406\u7b80\u4ecb<\/h2>\n\n\n\n<p>\u53ef\u80fd\u73b0\u5728\u770b\u4e0d\u61c2\uff0c\u4f46\u628a\u6574\u4e2a\u90e8\u7f72\u8fdb\u884c\u4e00\u904d\u4e4b\u540e\u5c31\u80fd\u770b\u5230\u8fd9\u91cc\u5728\u8bf4\u4ec0\u4e48\u4e86\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5148\u5728\u88ab\u76d1\u63a7\u7684\u4e3b\u673a\u4e0a\u5b9a\u4e49\u5b8f {$MYSQLPORT}\uff0c\u5b8f\u7684\u503c\u5c31\u662f\u8fd9\u53f0\u4e3b\u673a\u90e8\u7f72\u4e86 Mysql \u5b9e\u4f8b\u7684\u7aef\u53e3\u4eec\u3002Zabbix \u670d\u52a1\u7aef\u6709\u4e86\u88ab\u76d1\u63a7\u4e3b\u673a\u7684\u5b8f\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u53bb\u8bbf\u95ee\u88ab\u76d1\u63a7\u4e3b\u673a\u4e0a\u7684 Mysql \u5b9e\u4f8b\u7684\u7aef\u53e3\u4eec\u3002\u8fd9\u65f6\uff0cZabbix \u670d\u52a1\u7aef\u518d\u8c03\u7528 Zabbix \u5ba2\u6237\u7aef\u811a\u672c\uff0c\u53bb\u9010\u4e2a\u8bbf\u95ee\u6240\u6709\u6307\u5b9a\u7aef\u53e3\u7684 Mysql \u5b9e\u4f8b\uff0c\u8fd9\u6837\u5c31\u80fd\u83b7\u5f97\u6211\u4eec\u60f3\u8981\u7684\u6570\u636e\u4e86\u3002<\/p>\n\n\n\n<h2>\u5728\u591a\u4e2aMysql\u4e2d\u90fd\u65b0\u5efa\u76d1\u63a7\u8d26\u53f7<\/h2>\n\n\n\n<p>\u65e2\u7136\u6211\u4eec\u8981\u8bbf\u95ee Mysql \u5b9e\u4f8b\uff0c\u90a3\u4e48\u6211\u4eec\u9700\u8981\u5728\u6bcf\u4e2a Mysql \u5b9e\u4f8b\u4e2d\u90fd\u521b\u5efa\u76d1\u63a7\u8d26\u53f7\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u8d26\u53f7\u4e3a zabbix_monitor\uff0c\u5bc6\u7801\u4e3a0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE USER 'zabbix_monitor'@'%' IDENTIFIED BY '0';<br>GRANT USAGE,PROCESS,REPLICATION CLIENT,REPLICATION SLAVE,SUPER ON *.* TO 'zabbix_monitor'@'%';<br>FLUSH PRIVILEGES;<\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u4e0d\u60f3\u8bbe\u7f6e\u5bc6\u7801\uff0c\u5c31\u8fd9\u4e48\u5199\u3002\u4f46\u8fd9\u6837\u53ef\u80fd\u4f1a\u51fa\u73b0\u4e00\u4e2a\u95ee\u9898\uff0c\u5177\u4f53\u95ee\u9898\u548c\u89c4\u907f\u65b9\u6cd5\u6211\u5728\u4e0b\u9762\u8bf4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CREATE USER 'zabbix_monitor'@'%';<br>GRANT USAGE,PROCESS,REPLICATION CLIENT,REPLICATION SLAVE,SUPER ON *.* TO 'zabbix_monitor'@'%';<br>FLUSH PRIVILEGES;<\/pre>\n\n\n\n<p>\u63d0\u4e00\u53e5\uff0c\u4e0d\u8981\u5c06\u65b0\u5efa\u7528\u6237\u6307\u4ee4\u548c\u8d4b\u6743\u6307\u4ee4\u4e00\u8d77\u5199\uff0c\u5426\u5219\u65b0\u4e00\u70b9\u7684\u7248\u672c\u90fd\u4f1a\u51fa\u73b0 Warning \u7684\u3002<\/p>\n\n\n\n<h2>\u4fee\u6539Zabbix\u5ba2\u6237\u7aef\u914d\u7f6e<\/h2>\n\n\n\n<p>\u9996\u5148\uff0c\u6211\u4eec\u4fee\u6539 zabbix-agent2 \u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim \/etc\/zabbix\/zabbix_agent2.conf<br>\u200b<br># \u4ee5\u4e0b\u662f\u914d\u7f6e\u6587\u4ef6\/etc\/zabbix\/zabbix_agent2.conf\u4e2d\u7684\u5185\u5bb9<br># \u8fd9\u6761\u7684\u610f\u601d\u662f\u8fd0\u884c\u6307\u5b9a\u6587\u4ef6\u5939\u4e0b\u6240\u6709\u7684conf\u914d\u7f6e<br>Include=\/etc\/zabbix\/zabbix_agent2.d\/*.conf<br># \u8fd9\u6761\u7684\u610f\u601d\u662f\u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49\u76d1\u63a7\u9879<br>UnsafeUserParameters=1<\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u65b0\u589e\u914d\u7f6e\u6587\u4ef6 multi_mysql.conf\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim \/etc\/zabbix\/zabbix_agent2.d\/multi_mysql.conf<br>\u200b<br># \u4ee5\u4e0b\u662f\u914d\u7f6e\u6587\u4ef6\/etc\/zabbix\/zabbix_agent2.d\/multi_mysql.conf\u4e2d\u7684\u5185\u5bb9<br># mysql\u57fa\u7840\u76d1\u63a7\u9879<br>UserParameter=mysql_discovery[*],\/etc\/zabbix\/bin\/discovery_mysql.sh $1<br>UserParameter=mysql.test.status[*],\/etc\/zabbix\/bin\/mysql_status.sh $1 $2<br>UserParameter=mysql.test.ping[*],\/etc\/zabbix\/bin\/mysql_alive.sh $1<br>UserParameter=mysql.test.ms.check[*],\/etc\/zabbix\/bin\/mysql_slave_status.sh $1<br>UserParameter=mysql.test.ms.time[*],\/etc\/zabbix\/bin\/mysql_slave_time.sh $1<br># mysql\u8fdb\u7a0b\u5217\u8868<br>UserParameter=mysql.test.processlist[*],\/etc\/zabbix\/bin\/mysql_processlist.sh $1<br># mysql\u4e8b\u52a1<br>UserParameter=mysql.test.innodb.trx[*],\/etc\/zabbix\/bin\/mysql_innodb_trx.sh $1<\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\u4e00\u4e0b<\/strong>\uff0c\u91cc\u9762\u6709\u4e00\u4e2a\u53c2\u6570\u662f\u201cmysql.test.ping\u201d\u3002\u5982\u679c\u628a\u5b83\u6539\u6210\u201cmysql.ping\u201d\u5c31\u4f1a\u5bfc\u81f4 zabbix-agent2 \u542f\u52a8\u5931\u8d25\uff0c\u62a5\u9519\u539f\u56e0\u662f\u201c\u7528\u6237\u53c2\u6570mysql.ping[*]\u65e0\u6cd5\u521d\u59cb\u5316\uff0c\u56e0\u4e3a\u4e3b\u952e\u5df2\u7ecf\u5b58\u5728\u4e86\u201d\uff0c\u6240\u4ee5\u6211\u8fd9\u91cc\u6539\u6210\u4e86\u201cmysql.test.ping\u201d\uff0c\u4f60\u8981\u60f3\u6539\u6210\u5176\u4ed6\u7684\u540d\u5b57\u4e5f\u53ef\u4ee5\u3002<\/p>\n\n\n\n<p>\u4ece\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u6211\u4eec\u80fd\u5f88\u5bb9\u6613\u770b\u51fa\u6765\uff0c\u5f53 Zabbix \u670d\u52a1\u7aef\u5411 Zabbix \u5ba2\u6237\u7aef\u8bf7\u6c42\u6307\u5b9a\u53c2\u6570\u7684\u65f6\u5019\uff0cZabbix \u5ba2\u6237\u7aef\u8fd0\u884c\u6307\u5b9a\u811a\u672c\u3002\u8fd9\u5176\u5b9e\u5c31\u662f Zabbix \u539f\u751f\u7684\u76d1\u63a7\u81ea\u5b9a\u4e49\u9879\u7684\u65b9\u6cd5\uff0c\u683c\u5f0f\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">UserParameter=\u53c2\u6570\u540d\u79f0,shell\u6307\u4ee4<\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u6709\u5176\u4ed6\u60f3\u76d1\u63a7\u7684\u53c2\u6570\uff0c\u4e5f\u53ef\u4ee5\u6309\u7167\u8fd9\u4e2a\u683c\u5f0f\u5199\u3002\u4e0d\u8fc7\u5982\u679c\u4e0e Mysql \u65e0\u5173\u7684\u8bdd\uff0c\u6700\u540e\u65b0\u5efa\u4e00\u4e2a conf \u914d\u7f6e\u6587\u4ef6\uff0c\u65b9\u4fbf\u4f60\u540e\u671f\u597d\u5f52\u7c7b\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 shell \u6307\u4ee4\u5c31\u662f\u8fd0\u884c\u6211\u4eec\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u5e26\u53c2\u811a\u672c\uff0c\u90a3\u4e48\u6211\u4eec\u73b0\u5728\u5c31\u8981\u53bb\u521b\u5efa\u8fd9\u4e9b\u811a\u672c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u9996\u5148\u521b\u5efa\u5b58\u653e\u811a\u672c\u7684\u6587\u4ef6\u5939<br>mkdir \/etc\/zabbix\/bin<br>cd \/etc\/zabbix\/bin<\/pre>\n\n\n\n<p>\u811a\u672c1\uff1a\u81ea\u52a8\u53d1\u73b0\u4e0d\u540c\u7aef\u53e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim discovery_mysql.sh<br>\u200b<br># \u4ee5\u4e0b\u662f\u811a\u672c discovery_mysql.sh \u7684\u5185\u5bb9<br>res=`echo $1| sed \"s\/_\/\\n\/g\"`;<br>port=($res)<br>printf '{\\n'<br>printf '\\t\"data\":[\\n'<br>for key in ${!port[@]}<br>do<br>if [[ \"${#port[@]}\" -gt 1 &amp;&amp; \"${key}\" -ne \"$((${#port[@]}-1))\" ]];<br>then<br>printf '\\t {\\n'<br>printf \"\\t\\t\\t\\\"{#MYSQLPORT}\\\":\\\"${port[${key}]}\\\"},\\n\"<br>else [[ \"${key}\" -eq \"((${#port[@]}-1))\" ]]<br>printf '\\t {\\n'<br>printf \"\\t\\t\\t\\\"{#MYSQLPORT}\\\":\\\"${port[${key}]}\\\"}\\n\"<br>fi<br>done<br>printf '\\t ]\\n'<br>printf '}\\n'<\/pre>\n\n\n\n<p>\u811a\u672c2\uff1a\u76d1\u63a7 Mysql \u6027\u80fd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim mysql_status.sh<br>\u200b<br># \u4ee5\u4e0b\u662f\u811a\u672c mysql_status.sh \u7684\u5185\u5bb9<br>#!\/bin\/bash<br>var=$1<br>mysql=\/usr\/bin\/mysql<br>MYSQL_USER=\"zabbix_monitor\"<br>MYSQL_PASSWORD=0<br>MYSQL_SOCK_DIR=\"\/tmp\/mysql_$2.sock\"<br>${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -S ${MYSQL_SOCK_DIR} -e \"show global status;\" 2&gt; \/dev\/null |grep -v Variable_name|grep \"\\b${var}\\b\"|awk '{print $2}'<\/pre>\n\n\n\n<p>\u811a\u672c3\uff1a\u76d1\u63a7\u662f\u5426\u80fd\u8fde\u901a Mysql \u5b9e\u4f8b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim mysql_alive.sh<br>\u200b<br># \u4ee5\u4e0b\u662f\u811a\u672c mysql_alive.sh \u7684\u5185\u5bb9<br>#!\/bin\/bash<br>mysqladmin=\/usr\/bin\/mysqladmin<br>MYSQL_USER=\"zabbix_monitor\"<br>MYSQL_PASSWORD=0<br>MYSQL_SOCK_DIR=\"\/tmp\/mysql_$1.sock\"<br>${mysqladmin} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -S ${MYSQL_SOCK_DIR} ping|grep -c alive<\/pre>\n\n\n\n<p>\u811a\u672c4\uff1a\u76d1\u63a7\u4ece\u5e93 Mysql \u6027\u80fd\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim mysql_slave_status.sh<br>\u200b<br># \u4ee5\u4e0b\u662f\u811a\u672c mysql_slave_status.sh \u7684\u5185\u5bb9<br>#!\/bin\/bash<br>#var=$1<br>mysql=\/usr\/bin\/mysql<br>MYSQL_USER=\"zabbix_monitor\"<br>MYSQL_PASSWORD=0<br>MYSQL_SOCK_DIR=\"\/tmp\/mysql_$1.sock\"<br>${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -S ${MYSQL_SOCK_DIR} -e \"show slave status\\G;\" 2&gt; \/dev\/null|grep -E 'Slave_IO_Running: Yes|Slave_SQL_Running: Yes'|grep -c Yes<\/pre>\n\n\n\n<p>\u811a\u672c5\uff1a\u76d1\u63a7\u4ece\u5e93\u5ef6\u8fdf\u60c5\u51b5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim mysql_slave_time.sh<br>\u200b<br># \u4ee5\u4e0b\u662f\u811a\u672c mysql_slave_time.sh \u7684\u5185\u5bb9<br>#!\/bin\/bash<br>#var=$1<br>mysql=\/usr\/bin\/mysql<br>MYSQL_USER=\"zabbix_monitor\"<br>MYSQL_PASSWORD=0<br>MYSQL_SOCK_DIR=\"\/tmp\/mysql_$1.sock\"<br>${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -S ${MYSQL_SOCK_DIR} -e \"show slave status\\G;\" 2&gt; \/dev\/null|grep -E 'Seconds_Behind_Master'|awk '{print $2}'<\/pre>\n\n\n\n<p>\u811a\u672c6\uff1a\u76d1\u63a7 Mysql \u8fdb\u7a0b\u5217\u8868\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim mysql_processlist.sh<br>\u200b<br># \u4ee5\u4e0b\u662f\u811a\u672c mysql_processlist.sh \u7684\u5185\u5bb9<br>#!\/bin\/bash<br>mysql=\/usr\/bin\/mysql<br>MYSQL_USER=\"zabbix_monitor\"<br>MYSQL_PASSWORD=0<br>MYSQL_SOCK_DIR=\"\/tmp\/mysql_$1.sock\"<br>${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -S ${MYSQL_SOCK_DIR} -e \"select * from information_schema.processlist order by time;\" 2&gt; \/dev\/null<\/pre>\n\n\n\n<p>\u811a\u672c7\uff1a\u76d1\u63a7\u5f53\u524d Innodb \u5f15\u64ce\u5185\u6bcf\u4e2a\u4e8b\u7269\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim mysql_innodb_trx.sh<br>\u200b<br># \u4ee5\u4e0b\u662f\u811a\u672c mysql_innodb_trx.sh \u7684\u5185\u5bb9<br>#!\/bin\/bash<br>mysql=\/usr\/bin\/mysql<br>MYSQL_USER=\"zabbix_monitor\"<br>MYSQL_PASSWORD=0<br>MYSQL_SOCK_DIR=\"\/tmp\/mysql_$1.sock\"<br>${mysql} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -S ${MYSQL_SOCK_DIR} -e \"select * from information_schema.innodb_trx order by trx_started\\G\" 2&gt; \/dev\/null<\/pre>\n\n\n\n<p>\u6240\u6709\u811a\u672c\u521b\u5efa\u597d\u4ee5\u540e\u4e00\u5b9a\u8981\u7ed9\u5176\u8fd0\u884c\u6743\u9650\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u201cPermission denied\u201d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chmod 777 \/etc\/zabbix\/bin\/*.sh<\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\u70b91<\/strong>\uff1a\u4ee5\u4e0a mysqladmin \u548c mysql \u7684\u5730\u5740\u662f\u6211\u673a\u5668\u4e0a\u7684\u5730\u5740\uff0c\u4f60\u673a\u5668\u4e0a\u7684\u5730\u5740\u81ea\u5df1\u5148\u53bb\u67e5\u4e00\u4e0b\uff0c\u7136\u540e\u66ff\u6362\u6389\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u67e5\u627e\u673a\u5668\u4e0amysqladmin\u548cmysql\u7684\u5730\u5740<br>find \/ -name mysqladmin<br>find \/ -name mysql<\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\u70b92<\/strong>\uff1a\u4ee5\u4e0a socket \u6587\u4ef6\u7684\u5730\u5740\u6211\u5199\u7684\u662f\u201c\/tmp\/mysql_$1.sock\u201d\uff0c\u8fd9\u662f\u7531\u4e8e\u6211\u673a\u5668\u4e0a\u7684 socket \u6587\u4ef6\u53eb\u8fd9\u4e2a\u540d\u5b57\uff0c\u6bd4\u5982\u201c\/tmp\/mysql_20120.sock\u201d\u3002\u4f60\u8981\u81ea\u5df1\u53bb\u770b\u770b\u4f60\u673a\u5668\u4e0a socket \u6587\u4ef6\u7684\u76ee\u5f55\u548c\u540d\u79f0\uff0c\u7136\u540e\u66ff\u6362\u6389\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u67e5\u627e\u673a\u5668\u4e0a\u6240\u6709\u8fde\u63a5mysql\u7684socket\u6587\u4ef6<br>find \/ -name mysql*.sock<\/pre>\n\n\n\n<p><strong>\u6ce8\u610f\u70b93<\/strong>\uff1a\u4ee5\u4e0a\u662f\u4e4b\u524d\u6211\u4eec\u521b\u5efa\u7684\u76d1\u63a7\u8d26\u53f7 zabbix_monitor \u5bc6\u7801\u4e3a0\u7684\u60c5\u51b5\u3002\u5982\u679c\u4e4b\u524d\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801\u4e3a\u7a7a\u7684\u8bdd\uff0c\u4e0d\u662f\u53bb\u6389\u201cMYSQL_PASSWORD=0\u201d\u5c31\u884c\u4e86\uff0c\u8fd8\u8981<strong>\u540c\u65f6<\/strong>\u53bb\u6389\u6700\u540e\u4e00\u6761\u5b9e\u9645 shell \u8bed\u53e5\u4e2d\u7684\u201c-p${MYSQL_PASSWORD}\u201d\u624d\u884c\u3002<\/p>\n\n\n\n<p>\u6211\u4e4b\u524d\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801\uff0c\u53ea\u53bb\u6389\u4e86\u201cMYSQL_PASSWORD=0\u201d\uff0c\u800c<strong>\u6ca1\u6709<\/strong>\u53bb\u6389\u201c-p${MYSQL_PASSWORD}\u201d\u3002\u8fd9\u5c31\u5bfc\u81f4\u4e86 Zabbix \u76d1\u63a7\u9879\u8fd4\u56de\u6570\u636e\u4e0d\u5bf9\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Mysql On 20120 status<br>\u200b<br>\u8fd4\u56de\u6570\u636e\uff1a<br>Enter password: 1<\/pre>\n\n\n\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u8fd4\u56de\u6570\u636e\u5e94\u8be5\u662f\u201c1\u201d\uff0c\u800c\u8fd9\u91cc\u8fd4\u56de\u6570\u636e\u5c31\u53d8\u6210\u4e86\u201cEnter password: 1\u201d\u3002\u5148\u4e0d\u8bf4\u5185\u5bb9\uff0c\u8fd9\u4e2a\u53c2\u6570\u7684\u5b58\u50a8\u683c\u5f0f\u662f\u65e0\u7b26\u53f7\u6570\u5b57\uff0c\u8fd9\u91cc\u8fd4\u56de\u4e86\u4e00\u4e2a\u6587\u672c\u7c7b\u578b\uff0c\u80af\u5b9a\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u5c31\u6d89\u53ca\u5230\u53e6\u4e00\u4e2a\u95ee\u9898\u4e86\uff0c\u4e3a\u4ec0\u4e48\u8981\u65b0\u5efa\u76d1\u63a7\u8d26\u53f7\uff1f\u76f4\u63a5\u7528 root \u8d26\u6237\u4e0d\u597d\u5417\uff1f<\/p>\n\n\n\n<h2>\u4e3a\u4ec0\u4e48\u8981\u65b0\u5efa\u76d1\u63a7\u8d26\u53f7\uff1f<\/h2>\n\n\n\n<p>\u56e0\u4e3a<strong>\u6743\u9650<\/strong>\u3002<\/p>\n\n\n\n<p>\u5728\u5b9e\u9645\u4f01\u4e1a\u73af\u5883\u4e2d\uff0croot \u8d26\u53f7\u5e76\u4e0d\u4e00\u5b9a\u62e5\u6709\u5168\u90e8\u7684\u6743\u9650\u3002\u6240\u6709\u7684\u6743\u9650\u90fd\u5728\u4e00\u4e2a\u7279\u6b8a\u8d26\u6237\u4e0a\uff0c\u6211\u4eec\u4e00\u822c\u90fd\u662f\u7528\u8fd9\u4e2a\u8d26\u6237\u6765\u767b\u9646\u6570\u636e\u5e93\u7684\uff0c\u800c\u4e0d\u662f root\u3002<\/p>\n\n\n\n<p>\u800c\u6211\u4eec\u505a\u76d1\u63a7\uff0c\u5c31\u662f\u8981\u65e0\u8bba\u6570\u636e\u5e93\u51fa\u73b0\u4ec0\u4e48\u60c5\u51b5\uff0c\u90fd\u5bf9\u5b83\u8fdb\u884c\u5b9e\u65f6\u76d1\u63a7\u3002\u8fd9\u53c8\u6d89\u53ca\u5230\u4e00\u4e2a Mysql \u7684\u8d26\u6237\u6743\u9650\uff0c<strong>SUPER \u6743\u9650<\/strong>\u3002\u62e5\u6709 SUPER \u6743\u9650\u7684\u8d26\u6237\u88ab\u79f0\u4e3a SUPER \u8d26\u6237\uff0c\u5373\u4f7f\u5728\u6570\u636e\u5e93\u5904\u4e8e\u79bb\u7ebf\u6a21\u5f0f\u7684\u65f6\u5019\u4e5f\u80fd\u8fde\u63a5\u4e0a\u6570\u636e\u5e93\uff0c\u8fd9\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u70b9\u3002<\/p>\n\n\n\n<p>\u79bb\u7ebf\u6a21\u5f0f\uff08offline mode\uff09\u662f Mysql 5.7\u7248\u672c\u7684\u65b0\u7279\u6027\uff0c\u7528\u4e8e\u5728\u7ba1\u7406\u5458\u5bf9\u6570\u636e\u5e93\u8fdb\u884c\u5347\u7ea7\u548c\u7ef4\u62a4\u5de5\u4f5c\u65f6\uff0c\u963b\u6b62\u5176\u4ed6\u8d26\u6237\u5bf9\u6570\u636e\u5e93\u8fdb\u884c\u8bbf\u95ee\u7684\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u5728 root \u8d26\u6237\u6ca1\u6709 SUPER \u6743\u9650\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u6709 SUPER \u6743\u9650\u7684\u8d26\u6237 zabbix_monitor \u6765\u4f7f Zabbix \u5bf9 Mysql \u8fdb\u884c\u76d1\u63a7\uff0c\u9632\u6b62\u5728\u6570\u636e\u5e93\u5904\u7406\u79bb\u7ebf\u6a21\u5f0f\u7684\u65f6\u5019\u62d2\u7edd Zabbix \u7684\u8bbf\u95ee\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\uff0c\u5728\u5b9e\u9645\u7684\u4f01\u4e1a\u73af\u5883\u4e2d\uff0c\u6709\u4e9b\u662f\u4e0d\u5141\u8bb8\u51fa\u73b0\u989d\u5916\u7684 SUPER \u8d26\u6237\u7684\u3002\u6211\u81ea\u5df1\u5f53\u65f6\u5c31\u521b\u5efa\u4e86\u6709 SUPER \u6743\u9650\u7684 zabbix_monitor \u8d26\u6237\uff0c\u7ed3\u679c\u53cd\u624b\u5c31\u88ab\u7cfb\u7edf\u4e0b\u6389\u4e86\u8be5\u8d26\u6237\u7684 SUPER \u6743\u9650\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u6211\u81ea\u5df1\u7684\u89e3\u51b3\u65b9\u6cd5\u5c31\u662f\u76f4\u63a5\u7528\u767b\u9646\u6570\u636e\u5e93\u7528\u5230\u7684<strong>\u7279\u6b8a\u8d26\u6237<\/strong>\u53bb\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u6bd5\u7adf\u7cfb\u7edf\u4e0d\u5141\u8bb8\u5b83\u4ee5\u5916\u7684\u8d26\u6237\u6709 SUPER \u6743\u9650\uff0c\u6211\u7528\u5b83\u6765\u76d1\u63a7\u4e5f\u662f\u65e0\u5948\u4e4b\u4e3e\u3002\u7531\u4e8e\u8fd9\u4e2a\u7279\u6b8a\u8d26\u6237\u662f\u6ca1\u6709\u5bc6\u7801\u7684\uff0c\u6240\u4ee5\u6211\u4e4b\u524d\u624d\u5f3a\u8c03\u4e86\u76d1\u63a7\u8d26\u6237\u6ca1\u6709\u5bc6\u7801\u7684\u65f6\u5019\u811a\u672c\u5982\u4f55\u6539\u52a8\u3002<\/p>\n\n\n\n<h2>Zabbix\u5ba2\u6237\u7aef\u914d\u7f6e\u5b8c\u6210<\/h2>\n\n\n\n<p>\u4ee5\u4e0a\u6d41\u7a0b\u8d70\u5b8c\u540e\uff0cZabbix \u5ba2\u6237\u7aef\u7684\u914d\u7f6e\u5c31\u5b8c\u6210\u4e86\u3002\u6211\u4eec\u91cd\u542f Zabbix \u5ba2\u6237\u7aef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart zabbix-agent2<\/pre>\n\n\n\n<h2>Zabbix\u524d\u7aef\u9875\u9762\u914d\u7f6e<\/h2>\n\n\n\n<p>\u7b2c\u4e00\u6b65\uff0c\u6211\u4eec\u5148\u6dfb\u52a0\u4e3b\u673a\u5b8f\u3002\u8fd9\u4e2a\u5fc5\u987b\u653e\u5728\u7b2c\u4e00\u6b65\uff0c\u5426\u5219\u5c31\u4f1a\u51fa\u73b0\u7aef\u53e3\u627e\u4e0d\u5230\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u540e\u6dfb\u52a0\u4e3b\u673a\u5b8f\u7684\u9519\u8bef\u663e\u793a\uff1a\u201c{}\u201d\u91cc\u9762\u5e94\u8be5\u663e\u793a\u7aef\u53e3\u53f7\uff0c\u4f46\u8fd9\u91cc\u6ca1\u6709\u663e\u793a<br>mysql_discovery: Mysql On {} status<\/pre>\n\n\n\n<p>\u6211\u4eec\u6765\u5230 Zabbix \u524d\u7aef\u9875\u9762\uff0c\u5de6\u4fa7\u680f\u201c\u914d\u7f6e-\u4e3b\u673a\u201d\uff0c\u9009\u62e9\u9700\u8981\u76d1\u63a7\u7684\u4e3b\u673a\u3002\u518d\u8fdb\u5165\u4e3b\u673a\u914d\u7f6e\u754c\u9762\u540e\uff0c\u914d\u7f6e\u8be5\u4e3b\u673a\u7684\u5b8f\u3002<\/p>\n\n\n\n<p>\u5b8f\uff1a{$MYSQLPORT}\uff0c\u503c\uff1a\u7aef\u53e3\u53f7\uff08\u591a\u7aef\u53e3\u53f7\u4e4b\u95f4\u7528\u4e0b\u5212\u7ebf\u8fde\u63a5\uff09\uff0c\u4f8b\u598220120_20121_20122\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u53ef\u4e3b\u673a\u5b8f.png\" alt=\"\" class=\"wp-image-547\" width=\"1070\" height=\"414\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u53ef\u4e3b\u673a\u5b8f.png 2140w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u53ef\u4e3b\u673a\u5b8f-300x116.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u53ef\u4e3b\u673a\u5b8f-1024x396.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u53ef\u4e3b\u673a\u5b8f-768x297.png 768w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u53ef\u4e3b\u673a\u5b8f-1536x594.png 1536w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u53ef\u4e3b\u673a\u5b8f-2048x792.png 2048w\" sizes=\"(max-width: 1070px) 100vw, 1070px\" \/><\/figure><\/div>\n\n\n\n<p>\u7b2c\u4e8c\u6b65\uff0c\u6211\u4eec\u5bfc\u5165\u6a21\u7248 template multi MySQL.xml\u3002<\/p>\n\n\n\n<p><strong>\u6a21\u7248 template multi MySQL.xml \u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/template-multi-MySQL.xml_.zip\">https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/template-multi-MySQL.xml_.zip<\/a><\/strong><\/p>\n\n\n\n<p>\u7531\u4e8e\u7f51\u7ad9\u91cc\u4e0d\u597d\u76f4\u63a5\u653e xml \u6587\u4ef6\uff0c\u6240\u4ee5\u4f60\u4eec\u4e0b\u8f7d\u4e0b\u6765\u662f\u4e2a\u538b\u7f29\u5305\uff0c\u89e3\u538b\u4e00\u4e0b\u5c31\u662f\u6a21\u7248 template multi MySQL.xml\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5728\u5de6\u4fa7\u680f\u201c\u914d\u7f6e-\u6a21\u7248\u201d\u9875\u9762\u7684\u53f3\u4e0a\u89d2\u5bfc\u5165\u6a21\u7248\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u5bfc\u5165\u6a21\u7248.png\" alt=\"\" class=\"wp-image-544\" width=\"695\" height=\"428\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u5bfc\u5165\u6a21\u7248.png 1390w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u5bfc\u5165\u6a21\u7248-300x185.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u5bfc\u5165\u6a21\u7248-1024x631.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u5bfc\u5165\u6a21\u7248-768x473.png 768w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/figure><\/div>\n\n\n\n<p>\u4e4b\u540e\uff0c\u201c\u914d\u7f6e-\u6a21\u7248\u201d\u9875\u9762\u5c31\u4f1a\u51fa\u73b0\u6211\u4eec\u521a\u521a\u5bfc\u5165\u7684\u65b0\u6a21\u7248\u201cTemplate Multi Mysql\u201d\u3002<\/p>\n\n\n\n<p>\u7b2c\u4e09\u6b65\uff0c\u6211\u4eec\u70b9\u8fdb\u53bb\uff0c\u4fee\u6539\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u201cmysql_discovery\u201d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219.png\" alt=\"\" class=\"wp-image-548\" width=\"702\" height=\"428\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219.png 1404w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219-300x183.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219-1024x624.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219-768x468.png 768w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-preformatted\">\u540d\u79f0\uff1amysql_discovery<br>\u7c7b\u578b\uff1aZabbix\u5ba2\u6237\u7aef\uff08\u4e3b\u52a8\u5f0f\uff09<br>\u952e\u503c\uff1amysql_discovery[{#MYSQLPORT}]<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u8bbe\u7f6e.png\" alt=\"\" class=\"wp-image-549\" width=\"708\" height=\"426\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u8bbe\u7f6e.png 1416w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u8bbe\u7f6e-300x181.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u8bbe\u7f6e-1024x616.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u6a21\u7248\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u8bbe\u7f6e-768x462.png 768w\" sizes=\"(max-width: 708px) 100vw, 708px\" \/><\/figure><\/div>\n\n\n\n<p>\u7b2c\u56db\u6b65\uff0c\u7ed9\u88ab\u76d1\u63a7\u7684\u4e3b\u673a\u6dfb\u52a0\u6211\u4eec\u8bbe\u7f6e\u597d\u7684\u6a21\u7248\u201cTemplate Multi Mysql\u201d\u3002<\/p>\n\n\n\n<p>\u5728\u5de6\u4fa7\u680f\u201c\u914d\u7f6e-\u4e3b\u673a\u201d\u9875\u9762\u4e2d\uff0c\u9009\u62e9\u88ab\u76d1\u63a7\u7684\u4e3b\u673a\uff0c\u7136\u540e\u5728\u6a21\u7248\u4e00\u680f\uff0c\u6dfb\u52a0\u65b0\u7684\u6a21\u7248\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u4e3b\u673a\u6dfb\u52a0\u6a21\u7248.png\" alt=\"\" class=\"wp-image-551\" width=\"700\" height=\"427\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u4e3b\u673a\u6dfb\u52a0\u6a21\u7248.png 1400w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u4e3b\u673a\u6dfb\u52a0\u6a21\u7248-300x183.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u4e3b\u673a\u6dfb\u52a0\u6a21\u7248-1024x625.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u4e3b\u673a\u6dfb\u52a0\u6a21\u7248-768x468.png 768w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/figure><\/div>\n\n\n\n<h2>\u7b49\u5f85\u7ed3\u679c<\/h2>\n\n\n\n<p>\u5230\u8fd9\u91cc\u4e3a\u6b62\uff0c\u6240\u6709\u7684\u90e8\u7f72\u548c\u914d\u7f6e\u90fd\u7ed3\u675f\u4e86\u3002\u63a5\u4e0b\u6765\u9700\u8981<strong>\u7b49\u5f85<\/strong>\u4e00\u4f1a\u513f\uff0c\u7b49 Zabbix \u53bb\u6536\u96c6\u6570\u636e\uff0c\u624d\u4f1a\u51fa\u73b0 Mutli Mysql \u5e94\u7528\u96c6\u548c\u8be5\u5e94\u7528\u96c6\u4e2d\u7684\u5404\u79cd\u9009\u9879\u3002\u6574\u4e2a\u7b49\u5f85\u65f6\u95f4\u5927\u6982<strong>\u4e94\u5206\u949f<\/strong>\u5de6\u53f3\u5427\u3002<\/p>\n\n\n\n<h2>\u7ed3\u679c\u5c55\u793a<\/h2>\n\n\n\n<p>\u5de6\u4fa7\u680f\u201c\u914d\u7f6e-\u4e3b\u673a\u201d\u9875\u9762\uff0c\u6307\u5b9a\u4e3b\u673a\uff0c\u7136\u540e\u9009\u62e9\u76d1\u63a7\u9879-\u5e94\u7528\u96c6 Multi Mysql\uff0c\u5c31\u80fd\u770b\u5230\u5df2\u7ecf\u8bbe\u7f6e\u597d\u7684\u76d1\u63a7\u9879\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u914d\u7f6e\u4e2d\u7ed3\u679c.png\" alt=\"\" class=\"wp-image-550\" width=\"974\" height=\"525\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u914d\u7f6e\u4e2d\u7ed3\u679c.png 1948w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u914d\u7f6e\u4e2d\u7ed3\u679c-300x162.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u914d\u7f6e\u4e2d\u7ed3\u679c-1024x552.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u914d\u7f6e\u4e2d\u7ed3\u679c-768x414.png 768w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u914d\u7f6e\u4e2d\u7ed3\u679c-1536x828.png 1536w\" sizes=\"(max-width: 974px) 100vw, 974px\" \/><\/figure><\/div>\n\n\n\n<p>\u5de6\u4fa7\u680f\u201c\u76d1\u89c6-\u6700\u65b0\u6570\u636e\u201d\u9875\u9762\uff0c\u6307\u5b9a\u4e3b\u673a\uff0c\u9009\u62e9\u5e94\u7528\u96c6 Multi Mysql\uff0c\u5c31\u80fd\u770b\u5230\u76d1\u63a7\u5230\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u4e2d\u7ed3\u679c.png\" alt=\"\" class=\"wp-image-546\" width=\"1382\" height=\"488\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u4e2d\u7ed3\u679c.png 2764w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u4e2d\u7ed3\u679c-300x106.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u4e2d\u7ed3\u679c-1024x362.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u4e2d\u7ed3\u679c-768x271.png 768w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u4e2d\u7ed3\u679c-1536x542.png 1536w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u4e2d\u7ed3\u679c-2048x723.png 2048w\" sizes=\"(max-width: 1382px) 100vw, 1382px\" \/><\/figure><\/div>\n\n\n\n<p>\u5982\u679c\u7b49\u4e86\u4e00\u6bb5\u65f6\u95f4\u4e4b\u540e\uff0c\u914d\u7f6e\u91cc\u9762\u8fd8\u662f\u6ca1\u6709\u51fa\u73b0\u5e94\u7528\u96c6 Multi Mysql \u548c\u76f8\u5e94\u7684\u76d1\u63a7\u9879\u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u7740\u624b\u5f00\u59cb\u6392\u67e5\u9519\u8bef\u3002\u6211\u4eec\u5728 Zabbix \u670d\u52a1\u7aef\u673a\u5668\u4e0a\u64cd\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">zabbix_get -s zabbix\u5ba2\u6237\u7aefip -p 10050 -k mysql.test.ping[zabbix\u5ba2\u6237\u7aef\u4e0a\u6570\u636e\u5e93\u7aef\u53e3]<\/pre>\n\n\n\n<p>\u8fd9\u662f\u6d4b\u8bd5 zabbix-server \u80fd\u5426\u8fde\u63a5\u5230 zabbix-agent2 \u7684\u6307\u5b9a\u7aef\u53e3\u6570\u636e\u5e93\u5b9e\u4f8b\u7684\uff0c\u5982\u679c\u8fd4\u56de1\uff0c\u8bf4\u660e\u80fd\u8fde\u4e0a\uff1b\u5982\u679c\u8fd4\u56de0\uff0c\u8bf4\u660e\u6ca1\u8fde\u4e0a\u5ba2\u6237\u7aef\u7aef\u53e3\u6570\u636e\u5e93\u3002<\/p>\n\n\n\n<p>\u90a3\u6211\u4eec\u518d\u53bb\u6d4b\u8bd5\u4e00\u4e0b Zabbix \u5ba2\u6237\u7aef\uff0c\u770b\u770b\u662f\u5ba2\u6237\u7aef\u51fa\u4e86\u95ee\u9898\uff0c\u8fd8\u662f\u670d\u52a1\u7aef\u6709\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5728 Zabbix \u5ba2\u6237\u7aef\u673a\u5668\u4e0a\u64cd\u4f5c\u3002\u5148\u770b\u770b\u662f\u4e0d\u662f\u811a\u672c\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sh \/etc\/zabbix\/bin\/mysql_alive.sh \u5ba2\u6237\u7aef\u4e0a\u6570\u636e\u5e93\u7aef\u53e3<\/pre>\n\n\n\n<p>\u5982\u679c\u8fd4\u56de1\uff0c\u8bf4\u660e\u811a\u672c\u6ca1\u95ee\u9898\uff0c\u95ee\u9898\u4e0d\u5728\u5ba2\u6237\u7aef\u8fd9\u91cc\uff0c\u800c\u662f\u5728\u670d\u52a1\u7aef\u90a3\u91cc\u3002\u5982\u679c\u8fd4\u56de0\uff0c\u90a3\u4e48\u518d\u5f80\u4e0b\u67e5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/usr\/bin\/mysqladmin -uzabbix_monitor -p0 -S \/tmp\/mysql_\u5ba2\u6237\u7aef\u6570\u636e\u5e93\u7aef\u53e3.sock ping|grep -c alive<\/pre>\n\n\n\n<p>\u5982\u679c\u8fd4\u56de1\uff0c\u8bf4\u660e shell \u6307\u4ee4\u672c\u8eab\u6ca1\u95ee\u9898\uff0c\u95ee\u9898\u5728\u4e0a\u9762\u7684\u811a\u672c\u54ea\u91cc\u3002\u5982\u679c\u8fd4\u56de0\uff0c\u6216\u8005\u5176\u4ed6\u5177\u4f53\u7684\u9519\u8bef\uff0c\u5c31\u597d\u597d\u770b\u770b\u9519\u8bef\u539f\u56e0\u3002\u5230\u8fd9\u4e00\u6b65\uff0c\u8bf4\u660e Zabbix \u5ba2\u6237\u7aef\u6240\u5728\u7684\u673a\u5668\u81ea\u5df1\u90fd\u8fde\u63a5\u4e0d\u4e0a\u81ea\u5df1\u7aef\u53e3\u4e0a\u7684 Mysql \u5b9e\u4f8b\u4e86\uff0c\u8fd9\u5c31\u548c Zabbix \u65e0\u5173\u4e86\u3002<\/p>\n\n\n\n<h2>\u624b\u52a8\u6dfb\u52a0\u65b0\u7684Mysql\u76d1\u63a7\u9879<\/h2>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8bb2\u8bb2\u600e\u4e48\u6dfb\u52a0\u65b0\u7684\u5173\u4e8e Mysql \u7684\u81ea\u5b9a\u4e49\u76d1\u63a7\u9879\uff0c\u5c31\u6bd4\u5982 processlist \u548c innodb_trx \u8fd9\u4e24\u4e2a\u76d1\u63a7\u9879\u5176\u5b9e\u662f\u6211\u81ea\u5b9a\u4e49\u7684\u76d1\u63a7\u9879\u3002\u4f60\u4eec\u4e0a\u9762\u4e0b\u8f7d\u5e76\u5bfc\u5165\u7684\u6a21\u7248\u6587\u4ef6 template multi MySQL.xml \u5e76\u4e0d\u5305\u542b\u8fd9\u4e24\u4e2a\u76d1\u63a7\u9879\uff0c\u6240\u4ee5\u9700\u8981\u6211\u4eec\u624b\u52a8\u6dfb\u52a0\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5c31\u5148\u5728 Zabbix \u5ba2\u6237\u7aef\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5148\u5c06 shell \u547d\u4ee4\u5c01\u88c5\u6210\u811a\u672c\u6dfb\u52a0\u5230\u76ee\u5f55 \/etc\/zabbix\/bin \u4e0b\uff0c\u7136\u540e\u53bb\u914d\u7f6e\u6587\u4ef6 \/etc\/zabbix\/etc\/zabbix\/zabbix_agent2.d\/multi_mysql.conf \u4e2d\u6dfb\u52a0\u76f8\u5e94\u7684\u53c2\u6570\u540d\u79f0\u548c\u811a\u672c\u8fd0\u884c\u6307\u4ee4\u3002\u90fd\u4fee\u6539\u5b8c\u522b\u5fd8\u4e86\u91cd\u542f zabbix-agent2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart zabbix-agent2<\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u6211\u4eec\u518d\u5728 Zabbix \u524d\u7aef\u9875\u9762\u4e0a\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u76f4\u63a5\u5728\u201c\u914d\u7f6e-\u6a21\u7248\u201d\u4e2d\u6dfb\u52a0\u65b0\u7684\u76d1\u63a7\u9879\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u81ea\u52a8\u5e94\u7528\u5230\u6240\u6709\u4f7f\u7528\u4e86\u8be5\u6a21\u7248\u7684\u4e3b\u673a\u4e86\u3002\u6211\u4eec\u5728\u5de6\u4fa7\u680f\u201c\u914d\u7f6e-\u6a21\u7248\u201d\u9875\u9762\u9009\u62e9\u6a21\u7248\u201cTemplate Multi Mysql\u201d\uff0c\u7136\u540e\u9009\u62e9\u5b83\u7684\u81ea\u52a8\u53d1\u73b0\u89c4\u5219\u201cmysql_discovery\u201d\u7684\u76d1\u63a7\u9879\u539f\u578b\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u9879\u539f\u578b.png\" alt=\"\" class=\"wp-image-545\" width=\"957\" height=\"479\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u9879\u539f\u578b.png 1914w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u9879\u539f\u578b-300x150.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u9879\u539f\u578b-1024x513.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u9879\u539f\u578b-768x384.png 768w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_\u76d1\u63a7\u9879\u539f\u578b-1536x769.png 1536w\" sizes=\"(max-width: 957px) 100vw, 957px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fdb\u5165\u76d1\u63a7\u9879\u539f\u578b\u754c\u9762\u540e\uff0c\u6211\u4eec\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u521b\u5efa\u76d1\u63a7\u9879\u539f\u578b\uff0c\u7136\u540e\u586b\u5165\u76f8\u5e94\u7684\u81ea\u5b9a\u4e49\u76d1\u63a7\u9879\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u76d1\u63a7\u9879processlist<br>\u540d\u79f0\uff1aMysql On {#MYSQLPORT}  processlist<br>\u7c7b\u578b\uff1aZabbix\u5ba2\u6237\u7aef<br>\u952e\u503c\uff1amysql.test.processlist[{#MYSQLPORT}]<br>\u4fe1\u606f\u7c7b\u578b\uff1a\u6587\u672c<br>\u200b<br># \u76d1\u63a7\u9879innodb_trx<br>\u540d\u79f0\uff1aMysql On {#MYSQLPORT}  innodb_trx<br>\u7c7b\u578b\uff1aZabbix\u5ba2\u6237\u7aef<br>\u952e\u503c\uff1amysql.test.innodb.trx[{#MYSQLPORT}]<br>\u4fe1\u606f\u7c7b\u578b\uff1a\u6587\u672c<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_processlist.png\" alt=\"\" class=\"wp-image-552\" width=\"965\" height=\"485\" srcset=\"https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_processlist.png 1930w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_processlist-300x151.png 300w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_processlist-1024x515.png 1024w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_processlist-768x386.png 768w, https:\/\/twocups.cn\/wp-content\/uploads\/2021\/06\/zabbix\u7b2c\u516d\u7ae0_processlist-1536x772.png 1536w\" sizes=\"(max-width: 965px) 100vw, 965px\" \/><\/figure><\/div>\n\n\n\n<p>\u8fd9\u4e9b\u90fd\u914d\u7f6e\u5b8c\u6210\u4e4b\u540e\uff0c\u7167\u6837\u8fd8\u662f\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\uff0c\u5927\u6982\u4e94\u5206\u949f\u5de6\u53f3\u5c31\u4f1a\u5728\u4f7f\u7528\u4e86\u8be5\u6a21\u7248\u7684\u4e3b\u673a\u4e2d\u51fa\u73b0\u65b0\u7684\u76d1\u63a7\u9879\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3a\u535a\u4e3b\u539f\u521b\u6587\u7ae0\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\uff1ahttps:\/\/twocups.cn\/index.php\/202 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":471,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[99],"tags":[124,121,122],"_links":{"self":[{"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/posts\/561"}],"collection":[{"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/comments?post=561"}],"version-history":[{"count":0,"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/posts\/561\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/media\/471"}],"wp:attachment":[{"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/media?parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/categories?post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/twocups.cn\/index.php\/wp-json\/wp\/v2\/tags?post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}