{"id":114826,"date":"2026-10-10T10:09:24","date_gmt":"2026-10-10T02:09:24","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/114826.html"},"modified":"2026-10-10T10:09:24","modified_gmt":"2026-10-10T02:09:24","slug":"mysqld_exporter%e8%87%aa%e5%8a%a8%e5%8c%96%e7%9b%91%e6%8e%a7%e9%93%be%ef%bc%9ashell%e5%ae%89%e8%a3%85%e3%80%81systemd%e6%89%98%e7%ae%a1%e4%b8%8eprometheus%e6%8a%93%e5%8f%96","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/114826.html","title":{"rendered":"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>mysqld_exporter \u672c\u8eab\u5e76\u4e0d\u96be\u5b89\u88c5&#xff0c;\u771f\u6b63\u5bb9\u6613\u51fa\u95ee\u9898\u7684\u662f\u90e8\u7f72\u6b65\u9aa4\u592a\u5206\u6563&#xff1a;\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001MySQL \u76d1\u63a7\u8d26\u53f7\u3001\u6743\u9650\u3001\u8ba4\u8bc1\u6587\u4ef6\u3001systemd \u670d\u52a1\u548c 9105 \u6307\u6807\u7aef\u53e3\u90fd\u9700\u8981\u9010\u9879\u914d\u7f6e\u3002\u673a\u5668\u4e00\u591a\u4ee5\u540e&#xff0c;\u624b\u5de5\u64cd\u4f5c\u5f88\u5bb9\u6613\u51fa\u73b0\u8def\u5f84\u3001\u8d26\u53f7\u6216\u53c2\u6570\u4e0d\u4e00\u81f4\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u7684\u91cd\u70b9\u5c31\u662f\u628a\u8fd9\u4e9b\u6b65\u9aa4\u6536\u8fdb\u4e00\u4e2a Shell \u811a\u672c\u3002\u811a\u672c\u56fa\u5b9a\u4f7f\u7528 v0.18.0&#xff0c;\u5b89\u88c5\u5230 \/app\/mysqld_exporter&#xff0c;\u81ea\u52a8\u51c6\u5907 prometheus \u7cfb\u7edf\u7528\u6237&#xff0c;\u521b\u5efa MySQL \u76d1\u63a7\u8d26\u53f7&#xff0c;\u751f\u6210 localhost_db.cnf&#xff0c;\u518d\u6ce8\u518c mysqld_exporter.service \u5e76\u901a\u8fc7 systemd \u542f\u52a8\u3002<\/p>\n<p>\u811a\u672c\u6267\u884c\u5b8c\u6210\u540e&#xff0c;\u8fd8\u4f1a\u7ee7\u7eed\u68c0\u67e5\u670d\u52a1\u72b6\u6001&#xff0c;\u5e76\u628a 9105 \u52a0\u5165 Prometheus \u6293\u53d6\u76ee\u6807&#xff0c;\u786e\u8ba4 exporter \u6307\u6807\u5df2\u7ecf\u771f\u6b63\u8fdb\u5165\u76d1\u63a7\u94fe\u8def\u3002<\/p>\n<p>\u5982\u679c Prometheus \u548c MySQL \u4e0d\u5728\u540c\u4e00\u7f51\u7edc&#xff0c;\u518d\u7ee7\u7eed\u5904\u7406\u8fdc\u7a0b\u6293\u53d6&#xff0c;\u8ba9 Prometheus \u901a\u8fc7\u5916\u90e8\u5730\u5740\u8bbf\u95ee\u5185\u7f51\u4e2d\u7684 exporter&#xff0c;\u800c\u4e0d\u662f\u76f4\u63a5\u66b4\u9732\u6570\u636e\u5e93\u672c\u8eab\u3002<\/p>\n<p>\u6574\u7bc7\u91cd\u70b9\u653e\u5728\u201c\u811a\u672c\u6807\u51c6\u5316\u2014\u670d\u52a1\u6258\u7ba1\u2014Prometheus \u6293\u53d6\u2014\u8de8\u7f51\u76d1\u63a7\u201d\u8fd9\u6761\u94fe\u8def&#xff0c;\u800c\u4e0d\u662f\u7b80\u5355\u91cd\u590d\u4e00\u904d\u624b\u5de5\u5b89\u88c5\u6b65\u9aa4\u3002<\/p>\n<p>\u5bf9\u4e8e\u8fd9\u7c7b\u76d1\u63a7\u7ec4\u4ef6&#xff0c;\u81ea\u52a8\u5316\u811a\u672c\u7684\u610f\u4e49\u4e0d\u662f\u7701\u6389\u6240\u6709\u5224\u65ad&#xff0c;\u800c\u662f\u628a\u53ef\u91cd\u590d\u7684\u5b89\u88c5\u52a8\u4f5c\u6807\u51c6\u5316\u3002\u6700\u7ec8\u4ecd\u7136\u8981\u7528 systemd \u72b6\u6001\u548c Prometheus \u6293\u53d6\u7ed3\u679c\u9a8c\u8bc1&#xff0c;\u800c\u4e0d\u662f\u53ea\u770b\u811a\u672c\u662f\u5426\u6267\u884c\u5230\u6700\u540e\u3002\u628a\u90e8\u7f72\u7ed3\u679c\u548c\u76d1\u63a7\u7ed3\u679c\u5206\u5f00\u9a8c\u8bc1&#xff0c;\u540e\u7eed\u6279\u91cf\u94fa\u5f00\u65f6\u4e5f\u66f4\u5bb9\u6613\u5b9a\u4f4d\u95ee\u9898\u3002\u66f4\u7a33\u3002<\/p>\n<h3>1. \u4e3a\u4ec0\u4e48\u6211\u66f4\u613f\u610f\u628a mysqld_exporter \u5199\u6210\u811a\u672c<\/h3>\n<p>\u624b\u5de5\u5b89\u88c5\u4e00\u6b21 mysqld_exporter&#xff0c;\u5176\u5b9e\u4e0d\u7b97\u96be\u3002<\/p>\n<p>\u771f\u6b63\u9ebb\u70e6\u7684\u662f\u540c\u6837\u7684\u4e8b\u60c5\u8981\u91cd\u590d\u5f88\u591a\u6b21&#xff1a;\u4e0b\u8f7d\u3001\u89e3\u538b\u3001\u5efa\u7528\u6237\u3001\u6539\u6743\u9650\u3001\u5199\u8ba4\u8bc1\u6587\u4ef6\u3001\u5199 systemd\u3001\u542f\u52a8\u3001\u8bbe\u5f00\u673a\u81ea\u542f&#xff0c;\u518d\u53bb Prometheus \u91cc\u914d\u7f6e\u6293\u53d6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020918-6ac99e4e449f2.png\" alt=\"image-20260114172313119\" \/><\/p>\n<p>\u673a\u5668\u4e00\u591a\u4ee5\u540e&#xff0c;\u6700\u6015\u7684\u4e0d\u662f\u6162&#xff0c;\u800c\u662f\u4e0d\u4e00\u81f4\u3002<\/p>\n<p>\u8fd9\u53f0\u88c5\u5728 \/app\/mysqld_exporter&#xff0c;\u4e0b\u4e00\u53f0\u8def\u5f84\u6362\u4e86&#xff1b;\u8fd9\u53f0\u7aef\u53e3\u662f 9105&#xff0c;\u53e6\u4e00\u53f0\u914d\u7f6e\u6587\u4ef6\u53c8\u653e\u5230\u4e86\u522b\u5904\u3002\u7b49\u540e\u9762\u6279\u91cf\u7ef4\u62a4\u65f6&#xff0c;\u8fd9\u4e9b\u5c0f\u5dee\u5f02\u6700\u5bb9\u6613\u53d8\u6210\u6392\u9519\u6210\u672c\u3002<\/p>\n<p>\u6240\u4ee5\u8fd9\u7bc7\u7684\u6838\u5fc3\u601d\u8def\u5c31\u662f&#xff1a;\u628a\u8def\u5f84\u3001\u8d26\u53f7\u3001\u7aef\u53e3\u3001\u6743\u9650\u548c\u670d\u52a1\u6ce8\u518c\u4e00\u6b21\u5199\u8fdb\u811a\u672c&#xff0c;\u540e\u9762\u91cd\u590d\u6267\u884c\u3002<\/p>\n<h3>2. \u8fd9\u4efd\u811a\u672c\u51c6\u5907\u81ea\u52a8\u5b8c\u6210\u4ec0\u4e48<\/h3>\n<p>\u73b0\u6709\u6d41\u7a0b\u628a\u90e8\u7f72\u62c6\u6210\u4e94\u4ef6\u4e8b&#xff1a;<\/p>\n<li>\u521b\u5efa MySQL \u4e13\u7528\u76d1\u63a7\u7528\u6237&#xff1b;<\/li>\n<li>\u4e0b\u8f7d\u5e76\u89e3\u538b mysqld_exporter&#xff1b;<\/li>\n<li>\u751f\u6210\u6570\u636e\u5e93\u8ba4\u8bc1\u6587\u4ef6&#xff1b;<\/li>\n<li>\u521b\u5efa systemd \u670d\u52a1&#xff1b;<\/li>\n<li>\u542f\u52a8\u670d\u52a1\u5e76\u63d0\u4f9b\u6307\u6807\u5730\u5740\u3002<\/li>\n<p>\u811a\u672c\u91cc\u8fd8\u56fa\u5b9a\u4e86\u51e0\u4e2a\u5173\u952e\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>\u7248\u672c&#xff1a;v0.18.0<\/li>\n<li>\u5b89\u88c5\u76ee\u5f55&#xff1a;\/app\/mysqld_exporter<\/li>\n<li>\u6307\u6807\u7aef\u53e3&#xff1a;9105<\/li>\n<li>\u670d\u52a1\u7528\u6237&#xff1a;prometheus<\/li>\n<li>MySQL \u76d1\u63a7\u7528\u6237&#xff1a;mysqld_exporter<\/li>\n<\/ul>\n<p>\u8fd9\u6837\u505a\u7684\u610f\u4e49\u4e0d\u53ea\u662f\u201c\u5c11\u6572\u51e0\u6761\u547d\u4ee4\u201d&#xff0c;\u66f4\u91cd\u8981\u7684\u662f\u8ba9\u6bcf\u53f0\u673a\u5668\u7684\u5b89\u88c5\u7ed3\u6784\u5c3d\u91cf\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<h3>3. \u5148\u770b\u5b8c\u6574 Shell \u811a\u672c<\/h3>\n<p>\u5b8c\u6574\u811a\u672c\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u4e00\u952e\u5b89\u88c5 mysqld_exporter for CentOS 7<\/span><br \/>\n<span class=\"token comment\"># \u4f7f\u7528\u56fa\u5b9a MySQL root\u5bc6\u7801\u81ea\u52a8\u5efa\u7528\u6237<\/span><br \/>\n<span class=\"token comment\"># \u76d1\u63a7\u7528\u6237: mysqld_exporter \/ Sjixin520!<\/span><\/p>\n<p><span class=\"token builtin class-name\">set<\/span> <span class=\"token parameter variable\">-e<\/span><\/p>\n<p><span class=\"token assign-left variable\">VERSION<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;v0.18.0&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">INSTALL_DIR<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\/app\/mysqld_exporter&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">PORT<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;9105&#034;<\/span><\/p>\n<p><span class=\"token assign-left variable\">MYSQL_ROOT_USER<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;root&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">MYSQL_ROOT_PASS<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;Sjixin52!&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">EXPORTER_USER<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;mysqld_exporter&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">EXPORTER_PASS<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;Sjixin52!&#034;<\/span><\/p>\n<p><span class=\"token assign-left variable\">RED<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\\\\033[0;31m&#039;<\/span><br \/>\n<span class=\"token assign-left variable\">GREEN<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\\\\033[0;32m&#039;<\/span><br \/>\n<span class=\"token assign-left variable\">NC<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\\\\033[0m&#039;<\/span><\/p>\n<p><span class=\"token function-name function\">log<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token parameter variable\">-e<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">${GREEN}<\/span>[INFO]<span class=\"token variable\">${NC}<\/span> <span class=\"token variable\">$1<\/span>&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function-name function\">error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token parameter variable\">-e<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">${RED}<\/span>[ERROR]<span class=\"token variable\">${NC}<\/span> <span class=\"token variable\">$1<\/span>&#034;<\/span> <span class=\"token operator\">&gt;<\/span><span class=\"token file-descriptor important\">&amp;2<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token builtin class-name\">exit<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token string\">&#034;<span class=\"token environment constant\">$EUID<\/span>&#034;<\/span> <span class=\"token parameter variable\">-ne<\/span> <span class=\"token number\">0<\/span> <span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n    error <span class=\"token string\">&#034;\u8bf7\u4ee5 root \u7528\u6237\u8fd0\u884c\u6b64\u811a\u672c&#xff01;&#034;<\/span><br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5\u4f9d\u8d56<\/span><br \/>\nlog <span class=\"token string\">&#034;\u5b89\u88c5\u5fc5\u8981\u5de5\u5177&#8230;&#034;<\/span><br \/>\nyum <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> <span class=\"token function\">wget<\/span> <span class=\"token function\">tar<\/span> <span class=\"token operator\">&amp;&gt;<\/span>\/dev\/null<\/p>\n<p><span class=\"token comment\"># \u4e0b\u8f7dmysqld_exporter<\/span><br \/>\n<span class=\"token assign-left variable\">URL<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;https:\/\/github.com\/prometheus\/mysqld_exporter\/releases\/download\/<span class=\"token variable\">${VERSION}<\/span>\/mysqld_exporter-<span class=\"token variable\">${VERSION<span class=\"token operator\">#<\/span>v}<\/span>.linux-amd64.tar.gz&#034;<\/span><br \/>\nlog <span class=\"token string\">&#034;\u6b63\u5728\u4e0b\u8f7dmysqld_exporter <span class=\"token variable\">${VERSION}<\/span> &#8230;&#034;<\/span><br \/>\n<span class=\"token function\">wget<\/span> <span class=\"token parameter variable\">-O<\/span> \/tmp\/mysqld_exporter.tar.gz <span class=\"token string\">&#034;<span class=\"token variable\">$URL<\/span>&#034;<\/span> <span class=\"token operator\">||<\/span> error <span class=\"token string\">&#034;\u4e0b\u8f7d\u5931\u8d25&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u89e3\u538b\u5230\/app\/mysqld_exporter<\/span><br \/>\n<span class=\"token function\">mkdir<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>&#034;<\/span><br \/>\n<span class=\"token function\">tar<\/span> <span class=\"token parameter variable\">-zxvf<\/span> \/tmp\/mysqld_exporter.tar.gz <span class=\"token parameter variable\">-C<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>&#034;<\/span> &#8211;strip-components<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token function\">chown<\/span> <span class=\"token parameter variable\">-R<\/span> root:root <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u786e\u4fddprometheus\u7528\u6237\u5b58\u5728<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token operator\">!<\/span> <span class=\"token function\">id<\/span> <span class=\"token string\">&#034;prometheus&#034;<\/span> <span class=\"token operator\">&amp;&gt;<\/span>\/dev\/null<span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n    log <span class=\"token string\">&#034;\u521b\u5efaprometheus\u7cfb\u7edf\u7528\u6237&#8230;&#034;<\/span><br \/>\n    <span class=\"token function\">useradd<\/span> <span class=\"token parameter variable\">&#8211;system<\/span> <span class=\"token parameter variable\">&#8211;shell<\/span> \/sbin\/nologin &#8211;no-create-home prometheus<br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u81ea\u52a8\u521b\u5efaMySQL\u76d1\u63a7\u7528\u6237<\/span><br \/>\nlog <span class=\"token string\">&#034;\u6b63\u5728\u8fde\u63a5MySQL\u5e76\u521b\u5efa\u76d1\u63a7\u7528\u6237 &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039; &#8230;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u6d4b\u8bd5root\u767b\u5f55\u662f\u5426\u6210\u529f<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token operator\">!<\/span> mysql -u<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_USER<\/span>&#034;<\/span> -p<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_PASS<\/span>&#034;<\/span> <span class=\"token parameter variable\">-e<\/span> <span class=\"token string\">&#034;SELECT 1;&#034;<\/span> <span class=\"token operator\">&gt;<\/span>\/dev\/null <span class=\"token operator\"><span class=\"token file-descriptor important\">2<\/span>&gt;<\/span><span class=\"token file-descriptor important\">&amp;1<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n    error <span class=\"token string\">&#034;\u65e0\u6cd5\u4f7f\u7528root \/ Sjixin52! \u767b\u5f55MySQL&#xff0c;\u8bf7\u786e\u8ba4MySQL\u6b63\u5728\u8fd0\u884c\u4e14\u5bc6\u7801\u6b63\u786e&#034;<\/span><br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efaexporter\u7528\u6237<\/span><br \/>\nmysql -u<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_USER<\/span>&#034;<\/span> -p<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_PASS<\/span>&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">SQL<br \/>\nCREATE USER IF NOT EXISTS &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039;&#064;&#039;localhost&#039; IDENTIFIED BY &#039;<span class=\"token variable\">$EXPORTER_PASS<\/span>&#039;;<br \/>\nGRANT REPLICATION CLIENT, PROCESS ON *.* TO &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039;&#064;&#039;localhost&#039;;<br \/>\nGRANT SELECT ON performance_schema.* TO &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039;&#064;&#039;localhost&#039;;<br \/>\nFLUSH PRIVILEGES;<br \/>\nSQL<\/span><\/p>\n<p>log <span class=\"token string\">&#034;MySQL\u76d1\u63a7\u7528\u6237\u521b\u5efa\u6210\u529f&#xff01;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efa.my.cnf\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">EOF<br \/>\n[client]<br \/>\nuser&#061;<span class=\"token variable\">$EXPORTER_USER<\/span><br \/>\npassword&#061;<span class=\"token variable\">$EXPORTER_PASS<\/span><br \/>\nhost&#061;localhost<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token function\">chmod<\/span> <span class=\"token number\">600<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf&#034;<\/span><br \/>\n<span class=\"token function\">chown<\/span> prometheus:prometheus <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efasystemd\u670d\u52a1<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&gt;<\/span> \/etc\/systemd\/system\/mysqld_exporter.service <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">EOF<br \/>\n[Unit]<br \/>\nDescription&#061;MySQL Exporter<br \/>\nAfter&#061;network.target<\/p>\n<p>[Service]<br \/>\nType&#061;simple<br \/>\nUser&#061;prometheus<br \/>\nExecStart&#061;<span class=\"token variable\">$INSTALL_DIR<\/span>\/mysqld_exporter <span class=\"token entity\" title=\"\\\\\\\\\">\\\\\\\\<\/span><br \/>\n    &#8211;config.my-cnf&#061;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf <span class=\"token entity\" title=\"\\\\\\\\\">\\\\\\\\<\/span><br \/>\n    &#8211;web.listen-address&#061;:9105<br \/>\nRestart&#061;on-failure<br \/>\nRestartSec&#061;10<br \/>\nStandardOutput&#061;journal<br \/>\nStandardError&#061;journal<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token comment\"># \u542f\u52a8\u670d\u52a1<\/span><br \/>\nlog <span class=\"token string\">&#034;\u542f\u52a8 mysqld_exporter \u670d\u52a1&#8230;&#034;<\/span><br \/>\nsystemctl daemon-reload<br \/>\nsystemctl <span class=\"token builtin class-name\">enable<\/span> <span class=\"token parameter variable\">&#8211;now<\/span> mysqld_exporter<\/p>\n<p>log <span class=\"token string\">&#034;\u2705 \u5b89\u88c5\u5b8c\u6210&#xff01;&#034;<\/span><br \/>\nlog <span class=\"token string\">&#034;\u6307\u6807\u5730\u5740: http:\/\/<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">hostname<\/span> <span class=\"token parameter variable\">-I<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">awk<\/span> <span class=\"token string\">&#039;{print $1}&#039;<\/span><span class=\"token variable\">)<\/span><\/span>:<span class=\"token variable\">${PORT}<\/span>\/metrics&#034;<\/span><br \/>\nlog <span class=\"token string\">&#034;\u670d\u52a1\u72b6\u6001: systemctl status mysqld_exporter&#034;<\/span><\/p>\n<p>\u8fd9\u4efd\u811a\u672c\u91cc\u51e0\u4e2a\u5173\u952e\u52a8\u4f5c\u503c\u5f97\u5355\u72ec\u770b\u4e00\u4e0b\u3002<\/p>\n<h4>3.1 \u5148\u68c0\u67e5 root \u6743\u9650<\/h4>\n<p>\u811a\u672c\u4f1a\u68c0\u67e5\u5f53\u524d\u662f\u5426\u4ee5 root \u8eab\u4efd\u8fd0\u884c\u3002<\/p>\n<p>\u5982\u679c\u4e0d\u662f root&#xff0c;\u5c31\u76f4\u63a5\u9000\u51fa&#xff0c;\u4e0d\u7ee7\u7eed\u5f80\u4e0b\u6267\u884c\u3002<\/p>\n<h4>3.2 \u81ea\u52a8\u5b89\u88c5\u57fa\u7840\u5de5\u5177<\/h4>\n<p>\u811a\u672c\u4f7f\u7528 yum \u5b89\u88c5 wget \u548c tar&#xff0c;\u907f\u514d\u540e\u9762\u4e0b\u8f7d\u3001\u89e3\u538b\u9636\u6bb5\u624d\u53d1\u73b0\u57fa\u7840\u547d\u4ee4\u4e0d\u5b58\u5728\u3002<\/p>\n<h4>3.3 \u81ea\u52a8\u4e0b\u8f7d\u6307\u5b9a\u7248\u672c<\/h4>\n<p>\u4e0b\u8f7d\u5730\u5740\u6839\u636e&#xff1a;<\/p>\n<p>VERSION&#061;&#034;v0.18.0&#034;<\/p>\n<p>\u81ea\u52a8\u62fc\u63a5\u3002<\/p>\n<p>\u4e8c\u8fdb\u5236\u6587\u4ef6\u6700\u7ec8\u653e\u5230&#xff1a;<\/p>\n<p>\/app\/mysqld_exporter<\/p>\n<p>\u8fd9\u6837\u540e\u9762 systemd \u548c\u914d\u7f6e\u6587\u4ef6\u90fd\u80fd\u7ee7\u7eed\u5f15\u7528\u540c\u4e00\u5957\u56fa\u5b9a\u8def\u5f84\u3002<\/p>\n<h4>3.4 \u81ea\u52a8\u51c6\u5907 prometheus \u7528\u6237<\/h4>\n<p>\u5982\u679c\u7cfb\u7edf\u4e2d\u6ca1\u6709 prometheus \u7528\u6237&#xff0c;\u811a\u672c\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\u4e0d\u80fd\u767b\u5f55\u7684\u7cfb\u7edf\u7528\u6237\u3002<\/p>\n<p>mysqld_exporter \u6700\u7ec8\u4e5f\u901a\u8fc7\u8fd9\u4e2a\u7528\u6237\u8fd0\u884c&#xff0c;\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528 root\u3002<\/p>\n<h4>3.5 \u81ea\u52a8\u521b\u5efa MySQL \u76d1\u63a7\u8d26\u53f7<\/h4>\n<p>\u811a\u672c\u4f1a\u5148\u6d4b\u8bd5 MySQL root \u767b\u5f55&#xff0c;\u7136\u540e\u521b\u5efa&#xff1a;<\/p>\n<p>mysqld_exporter&#064;localhost<\/p>\n<p>\u5e76\u6388\u4e88\u5f53\u524d\u811a\u672c\u91cc\u5b9a\u4e49\u7684\u76d1\u63a7\u6743\u9650\u3002<\/p>\n<p>\u8fd9\u4e00\u6b65\u5982\u679c\u5931\u8d25&#xff0c;\u811a\u672c\u4f1a\u76f4\u63a5\u505c\u6b62&#xff0c;\u4e0d\u7ee7\u7eed\u521b\u5efa\u540e\u9762\u7684\u670d\u52a1\u3002<\/p>\n<h4>3.6 \u81ea\u52a8\u751f\u6210\u8ba4\u8bc1\u6587\u4ef6<\/h4>\n<p>\u8ba4\u8bc1\u6587\u4ef6\u4fdd\u5b58\u4e3a&#xff1a;<\/p>\n<p>\/app\/mysqld_exporter\/localhost_db.cnf<\/p>\n<p>\u91cc\u9762\u5305\u542b [client]\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u548c localhost\u3002<\/p>\n<p>\u811a\u672c\u968f\u540e\u628a\u6743\u9650\u8bbe\u4e3a 600&#xff0c;\u5e76\u628a\u6587\u4ef6\u5c5e\u4e3b\u6539\u6210 prometheus\u3002<\/p>\n<h4>3.7 \u81ea\u52a8\u6ce8\u518c systemd<\/h4>\n<p>\u670d\u52a1\u6587\u4ef6\u5199\u5165&#xff1a;<\/p>\n<p>\/etc\/systemd\/system\/mysqld_exporter.service<\/p>\n<p>\u542f\u52a8\u53c2\u6570\u91cc\u6307\u5b9a\u8ba4\u8bc1\u6587\u4ef6\u548c 9105 \u76d1\u542c\u7aef\u53e3\u3002<\/p>\n<p>\u6700\u540e\u6267\u884c systemctl daemon-reload \u548c systemctl enable &#8211;now mysqld_exporter\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u5b89\u88c5\u3001\u542f\u52a8\u548c\u5f00\u673a\u81ea\u542f\u4e00\u6b21\u5b8c\u6210\u3002<\/p>\n<h3>4. \u628a\u811a\u672c\u4fdd\u5b58\u4e0b\u6765\u5e76\u5b9e\u9645\u6267\u884c<\/h3>\n<p>\u5148\u521b\u5efa\u811a\u672c\u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token function\">vi<\/span> mysql_exporter.sh<\/p>\n<p>\u7136\u540e\u628a\u5b8c\u6574\u5185\u5bb9\u5199\u8fdb\u53bb&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u4e00\u952e\u5b89\u88c5 mysqld_exporter for CentOS 7<\/span><br \/>\n<span class=\"token comment\"># \u4f7f\u7528\u56fa\u5b9a MySQL root\u5bc6\u7801\u81ea\u52a8\u5efa\u7528\u6237<\/span><br \/>\n<span class=\"token comment\"># \u76d1\u63a7\u7528\u6237: mysqld_exporter \/ Sjixin520!<\/span><\/p>\n<p><span class=\"token builtin class-name\">set<\/span> <span class=\"token parameter variable\">-e<\/span><\/p>\n<p><span class=\"token assign-left variable\">VERSION<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;v0.18.0&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">INSTALL_DIR<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\/app\/mysqld_exporter&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">PORT<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;9105&#034;<\/span><\/p>\n<p><span class=\"token assign-left variable\">MYSQL_ROOT_USER<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;root&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">MYSQL_ROOT_PASS<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;Sjixin52!&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">EXPORTER_USER<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;mysqld_exporter&#034;<\/span><br \/>\n<span class=\"token assign-left variable\">EXPORTER_PASS<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;Sjixin52!&#034;<\/span><\/p>\n<p><span class=\"token assign-left variable\">RED<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\\\\033[0;31m&#039;<\/span><br \/>\n<span class=\"token assign-left variable\">GREEN<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\\\\033[0;32m&#039;<\/span><br \/>\n<span class=\"token assign-left variable\">NC<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;\\\\033[0m&#039;<\/span><\/p>\n<p><span class=\"token function-name function\">log<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token parameter variable\">-e<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">${GREEN}<\/span>[INFO]<span class=\"token variable\">${NC}<\/span> <span class=\"token variable\">$1<\/span>&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function-name function\">error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token builtin class-name\">echo<\/span> <span class=\"token parameter variable\">-e<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">${RED}<\/span>[ERROR]<span class=\"token variable\">${NC}<\/span> <span class=\"token variable\">$1<\/span>&#034;<\/span> <span class=\"token operator\">&gt;<\/span><span class=\"token file-descriptor important\">&amp;2<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token builtin class-name\">exit<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token string\">&#034;<span class=\"token environment constant\">$EUID<\/span>&#034;<\/span> <span class=\"token parameter variable\">-ne<\/span> <span class=\"token number\">0<\/span> <span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n    error <span class=\"token string\">&#034;\u8bf7\u4ee5 root \u7528\u6237\u8fd0\u884c\u6b64\u811a\u672c&#xff01;&#034;<\/span><br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5\u4f9d\u8d56<\/span><br \/>\nlog <span class=\"token string\">&#034;\u5b89\u88c5\u5fc5\u8981\u5de5\u5177&#8230;&#034;<\/span><br \/>\nyum <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> <span class=\"token function\">wget<\/span> <span class=\"token function\">tar<\/span> <span class=\"token operator\">&amp;&gt;<\/span>\/dev\/null<\/p>\n<p><span class=\"token comment\"># \u4e0b\u8f7dmysqld_exporter<\/span><br \/>\n<span class=\"token assign-left variable\">URL<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;https:\/\/github.com\/prometheus\/mysqld_exporter\/releases\/download\/<span class=\"token variable\">${VERSION}<\/span>\/mysqld_exporter-<span class=\"token variable\">${VERSION<span class=\"token operator\">#<\/span>v}<\/span>.linux-amd64.tar.gz&#034;<\/span><br \/>\nlog <span class=\"token string\">&#034;\u6b63\u5728\u4e0b\u8f7dmysqld_exporter <span class=\"token variable\">${VERSION}<\/span> &#8230;&#034;<\/span><br \/>\n<span class=\"token function\">wget<\/span> <span class=\"token parameter variable\">-O<\/span> \/tmp\/mysqld_exporter.tar.gz <span class=\"token string\">&#034;<span class=\"token variable\">$URL<\/span>&#034;<\/span> <span class=\"token operator\">||<\/span> error <span class=\"token string\">&#034;\u4e0b\u8f7d\u5931\u8d25&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u89e3\u538b\u5230\/app\/mysqld_exporter<\/span><br \/>\n<span class=\"token function\">mkdir<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>&#034;<\/span><br \/>\n<span class=\"token function\">tar<\/span> <span class=\"token parameter variable\">-zxvf<\/span> \/tmp\/mysqld_exporter.tar.gz <span class=\"token parameter variable\">-C<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>&#034;<\/span> &#8211;strip-components<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token function\">chown<\/span> <span class=\"token parameter variable\">-R<\/span> root:root <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u786e\u4fddprometheus\u7528\u6237\u5b58\u5728<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token operator\">!<\/span> <span class=\"token function\">id<\/span> <span class=\"token string\">&#034;prometheus&#034;<\/span> <span class=\"token operator\">&amp;&gt;<\/span>\/dev\/null<span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n    log <span class=\"token string\">&#034;\u521b\u5efaprometheus\u7cfb\u7edf\u7528\u6237&#8230;&#034;<\/span><br \/>\n    <span class=\"token function\">useradd<\/span> <span class=\"token parameter variable\">&#8211;system<\/span> <span class=\"token parameter variable\">&#8211;shell<\/span> \/sbin\/nologin &#8211;no-create-home prometheus<br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u81ea\u52a8\u521b\u5efaMySQL\u76d1\u63a7\u7528\u6237<\/span><br \/>\nlog <span class=\"token string\">&#034;\u6b63\u5728\u8fde\u63a5MySQL\u5e76\u521b\u5efa\u76d1\u63a7\u7528\u6237 &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039; &#8230;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u6d4b\u8bd5root\u767b\u5f55\u662f\u5426\u6210\u529f<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token operator\">!<\/span> mysql -u<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_USER<\/span>&#034;<\/span> -p<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_PASS<\/span>&#034;<\/span> <span class=\"token parameter variable\">-e<\/span> <span class=\"token string\">&#034;SELECT 1;&#034;<\/span> <span class=\"token operator\">&gt;<\/span>\/dev\/null <span class=\"token operator\"><span class=\"token file-descriptor important\">2<\/span>&gt;<\/span><span class=\"token file-descriptor important\">&amp;1<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">then<\/span><br \/>\n    error <span class=\"token string\">&#034;\u65e0\u6cd5\u4f7f\u7528root \/ Sjixin52! \u767b\u5f55MySQL&#xff0c;\u8bf7\u786e\u8ba4MySQL\u6b63\u5728\u8fd0\u884c\u4e14\u5bc6\u7801\u6b63\u786e&#034;<\/span><br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efaexporter\u7528\u6237<\/span><br \/>\nmysql -u<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_USER<\/span>&#034;<\/span> -p<span class=\"token string\">&#034;<span class=\"token variable\">$MYSQL_ROOT_PASS<\/span>&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">SQL<br \/>\nCREATE USER IF NOT EXISTS &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039;&#064;&#039;localhost&#039; IDENTIFIED BY &#039;<span class=\"token variable\">$EXPORTER_PASS<\/span>&#039;;<br \/>\nGRANT REPLICATION CLIENT, PROCESS ON *.* TO &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039;&#064;&#039;localhost&#039;;<br \/>\nGRANT SELECT ON performance_schema.* TO &#039;<span class=\"token variable\">$EXPORTER_USER<\/span>&#039;&#064;&#039;localhost&#039;;<br \/>\nFLUSH PRIVILEGES;<br \/>\nSQL<\/span><\/p>\n<p>log <span class=\"token string\">&#034;MySQL\u76d1\u63a7\u7528\u6237\u521b\u5efa\u6210\u529f&#xff01;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efa.my.cnf\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf&#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">EOF<br \/>\n[client]<br \/>\nuser&#061;<span class=\"token variable\">$EXPORTER_USER<\/span><br \/>\npassword&#061;<span class=\"token variable\">$EXPORTER_PASS<\/span><br \/>\nhost&#061;localhost<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token function\">chmod<\/span> <span class=\"token number\">600<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf&#034;<\/span><br \/>\n<span class=\"token function\">chown<\/span> prometheus:prometheus <span class=\"token string\">&#034;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efasystemd\u670d\u52a1<\/span><br \/>\n<span class=\"token function\">cat<\/span> <span class=\"token operator\">&gt;<\/span> \/etc\/systemd\/system\/mysqld_exporter.service <span class=\"token operator\">&lt;&lt;<\/span><span class=\"token string\">EOF<br \/>\n[Unit]<br \/>\nDescription&#061;MySQL Exporter<br \/>\nAfter&#061;network.target<\/p>\n<p>[Service]<br \/>\nType&#061;simple<br \/>\nUser&#061;prometheus<br \/>\nExecStart&#061;<span class=\"token variable\">$INSTALL_DIR<\/span>\/mysqld_exporter <span class=\"token entity\" title=\"\\\\\\\\\">\\\\\\\\<\/span><br \/>\n    &#8211;config.my-cnf&#061;<span class=\"token variable\">$INSTALL_DIR<\/span>\/localhost_db.cnf <span class=\"token entity\" title=\"\\\\\\\\\">\\\\\\\\<\/span><br \/>\n    &#8211;web.listen-address&#061;:9105<br \/>\nRestart&#061;on-failure<br \/>\nRestartSec&#061;10<br \/>\nStandardOutput&#061;journal<br \/>\nStandardError&#061;journal<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target<br \/>\nEOF<\/span><\/p>\n<p><span class=\"token comment\"># \u542f\u52a8\u670d\u52a1<\/span><br \/>\nlog <span class=\"token string\">&#034;\u542f\u52a8 mysqld_exporter \u670d\u52a1&#8230;&#034;<\/span><br \/>\nsystemctl daemon-reload<br \/>\nsystemctl <span class=\"token builtin class-name\">enable<\/span> <span class=\"token parameter variable\">&#8211;now<\/span> mysqld_exporter<\/p>\n<p>log <span class=\"token string\">&#034;\u2705 \u5b89\u88c5\u5b8c\u6210&#xff01;&#034;<\/span><br \/>\nlog <span class=\"token string\">&#034;\u6307\u6807\u5730\u5740: http:\/\/<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">hostname<\/span> <span class=\"token parameter variable\">-I<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">awk<\/span> <span class=\"token string\">&#039;{print $1}&#039;<\/span><span class=\"token variable\">)<\/span><\/span>:<span class=\"token variable\">${PORT}<\/span>\/metrics&#034;<\/span><br \/>\nlog <span class=\"token string\">&#034;\u670d\u52a1\u72b6\u6001: systemctl status mysqld_exporter&#034;<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020919-6ac99e4f15ad8.png\" alt=\"8c2d5c1922260fb9743f2a1e23afffc7\" \/><\/p>\n<p>\u4fdd\u5b58\u4ee5\u540e\u76f4\u63a5\u6267\u884c&#xff1a;<\/p>\n<p><span class=\"token function\">sh<\/span> mysql_exporter.sh<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020919-6ac99e4f754e6.png\" alt=\"623449c6efa42fc2459e175cb3509812\" \/><\/p>\n<p>\u8fd9\u91cc\u6211\u66f4\u5173\u5fc3\u7684\u4e0d\u662f\u7ec8\u7aef\u91cc\u6709\u6ca1\u6709\u51fa\u73b0\u201c\u5b89\u88c5\u5b8c\u6210\u201d&#xff0c;\u800c\u662f\u670d\u52a1\u662f\u4e0d\u662f\u5df2\u7ecf\u771f\u7684\u88ab systemd \u63a5\u7ba1\u3002<\/p>\n<p>\u6240\u4ee5\u7ee7\u7eed\u68c0\u67e5&#xff1a;<\/p>\n<p>systemctl status mysqld_exporter<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020919-6ac99e4fe5cbe.png\" alt=\"02f1d5357ec20d6667854d1cc18d1960\" \/><\/p>\n<p>\u670d\u52a1\u72b6\u6001\u6b63\u5e38\u4ee5\u540e&#xff0c;\u624d\u8bf4\u660e\u8fd9\u4efd\u81ea\u52a8\u5316\u811a\u672c\u771f\u6b63\u628a\u4e0b\u8f7d\u3001\u8d26\u53f7\u3001\u914d\u7f6e\u548c\u670d\u52a1\u6ce8\u518c\u8fd9\u4e00\u6574\u6761\u94fe\u8dd1\u901a\u4e86\u3002<\/p>\n<h3>5. \u63a5\u5165 Prometheus<\/h3>\n<p>mysqld_exporter \u672c\u8eab\u53ea\u662f\u66b4\u9732\u6307\u6807\u3002<\/p>\n<p>\u771f\u6b63\u8fdb\u5165\u76d1\u63a7\u4f53\u7cfb&#xff0c;\u8fd8\u9700\u8981 Prometheus \u53bb\u6293\u5b83\u3002<\/p>\n<p>\u7f16\u8f91 Prometheus \u914d\u7f6e&#xff1a;<\/p>\n<p><span class=\"token function\">vi<\/span> prometheus.yml<\/p>\n<p>\u52a0\u5165\u5f53\u524d\u793a\u4f8b\u91cc\u7684\u6293\u53d6\u76ee\u6807&#xff1a;<\/p>\n<p>      &#8211; targets: <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;192.168.42.146:9105&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n        labels:<br \/>\n          app: <span class=\"token string\">&#034;mysql_exporter&#034;<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020920-6ac99e50411ae.png\" alt=\"image-20260116144251013\" \/><\/p>\n<p>\u8fd9\u91cc\u7684 exporter \u5730\u5740\u662f&#xff1a;<\/p>\n<p>192.168.42.146:9105<\/p>\n<p>\u914d\u7f6e\u5b8c\u6210\u4ee5\u540e&#xff0c;\u4ece\u6d4f\u89c8\u5668\u6253\u5f00 Prometheus \u9875\u9762&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020920-6ac99e506a1e3.png\" alt=\"image-20260116145725079\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230 Prometheus \u5df2\u7ecf\u6293\u53d6\u5230\u8fd9\u53f0\u4e3b\u673a\u4e0a\u7684 mysqld_exporter\u3002<\/p>\n<p>\u505a\u5230\u8fd9\u91cc&#xff0c;\u7b2c\u4e00\u6761\u5b8c\u6574\u94fe\u8def\u6210\u7acb&#xff1a;<\/p>\n<p>MySQL \u2192 mysqld_exporter \u2192 9105 \u2192 Prometheus\u3002<\/p>\n<h3>6. \u5982\u679c Prometheus \u548c MySQL \u4e0d\u5728\u540c\u4e00\u4e2a\u7f51\u7edc<\/h3>\n<p>\u540c\u4e00\u4e2a\u5c40\u57df\u7f51\u91cc&#xff0c;Prometheus \u76f4\u63a5\u6293 IP:9105 \u6700\u7b80\u5355\u3002<\/p>\n<p>\u4f46\u5982\u679c Prometheus \u5728\u53e6\u4e00\u5f20\u7f51\u7edc\u91cc&#xff0c;\u800c mysqld_exporter \u8dd1\u5728\u5185\u7f51\u4e3b\u673a\u4e0a&#xff0c;\u5185\u7f51\u5730\u5740\u5c31\u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u3002<\/p>\n<p>\u8fd9\u91cc\u8981\u89e3\u51b3\u7684\u662f Prometheus \u5230 exporter \u7684\u7f51\u7edc\u53ef\u8fbe\u6027&#xff0c;\u800c\u4e0d\u662f\u8ba9 Prometheus \u76f4\u63a5\u8fde\u63a5 MySQL \u6570\u636e\u5e93\u3002<\/p>\n<p>\u540e\u9762\u7684\u65b9\u6848\u662f\u628a\u5df2\u7ecf\u8fd0\u884c\u5728 9105 \u7684\u6307\u6807\u670d\u52a1\u63d0\u4f9b\u4e00\u4e2a\u5916\u90e8\u5165\u53e3\u3002<\/p>\n<h3>7. \u5b89\u88c5 cpolar<\/h3>\n<p>\u6267\u884c\u5b89\u88c5&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">curl<\/span> https:\/\/get.cpolar.sh <span class=\"token operator\">|<\/span> <span class=\"token function\">sh<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020920-6ac99e50ed3d9.png\" alt=\"image-20250814101639846\" \/><\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u4ee5\u540e\u68c0\u67e5\u670d\u52a1\u72b6\u6001&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> systemctl status cpolar<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020921-6ac99e51061f3.png\" alt=\"22e5adfaf290a17fc3384bb296055259\" \/><\/p>\n<p>\u7136\u540e\u901a\u8fc7 9200 \u7aef\u53e3\u8fdb\u5165 Web \u7ba1\u7406\u754c\u9762&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020921-6ac99e511deb1.png\" alt=\"8a6698b1bf26d64ba3645827fbfb1c29\" \/><\/p>\n<p>\u5230\u8fd9\u91cc&#xff0c;\u8fdc\u7a0b\u7f51\u7edc\u5165\u53e3\u5de5\u5177\u5df2\u7ecf\u51c6\u5907\u5b8c\u6210\u3002<\/p>\n<h3>8. \u7ed9 mysqld_exporter \u7684 9105 \u521b\u5efa\u5916\u90e8\u8bbf\u95ee\u5730\u5740<\/h3>\n<p>\u521b\u5efa\u96a7\u9053\u65f6&#xff0c;\u5f53\u524d\u53c2\u6570\u4e3a&#xff1a;<\/p>\n<ul>\n<li>\u96a7\u9053\u540d\u79f0&#xff1a;mysql_exporter<\/li>\n<li>\u534f\u8bae&#xff1a;http<\/li>\n<li>\u672c\u5730\u5730\u5740&#xff1a;9105<\/li>\n<li>\u57df\u540d\u7c7b\u578b&#xff1a;\u968f\u673a\u57df\u540d<\/li>\n<li>\u5730\u533a&#xff1a;China Top<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020921-6ac99e51633ca.png\" alt=\"image-20251125140431855\" \/><\/p>\n<p>\u521b\u5efa\u4ee5\u540e&#xff0c;\u5728\u5728\u7ebf\u96a7\u9053\u5217\u8868\u67e5\u770b\u5730\u5740&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020921-6ac99e51a17e5.png\" alt=\"image-20251125140532931\" \/><\/p>\n<p>\u5f53\u524d\u793a\u4f8b\u7ed9\u51fa\u7684\u516c\u7f51\u5730\u5740\u662f&#xff1a;<\/p>\n<p>38c53143.r2.cpolar.top<\/p>\n<p>\u63a5\u7740\u628a Prometheus \u6293\u53d6\u76ee\u6807\u6539\u6210&#xff1a;<\/p>\n<p>      &#8211; targets: <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;38c53143.r2.cpolar.top&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n        labels:<br \/>\n          app: <span class=\"token string\">&#034;mysql_exporter&#034;<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020921-6ac99e51f1c98.png\" alt=\"image-20251125140712345\" \/><\/p>\n<p>Prometheus \u6293\u53d6\u6210\u529f&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020922-6ac99e5209e26.png\" alt=\"image-20251125140820943\" \/><\/p>\n<p>\u8fd9\u4e00\u6b65\u9a8c\u8bc1\u7684\u662f&#xff1a;Prometheus \u5373\u4f7f\u4e0d\u5728 MySQL \u6240\u5728\u5c40\u57df\u7f51&#xff0c;\u4e5f\u80fd\u7ee7\u7eed\u8bbf\u95ee exporter \u66b4\u9732\u51fa\u6765\u7684\u6307\u6807\u670d\u52a1\u3002<\/p>\n<h3>9. \u957f\u671f\u4f7f\u7528\u518d\u914d\u7f6e\u56fa\u5b9a\u5730\u5740<\/h3>\n<p>\u968f\u673a\u5730\u5740\u9002\u5408\u6d4b\u8bd5\u3002<\/p>\n<p>\u5982\u679c Prometheus \u8981\u957f\u671f\u6293\u53d6&#xff0c;\u76ee\u6807\u5730\u5740\u7ecf\u5e38\u53d8\u5316\u663e\u7136\u4e0d\u9002\u5408&#xff0c;\u6240\u4ee5\u7ee7\u7eed\u914d\u7f6e\u56fa\u5b9a\u4e8c\u7ea7\u5b50\u57df\u540d\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020922-6ac99e523dae5.png\" alt=\"image-20251125141035399\" \/><\/p>\n<p>\u8fdb\u5165\u9884\u7559\u9875\u9762&#xff0c;\u5f53\u524d\u793a\u4f8b\u4f7f\u7528&#xff1a;<\/p>\n<ul>\n<li>\u5730\u533a&#xff1a;china Top<\/li>\n<li>\u4e8c\u7ea7\u5b50\u57df\u540d&#xff1a;mysqll<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020922-6ac99e526e50f.png\" alt=\"image-20251125141009206\" \/><\/p>\n<p>\u7136\u540e\u56de\u5230\u96a7\u9053\u5217\u8868&#xff0c;\u627e\u5230 mysql_exporter&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020922-6ac99e529a1a5.png\" alt=\"image-20251125141100804\" \/><\/p>\n<p>\u7f16\u8f91\u96a7\u9053&#xff0c;\u628a\u57df\u540d\u7c7b\u578b\u6539\u6210\u4e8c\u7ea7\u5b50\u57df\u540d&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020922-6ac99e52f2daa.png\" alt=\"image-20251125141128044\" \/><\/p>\n<p>\u66f4\u65b0\u5b8c\u6210\u540e&#xff0c;\u518d\u67e5\u770b\u5728\u7ebf\u96a7\u9053&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020923-6ac99e5343e5f.png\" alt=\"image-20251125141147962\" \/><\/p>\n<p>\u6700\u540e\u8bbf\u95ee\u56fa\u5b9a\u5730\u5740\u6d4b\u8bd5&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020923-6ac99e5390507.png\" alt=\"image-20251125141202184\" \/><\/p>\n<p>\u957f\u671f\u4f7f\u7528\u65f6&#xff0c;Prometheus \u7684 target \u4e5f\u5e94\u8be5\u5bf9\u5e94\u8fd9\u4e2a\u7a33\u5b9a\u5730\u5740&#xff0c;\u907f\u514d\u968f\u673a\u57df\u540d\u53d8\u5316\u4ee5\u540e\u6293\u53d6\u4e2d\u65ad\u3002<\/p>\n<h3>10. \u8fd9\u4efd\u811a\u672c\u771f\u6b63\u9002\u5408\u4ec0\u4e48\u573a\u666f<\/h3>\n<p>\u5982\u679c\u53ea\u6709\u4e00\u53f0\u673a\u5668&#xff0c;\u624b\u52a8\u5b89\u88c5 mysqld_exporter \u5b8c\u5168\u53ef\u4ee5\u3002<\/p>\n<p>\u811a\u672c\u771f\u6b63\u5f00\u59cb\u6709\u4ef7\u503c&#xff0c;\u662f\u5728\u8fd9\u4e9b\u573a\u666f\u91cc&#xff1a;<\/p>\n<ul>\n<li>\u591a\u53f0 MySQL \u4e3b\u673a\u9700\u8981\u7edf\u4e00\u90e8\u7f72 exporter&#xff1b;<\/li>\n<li>\u5e0c\u671b\u5b89\u88c5\u8def\u5f84\u548c\u7aef\u53e3\u4fdd\u6301\u4e00\u81f4&#xff1b;<\/li>\n<li>\u4e0d\u60f3\u6bcf\u6b21\u91cd\u65b0\u521b\u5efa systemd&#xff1b;<\/li>\n<li>\u5e0c\u671b\u76d1\u63a7\u8d26\u53f7\u548c\u8ba4\u8bc1\u6587\u4ef6\u751f\u6210\u65b9\u5f0f\u7edf\u4e00&#xff1b;<\/li>\n<li>\u540e\u7eed\u8fd8\u51c6\u5907\u901a\u8fc7 Ansible \u6216 SSH \u6279\u91cf\u6267\u884c\u3002<\/li>\n<\/ul>\n<p>\u5bf9\u6211\u6765\u8bf4&#xff0c;\u81ea\u52a8\u5316\u7684\u4ef7\u503c\u4e0d\u662f\u201c\u4e00\u6761\u547d\u4ee4\u663e\u5f97\u5f88\u9177\u201d&#xff0c;\u800c\u662f\u540c\u6837\u7684\u73af\u5883\u548c\u540c\u6837\u7684\u4efb\u52a1\u4ee5\u540e\u53ef\u4ee5\u7a33\u5b9a\u91cd\u590d\u3002<\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u6574\u5957\u6d41\u7a0b\u53ef\u4ee5\u62c6\u6210\u56db\u5c42&#xff1a;Shell \u811a\u672c\u8d1f\u8d23\u6807\u51c6\u5316\u5b89\u88c5&#xff0c;systemd \u8d1f\u8d23\u957f\u671f\u6258\u7ba1 mysqld_exporter&#xff0c;9105 \u63d0\u4f9b\u6307\u6807\u63a5\u53e3&#xff0c;Prometheus \u8d1f\u8d23\u5b9e\u9645\u6293\u53d6\u3002<\/p>\n<p>\u811a\u672c\u6267\u884c\u5b8c\u6210\u4ee5\u540e&#xff0c;\u8fd8\u8981\u7ee7\u7eed\u68c0\u67e5 mysqld_exporter \u670d\u52a1\u72b6\u6001&#xff0c;\u5e76\u628a exporter \u52a0\u5165 Prometheus target\u3002\u53ea\u6709 Prometheus \u771f\u6b63\u6293\u5230\u6307\u6807&#xff0c;\u624d\u80fd\u8bf4\u660e\u76d1\u63a7\u94fe\u8def\u5df2\u7ecf\u95ed\u73af&#xff0c;\u800c\u4e0d\u662f\u5355\u7eaf\u670d\u52a1\u542f\u52a8\u6210\u529f\u3002<\/p>\n<p>\u8de8\u7f51\u7edc\u573a\u666f\u4e0b&#xff0c;\u518d\u7ed9 9105 \u589e\u52a0\u5916\u90e8\u8bbf\u95ee\u5165\u53e3&#xff0c;\u5e76\u6839\u636e\u957f\u671f\u4f7f\u7528\u9700\u6c42\u914d\u7f6e\u56fa\u5b9a\u5730\u5740\u3002\u8fd9\u6837\u53ef\u4ee5\u628a\u7f51\u7edc\u95ee\u9898\u548c exporter \u672c\u8eab\u7684\u5b89\u88c5\u3001\u8ba4\u8bc1\u3001systemd \u95ee\u9898\u5206\u5f00\u5904\u7406\u3002<\/p>\n<p>\u5bf9\u4e8e\u591a\u4e3b\u673a\u73af\u5883\u6765\u8bf4&#xff0c;\u8fd9\u7c7b\u811a\u672c\u6700\u5927\u7684\u4ef7\u503c\u662f\u7edf\u4e00\u7248\u672c\u3001\u8def\u5f84\u3001\u7aef\u53e3\u548c\u670d\u52a1\u7ba1\u7406\u65b9\u5f0f\u3002\u540e\u7eed\u518d\u914d\u5408 Ansible\u3001SSH \u6279\u91cf\u6267\u884c&#xff0c;\u4f1a\u6bd4\u6bcf\u53f0\u670d\u52a1\u5668\u624b\u5de5\u5b89\u88c5\u66f4\u5bb9\u6613\u7ef4\u62a4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00<br \/>\nmysqld_exporter \u672c\u8eab\u5e76\u4e0d\u96be\u5b89\u88c5&#xff0c;\u771f\u6b63\u5bb9\u6613\u51fa\u95ee\u9898\u7684\u662f\u90e8\u7f72\u6b65\u9aa4\u592a\u5206\u6563&#xff1a;\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001MySQL \u76d1\u63a7\u8d26\u53f7\u3001\u6743\u9650\u3001\u8ba4\u8bc1\u6587\u4ef6\u3001systemd \u670d\u52a1\u548c 9105 \u6307\u6807\u7aef\u53e3\u90fd\u9700\u8981\u9010\u9879\u914d\u7f6e\u3002\u673a\u5668\u4e00\u591a\u4ee5\u540e&#xff0c;\u624b\u5de5\u64cd\u4f5c\u5f88\u5bb9\u6613\u51fa\u73b0\u8def\u5f84\u3001\u8d26\u53f7\u6216\u53c2\u6570\u4e0d\u4e00\u81f4\u3002<br \/>\n\u8fd9\u7bc7\u6587\u7ae0\u7684\u91cd\u70b9\u5c31\u662f\u628a\u8fd9\u4e9b\u6b65\u9aa4\u6536\u8fdb\u4e00\u4e2a Shell \u811a\u672c\u3002\u811a\u672c\u56fa\u5b9a\u4f7f\u7528 v0.18.0&#xff0c;\u5b89\u88c5\u5230 \/app\/mysqld_exporter&#xff0c;\u81ea\u52a8\u51c6\u5907 prome<\/p>\n","protected":false},"author":2,"featured_media":114807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11820,678,87,395,44,214],"topic":[],"class_list":["post-114826","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-atomgit","tag-prometheus","tag-87","tag-395","tag-44","tag-214"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/114826.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00 mysqld_exporter \u672c\u8eab\u5e76\u4e0d\u96be\u5b89\u88c5&#xff0c;\u771f\u6b63\u5bb9\u6613\u51fa\u95ee\u9898\u7684\u662f\u90e8\u7f72\u6b65\u9aa4\u592a\u5206\u6563&#xff1a;\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001MySQL \u76d1\u63a7\u8d26\u53f7\u3001\u6743\u9650\u3001\u8ba4\u8bc1\u6587\u4ef6\u3001systemd \u670d\u52a1\u548c 9105 \u6307\u6807\u7aef\u53e3\u90fd\u9700\u8981\u9010\u9879\u914d\u7f6e\u3002\u673a\u5668\u4e00\u591a\u4ee5\u540e&#xff0c;\u624b\u5de5\u64cd\u4f5c\u5f88\u5bb9\u6613\u51fa\u73b0\u8def\u5f84\u3001\u8d26\u53f7\u6216\u53c2\u6570\u4e0d\u4e00\u81f4\u3002 \u8fd9\u7bc7\u6587\u7ae0\u7684\u91cd\u70b9\u5c31\u662f\u628a\u8fd9\u4e9b\u6b65\u9aa4\u6536\u8fdb\u4e00\u4e2a Shell \u811a\u672c\u3002\u811a\u672c\u56fa\u5b9a\u4f7f\u7528 v0.18.0&#xff0c;\u5b89\u88c5\u5230 \/app\/mysqld_exporter&#xff0c;\u81ea\u52a8\u51c6\u5907 prome\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/114826.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-10T02:09:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020918-6ac99e4e449f2.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/114826.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/114826.html\",\"name\":\"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-10T02:09:24+00:00\",\"dateModified\":\"2026-10-10T02:09:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/114826.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/114826.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/114826.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/114826.html","og_locale":"zh_CN","og_type":"article","og_title":"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00 mysqld_exporter \u672c\u8eab\u5e76\u4e0d\u96be\u5b89\u88c5&#xff0c;\u771f\u6b63\u5bb9\u6613\u51fa\u95ee\u9898\u7684\u662f\u90e8\u7f72\u6b65\u9aa4\u592a\u5206\u6563&#xff1a;\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001MySQL \u76d1\u63a7\u8d26\u53f7\u3001\u6743\u9650\u3001\u8ba4\u8bc1\u6587\u4ef6\u3001systemd \u670d\u52a1\u548c 9105 \u6307\u6807\u7aef\u53e3\u90fd\u9700\u8981\u9010\u9879\u914d\u7f6e\u3002\u673a\u5668\u4e00\u591a\u4ee5\u540e&#xff0c;\u624b\u5de5\u64cd\u4f5c\u5f88\u5bb9\u6613\u51fa\u73b0\u8def\u5f84\u3001\u8d26\u53f7\u6216\u53c2\u6570\u4e0d\u4e00\u81f4\u3002 \u8fd9\u7bc7\u6587\u7ae0\u7684\u91cd\u70b9\u5c31\u662f\u628a\u8fd9\u4e9b\u6b65\u9aa4\u6536\u8fdb\u4e00\u4e2a Shell \u811a\u672c\u3002\u811a\u672c\u56fa\u5b9a\u4f7f\u7528 v0.18.0&#xff0c;\u5b89\u88c5\u5230 \/app\/mysqld_exporter&#xff0c;\u81ea\u52a8\u51c6\u5907 prome","og_url":"https:\/\/www.wsisp.com\/helps\/114826.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-10T02:09:24+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261010020918-6ac99e4e449f2.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/114826.html","url":"https:\/\/www.wsisp.com\/helps\/114826.html","name":"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-10T02:09:24+00:00","dateModified":"2026-10-10T02:09:24+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/114826.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/114826.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/114826.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"mysqld_exporter\u81ea\u52a8\u5316\u76d1\u63a7\u94fe\uff1aShell\u5b89\u88c5\u3001systemd\u6258\u7ba1\u4e0ePrometheus\u6293\u53d6"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/114826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=114826"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/114826\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/114807"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=114826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=114826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=114826"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=114826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}