{"id":40600,"date":"2025-05-29T16:41:18","date_gmt":"2025-05-29T08:41:18","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/40600.html"},"modified":"2025-05-29T16:41:18","modified_gmt":"2025-05-29T08:41:18","slug":"mysql%e4%b9%8b%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%8a%b6%e6%80%81%e7%9b%91%e6%8e%a7%e4%b8%8e%e6%80%a7%e8%83%bd%e5%88%86%e6%9e%90%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/40600.html","title":{"rendered":"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218"},"content":{"rendered":"<h2>Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218<\/h2>\n<h3>\u4e00\u3001\u524d\u8a00<\/h3>\n<p>\u5f00\u53d1\u8005\u670b\u53cb\u4eec&#xff0c;\u5728MySQL\u6570\u636e\u5e93\u7684\u8fd0\u7ef4\u5de5\u4f5c\u4e2d&#xff0c;\u5b9e\u65f6\u638c\u63e1\u670d\u52a1\u5668\u72b6\u6001\u662f\u6027\u80fd\u4f18\u5316\u548c\u6545\u969c\u6392\u67e5\u7684\u57fa\u7840\u3002\u901a\u8fc7\u7cfb\u7edf\u53d8\u91cf\u3001\u72b6\u6001\u6307\u6807\u548c\u6027\u80fd\u6a21\u5f0f\u7b49\u5de5\u5177&#xff0c;\u6211\u4eec\u53ef\u4ee5\u6df1\u5165\u4e86\u89e3\u6570\u636e\u5e93\u7684\u8fd0\u884c\u72b6\u51b5&#xff0c;\u53ca\u65f6\u53d1\u73b0\u6f5c\u5728\u95ee\u9898\u3002\u5199\u4f5c\u672c\u6587\u7684\u521d\u8877&#xff0c;\u662f\u5e0c\u671b\u4e0e\u5927\u5bb6\u4e00\u540c\u5b66\u4e60\u8fdb\u6b65&#xff0c;\u6df1\u5165\u89e3\u6790MySQL\u670d\u52a1\u5668\u72b6\u6001\u7684\u6838\u5fc3\u6307\u6807\u3001\u67e5\u8be2\u65b9\u6cd5\u53ca\u5b9e\u6218\u5206\u6790\u6280\u5de7&#xff0c;\u901a\u8fc7\u901a\u4fd7\u7684\u8bb2\u89e3\u548c\u56fe\u8868\u603b\u7ed3&#xff0c;\u5e2e\u52a9\u5927\u5bb6\u6784\u5efa\u9ad8\u6548\u7684\u76d1\u63a7\u5206\u6790\u4f53\u7cfb\u3002<\/p>\n<h3>\u4e8c\u3001\u6838\u5fc3\u76d1\u63a7\u624b\u6bb5&#xff1a;\u7cfb\u7edf\u53d8\u91cf\u4e0e\u72b6\u6001\u6307\u6807<\/h3>\n<h4>&#xff08;\u4e00&#xff09;\u7cfb\u7edf\u53d8\u91cf&#xff1a;\u914d\u7f6e\u4e0e\u8fd0\u884c\u65f6\u53c2\u6570<\/h4>\n<h5>1. \u4f5c\u7528\u4e0e\u5206\u7c7b<\/h5>\n<ul>\n<li>\u9759\u6001\u53d8\u91cf&#xff1a;\u670d\u52a1\u5668\u542f\u52a8\u65f6\u8bfb\u53d6\u914d\u7f6e\u6587\u4ef6&#xff08;\u5982my.cnf&#xff09;\u751f\u6548&#xff0c;\u9700\u91cd\u542f\u624d\u80fd\u4fee\u6539&#xff08;\u5982innodb_buffer_pool_size&#xff09;\u3002<\/li>\n<li>\u52a8\u6001\u53d8\u91cf&#xff1a;\u53ef\u901a\u8fc7SET GLOBAL\u6216SET SESSION\u5b9e\u65f6\u4fee\u6539&#xff08;\u5982max_connections&#xff09;\u3002<\/li>\n<\/ul>\n<h5>2. \u67e5\u8be2\u65b9\u6cd5<\/h5>\n<p><span class=\"token comment\">&#8212; \u67e5\u8be2\u6240\u6709\u7cfb\u7edf\u53d8\u91cf<\/span><br \/>\n<span class=\"token keyword\">SHOW<\/span> VARIABLES<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">&#8212; \u67e5\u8be2\u7279\u5b9a\u53d8\u91cf&#xff08;\u5982\u5b57\u7b26\u96c6&#xff09;<\/span><br \/>\n<span class=\"token keyword\">SHOW<\/span> VARIABLES <span class=\"token operator\">LIKE<\/span> <span class=\"token string\">&#039;character_set_server&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">&#8212; \u52a8\u6001\u4fee\u6539\u8fde\u63a5\u6570\u4e0a\u9650&#xff08;\u9700SUPER\u6743\u9650&#xff09;<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> <span class=\"token keyword\">GLOBAL<\/span> max_connections <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">2000<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h5>3. \u5173\u952e\u53d8\u91cf\u793a\u4f8b<\/h5>\n<table>\n<tr>\u53d8\u91cf\u540d\u8bf4\u660e\u4f18\u5316\u65b9\u5411<\/tr>\n<tbody>\n<tr>\n<td>innodb_buffer_pool_size<\/td>\n<td>InnoDB\u7f13\u51b2\u6c60\u5927\u5c0f<\/td>\n<td>\u5efa\u8bae\u8bbe\u7f6e\u4e3a\u7269\u7406\u5185\u5b58\u768460%-80%<\/td>\n<\/tr>\n<tr>\n<td>query_cache_type<\/td>\n<td>\u67e5\u8be2\u7f13\u5b58\u5f00\u5173&#xff08;MySQL 8.0\u5df2\u79fb\u9664&#xff09;<\/td>\n<td>\u9ad8\u5e76\u53d1\u573a\u666f\u5efa\u8bae\u5173\u95ed<\/td>\n<\/tr>\n<tr>\n<td>max_allowed_packet<\/td>\n<td>\u6700\u5927\u6570\u636e\u5305\u5927\u5c0f<\/td>\n<td>\u6839\u636e\u5e94\u7528\u9700\u6c42\u8c03\u6574&#xff0c;\u907f\u514d\u5927\u6587\u4ef6\u5bfc\u5165\u5931\u8d25<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>&#xff08;\u4e8c&#xff09;\u72b6\u6001\u6307\u6807&#xff1a;\u8fd0\u884c\u65f6\u7edf\u8ba1\u6570\u636e<\/h4>\n<h5>1. \u5168\u5c40 vs \u4f1a\u8bdd\u53d8\u91cf<\/h5>\n<ul>\n<li>\u5168\u5c40\u53d8\u91cf&#xff1a;\u670d\u52a1\u5668\u6574\u4f53\u8fd0\u884c\u6307\u6807&#xff08;\u5982Threads_connected\u603b\u8fde\u63a5\u6570&#xff09;\u3002<\/li>\n<li>\u4f1a\u8bdd\u53d8\u91cf&#xff1a;\u5f53\u524d\u8fde\u63a5\u7684\u4e13\u5c5e\u6307\u6807&#xff08;\u5982Last_query_cost\u5f53\u524d\u67e5\u8be2\u6210\u672c&#xff09;\u3002<\/li>\n<\/ul>\n<h5>2. \u67e5\u8be2\u65b9\u6cd5<\/h5>\n<p><span class=\"token comment\">&#8212; \u67e5\u8be2\u5168\u5c40\u72b6\u6001<\/span><br \/>\n<span class=\"token keyword\">SHOW<\/span> <span class=\"token keyword\">GLOBAL<\/span> <span class=\"token keyword\">STATUS<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">&#8212; \u67e5\u8be2\u4f1a\u8bdd\u72b6\u6001&#xff08;\u5f53\u524d\u8fde\u63a5&#xff09;<\/span><br \/>\n<span class=\"token keyword\">SHOW<\/span> <span class=\"token keyword\">SESSION<\/span> <span class=\"token keyword\">STATUS<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">&#8212; \u901a\u8fc7INFORMATION_SCHEMA\u83b7\u53d6&#xff08;MySQL 5.1&#043;&#xff09;<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span> <span class=\"token operator\">*<\/span> <span class=\"token keyword\">FROM<\/span> INFORMATION_SCHEMA<span class=\"token punctuation\">.<\/span>GLOBAL_STATUS <span class=\"token keyword\">WHERE<\/span> VARIABLE_NAME <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;Slow_queries&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h5>3. \u6838\u5fc3\u6307\u6807\u5206\u7c7b<\/h5>\n<table>\n<tr>\u7c7b\u522b\u6307\u6807\u540d\u542b\u4e49\u5065\u5eb7\u9608\u503c<\/tr>\n<tbody>\n<tr>\n<td>\u8fde\u63a5\u7ba1\u7406<\/td>\n<td>Threads_connected<\/td>\n<td>\u5f53\u524d\u6d3b\u52a8\u8fde\u63a5\u6570<\/td>\n<td>&lt;80% of max_connections<\/td>\n<\/tr>\n<tr>\n<td>\u67e5\u8be2\u6027\u80fd<\/td>\n<td>Slow_queries<\/td>\n<td>\u6162\u67e5\u8be2\u603b\u6570<\/td>\n<td>&lt;10\u6b21\/\u5c0f\u65f6<\/td>\n<\/tr>\n<tr>\n<td>InnoDB\u72b6\u6001<\/td>\n<td>Innodb_buffer_pool_hit_rate<\/td>\n<td>\u7f13\u51b2\u6c60\u547d\u4e2d\u7387<\/td>\n<td>&gt;90%<\/td>\n<\/tr>\n<tr>\n<td>\u78c1\u76d8I\/O<\/td>\n<td>Innodb_data_read\/Innodb_data_written<\/td>\n<td>\u6570\u636e\u8bfb\u5199\u603b\u91cf<\/td>\n<td>\u6839\u636e\u4e1a\u52a1\u8bc4\u4f30&#xff0c;\u65e0\u56fa\u5b9a\u9608\u503c<\/td>\n<\/tr>\n<tr>\n<td>\u590d\u5236\u72b6\u6001<\/td>\n<td>Seconds_Behind_Master<\/td>\n<td>\u4e3b\u4ece\u5ef6\u8fdf\u65f6\u95f4<\/td>\n<td>&lt;1\u79d2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e09\u3001\u6027\u80fd\u5206\u6790\u5de5\u5177\u4e0e\u5b9e\u6218<\/h3>\n<h4>&#xff08;\u4e00&#xff09;Innotop&#xff1a;\u5b9e\u65f6\u72b6\u6001\u76d1\u63a7<\/h4>\n<h5>1. \u6838\u5fc3\u529f\u80fd<\/h5>\n<ul>\n<li>\u591a\u6a21\u5f0f\u76d1\u63a7&#xff1a;\u652f\u6301InnoDB\u4e8b\u52a1&#xff08;T\u6a21\u5f0f&#xff09;\u3001\u67e5\u8be2\u5217\u8868&#xff08;Q\u6a21\u5f0f&#xff09;\u3001\u590d\u5236\u72b6\u6001&#xff08;M\u6a21\u5f0f&#xff09;\u7b49\u3002<\/li>\n<li>\u81ea\u5b9a\u4e49\u6307\u6807&#xff1a;\u901a\u8fc7\u8868\u8fbe\u5f0f\u5b9e\u65f6\u8ba1\u7b97\u81ea\u5b9a\u4e49\u6307\u6807&#xff08;\u5982\u952e\u7f13\u5b58\u4f7f\u7528\u7387&#xff09;\u3002<\/li>\n<\/ul>\n<h5>2. \u64cd\u4f5c\u793a\u4f8b<\/h5>\n<p><span class=\"token comment\"># \u542f\u52a8Innotop\u76d1\u63a7\u672c\u5730MySQL<\/span><br \/>\ninnotop -h localhost -u root -p your_password<br \/>\n<span class=\"token comment\"># \u5728Q\u6a21\u5f0f\u4e0b\u67e5\u770bQPS\u8d8b\u52bf<\/span><br \/>\n\u6309o\u952e\u9009\u62e9qps\u5217\u6392\u5e8f&#xff0c;\u5b9e\u65f6\u89c2\u5bdf\u67e5\u8be2\u541e\u5410\u91cf\u53d8\u5316<\/p>\n<h4>&#xff08;\u4e8c&#xff09;Percona Toolkit&#xff1a;\u6df1\u5ea6\u5206\u6790<\/h4>\n<h5>1. pt-mysql-summary&#xff1a;\u670d\u52a1\u5668\u72b6\u6001\u6c47\u603b<\/h5>\n<p>pt-mysql-summary &#8211;user<span class=\"token operator\">&#061;<\/span>root &#8211;password<span class=\"token operator\">&#061;<\/span>xxx<br \/>\n<span class=\"token comment\"># \u8f93\u51fa\u5305\u542b\u786c\u4ef6\u4fe1\u606f\u3001\u914d\u7f6e\u6458\u8981\u3001\u5173\u952e\u6307\u6807\u8d8b\u52bf&#xff08;\u5982\u7f13\u51b2\u6c60\u547d\u4e2d\u7387\u3001QPS&#xff09;<\/span><\/p>\n<h5>2. pt-query-digest&#xff1a;\u6162\u67e5\u8be2\u5206\u6790<\/h5>\n<p>pt-query-digest \/var\/log\/mysql\/slow.log <span class=\"token operator\">&gt;<\/span> slow_query_analysis.txt<br \/>\n<span class=\"token comment\"># \u62a5\u544a\u5305\u542b\u6162\u67e5\u8be2Top N\u3001\u6267\u884c\u8ba1\u5212\u5206\u6790\u3001\u7d22\u5f15\u4f18\u5316\u5efa\u8bae<\/span><\/p>\n<h4>&#xff08;\u4e09&#xff09;Performance Schema&#xff1a;\u5185\u6838\u7ea7\u76d1\u63a7<\/h4>\n<h5>1. \u529f\u80fd\u6982\u8ff0<\/h5>\n<ul>\n<li>\u63d0\u4f9b\u7ebf\u7a0b\u3001\u6587\u4ef6\u3001\u9501\u3001\u8bed\u53e5\u7b49\u7ec6\u7c92\u5ea6\u76d1\u63a7\u6570\u636e\u3002<\/li>\n<li>\u9002\u7528\u4e8e\u8bca\u65ad\u590d\u6742\u6027\u80fd\u95ee\u9898&#xff08;\u5982\u9501\u7ade\u4e89\u3001\u7ebf\u7a0b\u963b\u585e&#xff09;\u3002<\/li>\n<\/ul>\n<h5>2. \u67e5\u8be2\u793a\u4f8b&#xff1a;\u67e5\u770b\u5f53\u524d\u963b\u585e\u7684\u7ebf\u7a0b<\/h5>\n<p><span class=\"token keyword\">SELECT<\/span><br \/>\n  blocking_thread_id<span class=\"token punctuation\">,<\/span><br \/>\n  blocked_thread_id<span class=\"token punctuation\">,<\/span><br \/>\n  EVENT_NAME<span class=\"token punctuation\">,<\/span><br \/>\n  STATE<br \/>\n<span class=\"token keyword\">FROM<\/span> performance_schema<span class=\"token punctuation\">.<\/span>threads<br \/>\n<span class=\"token keyword\">WHERE<\/span> STATE <span class=\"token operator\">LIKE<\/span> <span class=\"token string\">&#039;waiting for table metadata lock&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>\u56db\u3001\u5178\u578b\u573a\u666f\u5206\u6790\u4e0e\u4f18\u5316<\/h3>\n<h4>&#xff08;\u4e00&#xff09;\u573a\u666f1&#xff1a;\u7f13\u51b2\u6c60\u5229\u7528\u7387\u4f4e\u4e0b<\/h4>\n<h5>1. \u76d1\u63a7\u53d1\u73b0<\/h5>\n<ul>\n<li>Innodb_buffer_pool_hit_rate\u4ec570%&#xff0c;\u4f4e\u4e8e\u5065\u5eb7\u9608\u503c&#xff08;&gt;90%&#xff09;\u3002<\/li>\n<li>Innodb_buffer_pool_pages_free\u5360\u6bd4\u8fc7\u9ad8&#xff0c;\u8868\u660e\u7f13\u51b2\u6c60\u672a\u5145\u5206\u5229\u7528\u3002<\/li>\n<\/ul>\n<h5>2. \u4f18\u5316\u6b65\u9aa4<\/h5>\n<p><span class=\"token comment\">&#8212; \u589e\u5927\u7f13\u51b2\u6c60\u5927\u5c0f&#xff08;\u9700\u91cd\u542f\u751f\u6548&#xff09;<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> <span class=\"token keyword\">GLOBAL<\/span> innodb_buffer_pool_size <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">16<\/span>G<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">&#8212; \u67e5\u770b\u7f13\u51b2\u6c60\u4f7f\u7528\u60c5\u51b5<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span> POOL_ID<span class=\"token punctuation\">,<\/span> NAME<span class=\"token punctuation\">,<\/span> DATA_SIZE<span class=\"token operator\">\/<\/span><span class=\"token number\">1024<\/span><span class=\"token operator\">\/<\/span><span class=\"token number\">1024<\/span> <span class=\"token keyword\">AS<\/span> MB_SIZE<br \/>\n<span class=\"token keyword\">FROM<\/span> INFORMATION_SCHEMA<span class=\"token punctuation\">.<\/span>INNODB_BUFFER_POOL_STATS<span class=\"token punctuation\">;<\/span><\/p>\n<h4>&#xff08;\u4e8c&#xff09;\u573a\u666f2&#xff1a;\u4e3b\u4ece\u590d\u5236\u5ef6\u8fdf<\/h4>\n<h5>1. \u76d1\u63a7\u53d1\u73b0<\/h5>\n<ul>\n<li>Seconds_Behind_Master\u6301\u7eed&gt;10\u79d2&#xff0c;Slave_SQL_Running\u72b6\u6001\u6b63\u5e38\u3002<\/li>\n<li>SHOW SLAVE STATUS\u663e\u793aLast_Executed_Log_Pos\u505c\u6ede\u4e0d\u524d\u3002<\/li>\n<\/ul>\n<h5>2. \u4f18\u5316\u6b65\u9aa4<\/h5>\n<p><span class=\"token comment\"># \u67e5\u770b\u4ece\u5e93\u5ef6\u8fdf\u539f\u56e0&#xff08;\u5982\u9501\u7b49\u5f85&#xff09;<\/span><br \/>\ninnotop -M  <span class=\"token comment\"># \u8fdb\u5165\u590d\u5236\u6a21\u5f0f&#xff0c;\u67e5\u770bSQL\u7ebf\u7a0b\u6267\u884c\u7684SQL<\/span><br \/>\n<span class=\"token comment\"># \u4f18\u5316\u4e3b\u5e93\u5927\u4e8b\u52a1&#xff0c;\u62c6\u5206\u6279\u91cf\u64cd\u4f5c<\/span><br \/>\npt-query-digest &#8211;type<span class=\"token operator\">&#061;<\/span>slow \/var\/log\/mysql\/master-slow.log  <span class=\"token comment\"># \u5206\u6790\u4e3b\u5e93\u6162\u67e5\u8be2<\/span><\/p>\n<h4>&#xff08;\u4e09&#xff09;\u573a\u666f3&#xff1a;\u9ad8\u8fde\u63a5\u6570\u5bfc\u81f4\u6027\u80fd\u4e0b\u964d<\/h4>\n<h5>1. \u76d1\u63a7\u53d1\u73b0<\/h5>\n<ul>\n<li>Threads_connected\u63a5\u8fd1max_connections&#xff0c;Aborted_connects\u9891\u7e41\u589e\u52a0\u3002<\/li>\n<li>\u5e94\u7528\u7aef\u62a5\u9519\u201cToo many connections\u201d\u3002<\/li>\n<\/ul>\n<h5>2. \u4f18\u5316\u6b65\u9aa4<\/h5>\n<p><span class=\"token comment\">&#8212; \u4e34\u65f6\u589e\u52a0\u8fde\u63a5\u6570\u4e0a\u9650<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> <span class=\"token keyword\">GLOBAL<\/span> max_connections <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">3000<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">&#8212; \u67e5\u770b\u8fde\u63a5\u6765\u6e90<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span> SUBSTRING_INDEX<span class=\"token punctuation\">(<\/span>HOST<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;:&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> client_host<span class=\"token punctuation\">,<\/span> <span class=\"token function\">COUNT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">AS<\/span> conn_count<br \/>\n<span class=\"token keyword\">FROM<\/span> INFORMATION_SCHEMA<span class=\"token punctuation\">.<\/span>PROCESSLIST<br \/>\n<span class=\"token keyword\">GROUP<\/span> <span class=\"token keyword\">BY<\/span> client_host <span class=\"token keyword\">ORDER<\/span> <span class=\"token keyword\">BY<\/span> conn_count <span class=\"token keyword\">DESC<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">&#8212; \u6e05\u7406\u65e0\u6548\u8fde\u63a5<\/span><br \/>\n<span class=\"token keyword\">KILL<\/span> PROCESS <span class=\"token number\">1234<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">&#8212; \u66ff\u6362\u4e3a\u5b9e\u9645\u963b\u585e\u7684\u8fde\u63a5ID<\/span><\/p>\n<h3>\u4e94\u3001\u81ea\u52a8\u5316\u76d1\u63a7\u4f53\u7cfb\u6784\u5efa<\/h3>\n<h4>&#xff08;\u4e00&#xff09;\u6307\u6807\u91c7\u96c6\u4e0e\u5b58\u50a8<\/h4>\n<h5>1. \u811a\u672c\u5316\u91c7\u96c6&#xff08;Python\u793a\u4f8b&#xff09;<\/h5>\n<p><span class=\"token keyword\">import<\/span> MySQLdb<br \/>\n<span class=\"token keyword\">import<\/span> time<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">get_mysql_status<\/span><span class=\"token punctuation\">(<\/span>host<span class=\"token punctuation\">,<\/span> user<span class=\"token punctuation\">,<\/span> password<span class=\"token punctuation\">,<\/span> metric<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    conn <span class=\"token operator\">&#061;<\/span> MySQLdb<span class=\"token punctuation\">.<\/span>connect<span class=\"token punctuation\">(<\/span>host<span class=\"token operator\">&#061;<\/span>host<span class=\"token punctuation\">,<\/span> user<span class=\"token operator\">&#061;<\/span>user<span class=\"token punctuation\">,<\/span> password<span class=\"token operator\">&#061;<\/span>password<span class=\"token punctuation\">)<\/span><br \/>\n    cursor <span class=\"token operator\">&#061;<\/span> conn<span class=\"token punctuation\">.<\/span>cursor<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    cursor<span class=\"token punctuation\">.<\/span>execute<span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;SHOW GLOBAL STATUS LIKE &#039;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>metric<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#039;&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n    value <span class=\"token operator\">&#061;<\/span> cursor<span class=\"token punctuation\">.<\/span>fetchone<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    conn<span class=\"token punctuation\">.<\/span>close<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> value<\/p>\n<p><span class=\"token comment\"># \u91c7\u96c6QPS\u5e76\u6253\u5370<\/span><br \/>\nqps <span class=\"token operator\">&#061;<\/span> get_mysql_status<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;localhost&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;root&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;xxx&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;Questions&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u5f53\u524dQPS&#xff1a;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>qps<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h5>2. \u96c6\u6210Prometheus<\/h5>\n<ul>\n<li>\u4f7f\u7528mysqld_exporter\u91c7\u96c6\u6307\u6807&#xff0c;\u914d\u7f6eprometheus.yml&#xff1a;<span class=\"token key atrule\">scrape_configs<\/span><span class=\"token punctuation\">:<\/span><br \/>\n  <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">job_name<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#039;mysql&#039;<\/span><br \/>\n    <span class=\"token key atrule\">static_configs<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      <span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">targets<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;localhost:9104&#039;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token key atrule\">metrics_path<\/span><span class=\"token punctuation\">:<\/span> \/metrics<br \/>\n    <span class=\"token key atrule\">params<\/span><span class=\"token punctuation\">:<\/span><br \/>\n      collect<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;global_status&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;slave_status&#034;<\/span><span class=\"token punctuation\">]<\/span>\n <\/li>\n<\/ul>\n<h4>&#xff08;\u4e8c&#xff09;\u544a\u8b66\u89c4\u5219\u793a\u4f8b&#xff08;Alertmanager&#xff09;<\/h4>\n<p><span class=\"token comment\"># \u4e3b\u4ece\u5ef6\u8fdf\u544a\u8b66<\/span><br \/>\n<span class=\"token punctuation\">&#8211;<\/span> <span class=\"token key atrule\">alert<\/span><span class=\"token punctuation\">:<\/span> Slave_Replication_Delay<br \/>\n  <span class=\"token key atrule\">expr<\/span><span class=\"token punctuation\">:<\/span> mysql_slave_seconds_behind_master <span class=\"token punctuation\">&gt;<\/span> 10<br \/>\n  <span class=\"token key atrule\">for<\/span><span class=\"token punctuation\">:<\/span> 5m<br \/>\n  <span class=\"token key atrule\">labels<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">severity<\/span><span class=\"token punctuation\">:<\/span> critical<br \/>\n  <span class=\"token key atrule\">annotations<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token key atrule\">summary<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u4e3b\u4ece\u5ef6\u8fdf\u8d85\u8fc710\u79d2&#034;<\/span><br \/>\n    <span class=\"token key atrule\">description<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;\u5b9e\u4f8b {{ $labels.instance }} \u5ef6\u8fdf\u4e3a {{ $value }} \u79d2&#034;<\/span><\/p>\n<h3>\u516d\u3001\u603b\u7ed3&#xff1a;\u72b6\u6001\u76d1\u63a7\u7684\u201c\u4e09\u7ef4\u6cd5\u5219\u201d<\/h3>\n<p>\u672c\u6587\u56f4\u7ed5MySQL\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7&#xff0c;\u89e3\u6790\u4e86\u6838\u5fc3\u6307\u6807\u3001\u5de5\u5177\u53ca\u5b9e\u6218\u573a\u666f&#xff0c;\u6838\u5fc3\u6cd5\u5219\u5982\u4e0b&#xff1a;<\/p>\n<li>\u57fa\u7840\u76d1\u63a7&#xff1a;\u901a\u8fc7\u7cfb\u7edf\u53d8\u91cf\u548c\u72b6\u6001\u6307\u6807\u638c\u63e1\u5168\u5c40\u8fd0\u884c\u72b6\u51b5&#xff0c;\u5efa\u7acb\u5065\u5eb7\u9608\u503c\u57fa\u7ebf\u3002<\/li>\n<li>\u5de5\u5177\u534f\u540c&#xff1a;Innotop\u7528\u4e8e\u5b9e\u65f6\u6392\u67e5&#xff0c;Percona Toolkit\u7528\u4e8e\u6df1\u5ea6\u5206\u6790&#xff0c;Performance Schema\u7528\u4e8e\u5185\u6838\u7ea7\u8bca\u65ad\u3002<\/li>\n<li>\u81ea\u52a8\u5316\u54cd\u5e94&#xff1a;\u901a\u8fc7\u811a\u672c\u548cPrometheus\u5b9e\u73b0\u6307\u6807\u91c7\u96c6\u3001\u544a\u8b66\u81ea\u52a8\u5316&#xff0c;\u7f29\u77ed\u6545\u969c\u54cd\u5e94\u65f6\u95f4\u3002<\/li>\n<p>\u5728\u5b9e\u9645\u8fd0\u7ef4\u4e2d&#xff0c;\u5efa\u8bae\u5efa\u7acb\u201c\u5b9e\u65f6\u76d1\u63a7\u2192\u8d8b\u52bf\u5206\u6790\u2192\u6839\u56e0\u5b9a\u4f4d\u2192\u4f18\u5316\u9a8c\u8bc1\u201d\u7684\u95ed\u73af\u6d41\u7a0b&#xff0c;\u5b9a\u671f\u590d\u76d8\u76d1\u63a7\u6570\u636e&#xff0c;\u6301\u7eed\u4f18\u5316\u6570\u636e\u5e93\u914d\u7f6e\u4e0e\u67e5\u8be2\u6027\u80fd\u3002\u901a\u8fc7\u7cfb\u7edf\u5316\u7684\u72b6\u6001\u76d1\u63a7&#xff0c;\u53ef\u5c06\u88ab\u52a8\u8fd0\u7ef4\u8f6c\u53d8\u4e3a\u4e3b\u52a8\u4f18\u5316&#xff0c;\u663e\u8457\u63d0\u5347\u6570\u636e\u5e93\u7684\u7a33\u5b9a\u6027\u4e0e\u53ef\u7528\u6027\u3002<\/p>\n<h3>\u4e03\u3001\u5199\u4f5c\u4e0d\u6613&#xff0c;\u671f\u5f85\u60a8\u7684\u652f\u6301<\/h3>\n<p>\u4eb2\u7231\u7684\u8bfb\u8005&#xff0c;\u672c\u6587\u4ece\u57fa\u7840\u6307\u6807\u67e5\u8be2\u5230\u81ea\u52a8\u5316\u76d1\u63a7\u4f53\u7cfb\u6784\u5efa&#xff0c;\u6bcf\u4e00\u4e2a\u73af\u8282\u90fd\u51dd\u805a\u7740\u6570\u636e\u5e93\u8fd0\u7ef4\u7684\u5b9e\u8df5\u7ecf\u9a8c\u3002\u5982\u679c\u672c\u6587\u5bf9\u60a8\u7406\u89e3MySQL\u72b6\u6001\u76d1\u63a7\u6709\u6240\u5e2e\u52a9&#xff0c;\u6073\u8bf7\u70b9\u51fb\u4e0b\u65b9\u7684\u201c\u5173\u6ce8\u201d\u6309\u94ae&#xff0c;\u540e\u7eed\u5c06\u6301\u7eed\u5206\u4eab\u67e5\u8be2\u4f18\u5316\u3001\u5206\u5e03\u5f0f\u4e8b\u52a1\u7b49\u6df1\u5ea6\u5185\u5bb9\u3002\u540c\u65f6&#xff0c;\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u7559\u8a00\u4ea4\u6d41\u60a8\u5728\u76d1\u63a7\u4e2d\u7684\u5b9e\u6218\u6280\u5de7\u6216\u95ee\u9898&#xff0c;\u6211\u4f1a\u53ca\u65f6\u56de\u590d\u63a2\u8ba8\u3002\u5982\u679c\u89c9\u5f97\u6587\u7ae0\u5b9e\u7528&#xff0c;\u4e5f\u8bf7\u70b9\u8d5e\u8f6c\u53d1&#xff0c;\u8ba9\u66f4\u591a\u5f00\u53d1\u8005\u53d7\u76ca\u3002\u60a8\u7684\u652f\u6301\u662f\u6211\u521b\u4f5c\u7684\u6700\u5927\u52a8\u529b&#xff0c;\u611f\u8c22\u9605\u8bfb&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb742\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u300aMySQL\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218\u300b\u4e00\u6587\u6df1\u5165\u63a2\u8ba8\u4e86MySQL\u6570\u636e\u5e93\u7684\u76d1\u63a7\u4e0e\u4f18\u5316\u65b9\u6cd5\u3002\u6587\u7ae0\u9996\u5148\u4ecb\u7ecd\u4e86\u7cfb\u7edf\u53d8\u91cf\u548c\u72b6\u6001\u6307\u6807\u7684\u6838\u5fc3\u76d1\u63a7\u624b\u6bb5\uff0c\u5305\u62ec\u9759\u6001\u4e0e\u52a8\u6001\u53d8\u91cf\u7684\u67e5\u8be2\u4e0e\u4fee\u6539\uff0c\u4ee5\u53ca\u5168\u5c40\u548c\u4f1a\u8bdd\u72b6\u6001\u6307\u6807\u7684\u5206\u7c7b\u4e0e\u5065\u5eb7\u9608\u503c\u3002\u63a5\u7740\uff0c\u8be6\u7ec6\u8bb2\u89e3\u4e86Innotop\u3001Percona Toolkit\u548cPerformance Schema\u7b49\u6027\u80fd\u5206\u6790\u5de5\u5177\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e76\u901a\u8fc7\u5178\u578b\u573a\u666f\uff08\u5982\u7f13\u51b2\u6c60\u5229\u7528\u7387\u4f4e\u4e0b\u3001\u4e3b\u4ece\u590d\u5236\u5ef6\u8fdf\u3001\u9ad8\u8fde\u63a5\u6570\u95ee\u9898\uff09\u5c55\u793a\u4e86\u4f18\u5316\u6b65\u9aa4\u3002\u6700\u540e\uff0c\u6587\u7ae0\u63d0\u51fa\u4e86\u81ea\u52a8\u5316\u76d1\u63a7\u4f53\u7cfb\u7684\u6784\u5efa\u65b9\u6cd5\uff0c\u5305\u62ec\u811a\u672c\u5316\u91c7\u96c6\u3001Prometheus\u96c6\u6210\u548c\u544a\u8b66\u89c4\u5219\u914d\u7f6e<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[114,100,43],"topic":[],"class_list":["post-40600","post","type-post","status-publish","format-standard","hentry","category-server","tag-mysql","tag-100","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218 - \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\/40600.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb742\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u300aMySQL\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218\u300b\u4e00\u6587\u6df1\u5165\u63a2\u8ba8\u4e86MySQL\u6570\u636e\u5e93\u7684\u76d1\u63a7\u4e0e\u4f18\u5316\u65b9\u6cd5\u3002\u6587\u7ae0\u9996\u5148\u4ecb\u7ecd\u4e86\u7cfb\u7edf\u53d8\u91cf\u548c\u72b6\u6001\u6307\u6807\u7684\u6838\u5fc3\u76d1\u63a7\u624b\u6bb5\uff0c\u5305\u62ec\u9759\u6001\u4e0e\u52a8\u6001\u53d8\u91cf\u7684\u67e5\u8be2\u4e0e\u4fee\u6539\uff0c\u4ee5\u53ca\u5168\u5c40\u548c\u4f1a\u8bdd\u72b6\u6001\u6307\u6807\u7684\u5206\u7c7b\u4e0e\u5065\u5eb7\u9608\u503c\u3002\u63a5\u7740\uff0c\u8be6\u7ec6\u8bb2\u89e3\u4e86Innotop\u3001Percona Toolkit\u548cPerformance Schema\u7b49\u6027\u80fd\u5206\u6790\u5de5\u5177\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e76\u901a\u8fc7\u5178\u578b\u573a\u666f\uff08\u5982\u7f13\u51b2\u6c60\u5229\u7528\u7387\u4f4e\u4e0b\u3001\u4e3b\u4ece\u590d\u5236\u5ef6\u8fdf\u3001\u9ad8\u8fde\u63a5\u6570\u95ee\u9898\uff09\u5c55\u793a\u4e86\u4f18\u5316\u6b65\u9aa4\u3002\u6700\u540e\uff0c\u6587\u7ae0\u63d0\u51fa\u4e86\u81ea\u52a8\u5316\u76d1\u63a7\u4f53\u7cfb\u7684\u6784\u5efa\u65b9\u6cd5\uff0c\u5305\u62ec\u811a\u672c\u5316\u91c7\u96c6\u3001Prometheus\u96c6\u6210\u548c\u544a\u8b66\u89c4\u5219\u914d\u7f6e\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/40600.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-29T08:41:18+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/40600.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/40600.html\",\"name\":\"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-29T08:41:18+00:00\",\"dateModified\":\"2025-05-29T08:41:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/40600.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/40600.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/40600.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218\"}]},{\"@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":"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218 - \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\/40600.html","og_locale":"zh_CN","og_type":"article","og_title":"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb742\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf14\u6b21\u3002\u300aMySQL\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218\u300b\u4e00\u6587\u6df1\u5165\u63a2\u8ba8\u4e86MySQL\u6570\u636e\u5e93\u7684\u76d1\u63a7\u4e0e\u4f18\u5316\u65b9\u6cd5\u3002\u6587\u7ae0\u9996\u5148\u4ecb\u7ecd\u4e86\u7cfb\u7edf\u53d8\u91cf\u548c\u72b6\u6001\u6307\u6807\u7684\u6838\u5fc3\u76d1\u63a7\u624b\u6bb5\uff0c\u5305\u62ec\u9759\u6001\u4e0e\u52a8\u6001\u53d8\u91cf\u7684\u67e5\u8be2\u4e0e\u4fee\u6539\uff0c\u4ee5\u53ca\u5168\u5c40\u548c\u4f1a\u8bdd\u72b6\u6001\u6307\u6807\u7684\u5206\u7c7b\u4e0e\u5065\u5eb7\u9608\u503c\u3002\u63a5\u7740\uff0c\u8be6\u7ec6\u8bb2\u89e3\u4e86Innotop\u3001Percona Toolkit\u548cPerformance Schema\u7b49\u6027\u80fd\u5206\u6790\u5de5\u5177\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e76\u901a\u8fc7\u5178\u578b\u573a\u666f\uff08\u5982\u7f13\u51b2\u6c60\u5229\u7528\u7387\u4f4e\u4e0b\u3001\u4e3b\u4ece\u590d\u5236\u5ef6\u8fdf\u3001\u9ad8\u8fde\u63a5\u6570\u95ee\u9898\uff09\u5c55\u793a\u4e86\u4f18\u5316\u6b65\u9aa4\u3002\u6700\u540e\uff0c\u6587\u7ae0\u63d0\u51fa\u4e86\u81ea\u52a8\u5316\u76d1\u63a7\u4f53\u7cfb\u7684\u6784\u5efa\u65b9\u6cd5\uff0c\u5305\u62ec\u811a\u672c\u5316\u91c7\u96c6\u3001Prometheus\u96c6\u6210\u548c\u544a\u8b66\u89c4\u5219\u914d\u7f6e","og_url":"https:\/\/www.wsisp.com\/helps\/40600.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-29T08:41:18+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/40600.html","url":"https:\/\/www.wsisp.com\/helps\/40600.html","name":"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-29T08:41:18+00:00","dateModified":"2025-05-29T08:41:18+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/40600.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/40600.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/40600.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Mysql\u4e4b\u670d\u52a1\u5668\u72b6\u6001\u76d1\u63a7\u4e0e\u6027\u80fd\u5206\u6790\u5b9e\u6218"}]},{"@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\/40600","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=40600"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/40600\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=40600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=40600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=40600"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=40600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}