{"id":5527,"date":"2024-11-14T09:12:42","date_gmt":"2024-11-14T01:12:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5527\/"},"modified":"2024-11-14T09:12:42","modified_gmt":"2024-11-14T01:12:42","slug":"mysql%e9%97%aa%e9%80%80%e6%80%8e%e4%b9%88%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5527\/","title":{"rendered":"mysql\u95ea\u9000\u600e\u4e48\u89e3\u51b3"},"content":{"rendered":"<blockquote><p>\n  mysql\u95ea\u9000\u89e3\u51b3\u65b9\u6848\uff1a\u786e\u5b9a\u539f\u56e0\uff1a\u68c0\u67e5\u9519\u8bef\u65e5\u5fd7\u3001\u7cfb\u7edf\u65e5\u5fd7\u548culimit\u3002\u68c0\u67e5\u53ef\u7528\u8d44\u6e90\uff1a\u786e\u4fdd\u8db3\u591f\u5185\u5b58\u3001cpu\u548c\u78c1\u76d8\u7a7a\u95f4\u3002\u4f18\u5316\u914d\u7f6e\uff1a\u8c03\u6574innodb_buffer_pool_size\u3001innodb_log_file_size\u548cinnodb_flush_log_at_trx_commit\u3002\u4fee\u590d\u635f\u574f\u7684\u6570\u636e\uff1a\u4f7f\u7528check table\u548crepair table\u8bed\u53e5\u3002\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879\uff1a\u5b9a\u671f\u5907\u4efd\u3001\u76d1\u63a7\u670d\u52a1\u5668\u548c\u4fdd\u6301\u6700\u65b0\u66f4\u65b0\u7248\u672c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052908003563317.jpg\" class=\"aligncenter\" title=\"mysql\u95ea\u9000\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" alt=\"mysql\u95ea\u9000\u600e\u4e48\u89e3\u51b3\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL\u95ea\u9000\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>MySQL\u95ea\u9000\uff0c\u5373\u670d\u52a1\u5668\u610f\u5916\u5173\u95ed\uff0c\u8fd9\u53ef\u80fd\u9020\u6210\u548c\u5176\u4ed6\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u89e3\u51b3MySQL\u95ea\u9000\uff1a<\/p>\n<p><strong>1. \u786e\u5b9a\u539f\u56e0<\/strong><\/p>\n<ul>\n<li> <strong>\u9519\u8bef\u65e5\u5fd7\uff1a<\/strong>\u68c0\u67e5MySQL\u9519\u8bef\u65e5\u5fd7\uff08\u901a\u5e38\u4f4d\u4e8e\/var\/log\/\/error.log\uff09\u4ee5\u83b7\u53d6\u5bfc\u81f4\u95ea\u9000\u7684\u7ec6\u8282\u3002<\/li>\n<li> <strong>\u7cfb\u7edf\u65e5\u5fd7\uff1a<\/strong>\u68c0\u67e5\u7cfb\u7edf\u65e5\u5fd7\uff08\u901a\u5e38\u4f4d\u4e8e\/var\/log\/messages\uff09\u4ee5\u67e5\u627e\u4e0eMySQL\u76f8\u5173\u7684\u9519\u8bef\u3002<\/li>\n<li> <strong>ulimit\uff1a<\/strong>\u68c0\u67e5MySQL\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236\uff08ulimit\uff09\u3002\u5982\u679c\u67d0\u4e9b\u9650\u5236\uff08\u5982\u5185\u5b58\u6216\u6587\u4ef6\u63cf\u8ff0\u7b26\uff09\u5df2\u8fbe\u5230\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u95ea\u9000\u3002<\/li>\n<\/ul>\n<p><strong>2. \u68c0\u67e5\u53ef\u7528\u8d44\u6e90<\/strong><\/p>\n<ul>\n<li> <strong>\u5185\u5b58\uff1a<\/strong>\u786e\u4fddMySQL\u670d\u52a1\u5668\u6709\u8db3\u591f\u7684\u5185\u5b58\u3002<\/li>\n<li> <strong>CPU\uff1a<\/strong>\u68c0\u67e5\u670d\u52a1\u5668\u7684CPU\u4f7f\u7528\u7387\u662f\u5426\u8fc7\u9ad8\u3002<\/li>\n<li> <strong>\u78c1\u76d8\u7a7a\u95f4\uff1a<\/strong>\u786e\u4fddMySQL\u6570\u636e\u76ee\u5f55\u6709\u8db3\u591f\u7684\u53ef\u7528\u7a7a\u95f4\u3002<\/li>\n<\/ul>\n<p><strong>3. <\/strong><\/p>\n<ul>\n<li> <strong>innodb_buffer_pool_size\uff1a<\/strong>\u8c03\u6574InnoDB\u7f13\u51b2\u6c60\u7684\u5927\u5c0f\uff0c\u4ee5\u4f18\u5316\u67e5\u8be2\u6027\u80fd\u5e76\u51cf\u5c11\u95ea\u9000\u98ce\u9669\u3002<\/li>\n<li> <strong>innodb_log_file_size\uff1a<\/strong>\u8c03\u6574InnoDB\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u4ee5\u51cf\u5c11\u65e5\u5fd7\u5207\u6362\u671f\u95f4\u7684\u505c\u673a\u65f6\u95f4\u3002<\/li>\n<li> <strong>innodb_flush_log_at_trx_commit\uff1a<\/strong>\u5c06\u6b64\u8bbe\u7f6e\u66f4\u6539\u4e3a2\uff0c\u4ee5\u5728\u6bcf\u4e2a\u4e8b\u52a1\u63d0\u4ea4\u65f6\u5237\u65b0\u65e5\u5fd7\uff0c\u4ece\u800c\u63d0\u9ad8\u6027\u80fd\u5e76\u51cf\u5c11\u95ea\u9000\u98ce\u9669\u3002<\/li>\n<\/ul>\n<p><strong>4. \u4fee\u590d\u635f\u574f\u7684\u6570\u636e<\/strong><\/p>\n<ul>\n<li> <strong>CHECK TABLE\uff1a<\/strong>\u4f7f\u7528CHECK TABLE\u8bed\u53e5\u68c0\u67e5\u5e76\u4fee\u590d\u635f\u574f\u7684\u6570\u636e\u8868\u3002<\/li>\n<li> <strong>REPAIR TABLE\uff1a<\/strong>\u4f7f\u7528REPAIR TABLE\u8bed\u53e5\u4fee\u590d\u635f\u574f\u7684\u6570\u636e\u8868\uff08\u6bd4CHECK TABLE\u66f4\u5177\u4fb5\u5165\u6027\uff09\u3002<\/li>\n<\/ul>\n<p><strong>5. \u5176\u4ed6\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li> <strong>\u5b9a\u671f\u5907\u4efd\uff1a<\/strong>\u59cb\u7ec8\u5b9a\u671f\u5907\u4efd\u6570\u636e\u5e93\uff0c\u4ee5\u9632\u4e07\u4e00\u51fa\u73b0\u6570\u636e\u4e22\u5931\u3002<\/li>\n<li> <strong>\u76d1\u63a7\u670d\u52a1\u5668\uff1a<\/strong>\u4f7f\u7528\u76d1\u63a7\u5de5\u5177\u6216\u811a\u672c\u6765\u76d1\u89c6MySQL\u670d\u52a1\u5668\u7684\u8fd0\u884c\u72b6\u51b5\u5e76\u68c0\u6d4b\u6f5c\u5728\u95ee\u9898\u3002<\/li>\n<li> <strong>\u5b9a\u671f\u66f4\u65b0\uff1a<\/strong>\u4fdd\u6301MySQL\u8f6f\u4ef6\u548c\u64cd\u4f5c\u7cfb\u7edf\u662f\u6700\u65b0\u7684\uff0c\u4ee5\u89e3\u51b3\u5df2\u77e5\u95ee\u9898\u548c\u6f0f\u6d1e\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u95ea\u9000\u600e\u4e48\u89e3\u51b3\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql\u95ea\u9000\u89e3\u51b3\u65b9\u6848\uff1a\u786e\u5b9a\u539f\u56e0\uff1a\u68c0\u67e5\u9519\u8bef\u65e5\u5fd7\u3001\u7cfb\u7edf\u65e5\u5fd7\u548culimit\u3002\u68c0\u67e5\u53ef\u7528\u8d44\u6e90\uff1a\u786e\u4fdd\u8db3\u591f\u5185\u5b58\u3001cpu\u548c\u78c1\u76d8\u7a7a\u95f4\u3002\u4f18\u5316\u914d\u7f6e\uff1a\u8c03\u6574innodb_buffer_pool_size\u3001innodb_log_file_size\u548cinnodb_flush_log_at_trx_commit\u3002\u4fee\u590d\u635f\u574f\u7684\u6570\u636e\uff1a\u4f7f\u7528check table\u548crepair table\u8bed\u53e5\u3002\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879\uff1a\u5b9a\u671f\u5907\u4efd\u3001\u76d1\u63a7\u670d\u52a1\u5668\u548c\u4fdd\u6301\u6700\u65b0\u66f4\u65b0\u7248\u672c\u3002 MySQL\u95ea\u9000\u89e3\u51b3\u65b9\u6848 MySQL\u95ea\u9000\uff0c\u5373\u670d\u52a1\u5668\u610f\u5916\u5173\u95ed\uff0c\u8fd9\u53ef\u80fd\u9020\u6210\u548c\u5176\u4ed6\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u89e3\u51b3MySQL\u95ea\u9000\uff1a 1. \u786e\u5b9a\u539f\u56e0 \u9519\u8bef\u65e5\u5fd7\uff1a\u68c0\u67e5MySQL\u9519\u8bef\u65e5\u5fd7\uff08\u901a\u5e38\u4f4d\u4e8e\/var\/log\/\/error.log\uff09\u4ee5\u83b7\u53d6\u5bfc\u81f4\u95ea\u9000\u7684\u7ec6\u8282\u3002 \u7cfb\u7edf\u65e5\u5fd7\uff1a\u68c0\u67e5\u7cfb\u7edf\u65e5\u5fd7\uff08\u901a\u5e38\u4f4d\u4e8e\/var\/log\/messages\uff09\u4ee5\u67e5\u627e\u4e0eMySQL\u76f8\u5173\u7684\u9519\u8bef\u3002 ulimit\uff1a\u68c0\u67e5MySQL\u8fdb\u7a0b\u7684\u8d44\u6e90\u9650\u5236\uff08ulimit\uff09\u3002\u5982\u679c\u67d0\u4e9b\u9650\u5236\uff08\u5982\u5185\u5b58\u6216\u6587\u4ef6\u63cf\u8ff0\u7b26\uff09\u5df2\u8fbe\u5230\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u95ea\u9000\u3002 2. \u68c0\u67e5\u53ef\u7528\u8d44\u6e90 \u5185\u5b58\uff1a\u786e\u4fddMySQL\u670d\u52a1\u5668\u6709\u8db3\u591f\u7684\u5185\u5b58\u3002 CPU\uff1a\u68c0\u67e5\u670d\u52a1\u5668\u7684CPU\u4f7f\u7528\u7387\u662f\u5426\u8fc7\u9ad8\u3002 \u78c1\u76d8\u7a7a\u95f4\uff1a\u786e\u4fddMySQL\u6570\u636e\u76ee\u5f55\u6709\u8db3\u591f\u7684\u53ef\u7528\u7a7a\u95f4\u3002 3. innodb_buffer_pool_size\uff1a\u8c03\u6574InnoDB\u7f13\u51b2\u6c60\u7684\u5927\u5c0f\uff0c\u4ee5\u4f18\u5316\u67e5\u8be2\u6027\u80fd\u5e76\u51cf\u5c11\u95ea\u9000\u98ce\u9669\u3002 innodb_log_file_size\uff1a\u8c03\u6574InnoDB\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u4ee5\u51cf\u5c11\u65e5\u5fd7\u5207\u6362\u671f\u95f4\u7684\u505c\u673a\u65f6\u95f4\u3002 innodb_flush_log_at_trx_commit\uff1a\u5c06\u6b64\u8bbe\u7f6e\u66f4\u6539\u4e3a2\uff0c\u4ee5\u5728\u6bcf\u4e2a\u4e8b\u52a1\u63d0\u4ea4\u65f6\u5237\u65b0\u65e5\u5fd7\uff0c\u4ece\u800c\u63d0\u9ad8\u6027\u80fd\u5e76\u51cf\u5c11\u95ea\u9000\u98ce\u9669\u3002 4. \u4fee\u590d\u635f\u574f\u7684\u6570\u636e CHECK TABLE\uff1a\u4f7f\u7528CHECK TABLE\u8bed\u53e5\u68c0\u67e5\u5e76\u4fee\u590d\u635f\u574f\u7684\u6570\u636e\u8868\u3002 REPAIR TABLE\uff1a\u4f7f\u7528REPAIR TABLE\u8bed\u53e5\u4fee\u590d\u635f\u574f\u7684\u6570\u636e\u8868\uff08\u6bd4CHECK TABLE\u66f4\u5177\u4fb5\u5165\u6027\uff09\u3002 5. \u5176\u4ed6\u6ce8\u610f\u4e8b\u9879 \u5b9a\u671f\u5907\u4efd\uff1a\u59cb\u7ec8\u5b9a\u671f\u5907\u4efd\u6570\u636e\u5e93\uff0c\u4ee5\u9632\u4e07\u4e00\u51fa\u73b0\u6570\u636e\u4e22\u5931\u3002 \u76d1\u63a7\u670d\u52a1\u5668\uff1a\u4f7f\u7528\u76d1\u63a7\u5de5\u5177\u6216\u811a\u672c\u6765\u76d1\u89c6MySQL\u670d\u52a1\u5668\u7684\u8fd0\u884c\u72b6\u51b5\u5e76\u68c0\u6d4b\u6f5c\u5728\u95ee\u9898\u3002 \u5b9a\u671f\u66f4\u65b0\uff1a\u4fdd\u6301MySQL\u8f6f\u4ef6\u548c\u64cd\u4f5c\u7cfb\u7edf\u662f\u6700\u65b0\u7684\uff0c\u4ee5\u89e3\u51b3\u5df2\u77e5\u95ee\u9898\u548c\u6f0f\u6d1e\u3002 \u4ee5\u4e0a\u5c31\u662f\u95ea\u9000\u600e\u4e48\u89e3\u51b3\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5527","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5527"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5527\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}