{"id":91280,"date":"2024-03-21T06:35:11","date_gmt":"2024-03-20T22:35:11","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=91280"},"modified":"2024-03-21T06:35:11","modified_gmt":"2024-03-20T22:35:11","slug":"mysql-master-salve","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/mysql-master-salve.html","title":{"rendered":"\u8be6\u89e3MySQL \u4e3b\u4ece\u540c\u6b65\u5ef6\u8fdf"},"content":{"rendered":"
mysql \u7528\u4e3b\u4ece\u540c\u6b65\u7684\u65b9\u6cd5\u8fdb\u884c\u8bfb\u5199\u5206\u79bb\uff0c\u51cf\u8f7b\u4e3b\u670d\u52a1\u5668\u7684\u538b\u529b\u7684\u505a\u6cd5\u73b0\u5728\u5728\u4e1a\u5185\u505a\u7684\u975e\u5e38\u666e\u904d\u3002 \u4e3b\u4ece\u540c\u6b65\u57fa\u672c\u4e0a\u80fd\u505a\u5230\u5b9e\u65f6\u540c\u6b65\u3002\u6211\u4ece\u522b\u7684\u7f51\u7ad9\u501f\u7528\u4e86\u4e3b\u4ece\u540c\u6b65\u7684\u539f\u7406\u56fe\u3002<\/p>\n
<\/p>\n
\u5728\u914d\u7f6e\u597d\u4e86\uff0c \u4e3b\u4ece\u540c\u6b65\u4ee5\u540e\uff0c \u4e3b\u670d\u52a1\u5668\u4f1a\u628a\u66f4\u65b0\u8bed\u53e5\u5199\u5165binlog, \u4ece\u670d\u52a1\u5668\u7684IO \u7ebf\u7a0b(\u8fd9\u91cc\u8981\u6ce8\u610f\uff0c 5.6.3 \u4e4b\u524d\u7684IO\u7ebf\u7a0b\u4ec5\u6709\u4e00\u4e2a\uff0c5.6.3\u4e4b\u540e\u7684\u6709\u591a\u7ebf\u7a0b\u53bb\u8bfb\u4e86\uff0c\u901f\u5ea6\u81ea\u7136\u4e5f\u5c31\u52a0\u5feb\u4e86)\u56de\u53bb\u8bfb\u53d6\u4e3b\u670d\u52a1\u5668\u7684binlog \u5e76\u4e14\u5199\u5230\u4ece\u670d\u52a1\u5668\u7684Relay log \u91cc\u9762\uff0c\u7136\u540e\u4ece\u670d\u52a1\u5668\u7684 \u7684SQL thread \u4f1a\u4e00\u4e2a\u4e00\u4e2a\u6267\u884c relay log \u91cc\u9762\u7684sql \uff0c \u8fdb\u884c\u6570\u636e\u6062\u590d\u3002<\/p>\n
relay \u5c31\u662f \u4f20\u9012, relay race \u5c31\u662f\u63a5\u529b\u8d5b\u7684\u610f\u601d<\/p>\n
\u6211\u4eec\u77e5\u9053\uff0c \u4e00\u4e2a\u670d\u52a1\u5668\u5f00\u653e\uff2e\u4e2a\u94fe\u63a5\u7ed9\u5ba2\u6237\u7aef\u6765\u8fde\u63a5\u7684\uff0c\u3000\u8fd9\u6837\u6709\u4f1a\u6709\u5927\u5e76\u53d1\u7684\u66f4\u65b0\u64cd\u4f5c, \u4f46\u662f\u4ece\u670d\u52a1\u5668\u7684\u91cc\u9762\u8bfb\u53d6binlog \u7684\u7ebf\u7a0b\u4ec5\u6709\u4e00\u4e2a\uff0c \u5f53\u67d0\u4e2aSQL\u5728\u4ece\u670d\u52a1\u5668\u4e0a\u6267\u884c\u7684\u65f6\u95f4\u7a0d\u957f \u6216\u8005\u7531\u4e8e\u67d0\u4e2aSQL\u8981\u8fdb\u884c\u9501\u8868\u5c31\u4f1a\u5bfc\u81f4\uff0c\u4e3b\u670d\u52a1\u5668\u7684SQL\u5927\u91cf\u79ef\u538b\uff0c\u672a\u88ab\u540c\u6b65\u5230\u4ece\u670d\u52a1\u5668\u91cc\u3002\u8fd9\u5c31\u5bfc\u81f4\u4e86\u4e3b\u4ece\u4e0d\u4e00\u81f4\uff0c \u4e5f\u5c31\u662f\u4e3b\u4ece\u5ef6\u8fdf\u3002<\/p>\n
\u5b9e\u9645\u4e0a\u4e3b\u4ece\u540c\u6b65\u5ef6\u8fdf\u6839\u672c\u6ca1\u6709\u4ec0\u4e48\u4e00\u62db\u5236\u654c\u7684\u529e\u6cd5\uff0c \u56e0\u4e3a\u6240\u6709\u7684SQL\u5fc5\u987b\u90fd\u8981\u5728\u4ece\u670d\u52a1\u5668\u91cc\u9762\u6267\u884c\u4e00\u904d\uff0c\u4f46\u662f\u4e3b\u670d\u52a1\u5668\u5982\u679c\u4e0d\u65ad\u7684\u6709\u66f4\u65b0\u64cd\u4f5c\u6e90\u6e90\u4e0d\u65ad\u7684\u5199\u5165\uff0c \u90a3\u4e48\u4e00\u65e6\u6709\u5ef6\u8fdf\u4ea7\u751f\uff0c \u90a3\u4e48\u5ef6\u8fdf\u52a0\u91cd\u7684\u53ef\u80fd\u6027\u5c31\u4f1a\u539f\u6765\u8d8a\u5927\u3002 \u5f53\u7136\u6211\u4eec\u53ef\u4ee5\u505a\u4e00\u4e9b\u7f13\u89e3\u7684\u63aa\u65bd\u3002<\/p>\n
a. \u6211\u4eec\u77e5\u9053\u56e0\u4e3a\u4e3b\u670d\u52a1\u5668\u8981\u8d1f\u8d23\u66f4\u65b0\u64cd\u4f5c\uff0c \u4ed6\u5bf9\u5b89\u5168\u6027\u7684\u8981\u6c42\u6bd4\u4ece\u670d\u52a1\u5668\u9ad8\uff0c \u6240\u6709\u6709\u4e9b\u8bbe\u7f6e\u53ef\u4ee5\u4fee\u6539\uff0c\u6bd4\u5982sync_binlog=1\uff0cinnodb_flush_log_at_trx_commit = 1 \u4e4b\u7c7b\u7684\u8bbe\u7f6e\uff0c\u800cslave\u5219\u4e0d\u9700\u8981\u8fd9\u4e48\u9ad8\u7684\u6570\u636e\u5b89\u5168\uff0c\u5b8c\u5168\u53ef\u4ee5\u8bb2sync_binlog\u8bbe\u7f6e\u4e3a0\u6216\u8005\u5173\u95edbinlog\uff0cinnodb_flushlog\uff0c innodb_flush_log_at_trx_commit \u4e5f \u53ef\u4ee5\u8bbe\u7f6e\u4e3a0\u6765\u63d0\u9ad8sql\u7684\u6267\u884c\u6548\u7387 \u8fd9\u4e2a\u80fd\u5f88\u5927\u7a0b\u5ea6\u4e0a\u63d0\u9ad8\u6548\u7387\u3002\u53e6\u5916\u5c31\u662f\u4f7f\u7528\u6bd4\u4e3b\u5e93\u66f4\u597d\u7684\u786c\u4ef6\u8bbe\u5907\u4f5c\u4e3aslave\u3002<\/p>\n
b. \u5c31\u662f\u628a\uff0c\u4e00\u53f0\u4ece\u670d\u52a1\u5668\u5f53\u5ea6\u4f5c\u4e3a\u5907\u4efd\u4f7f\u7528\uff0c \u800c\u4e0d\u63d0\u4f9b\u67e5\u8be2\uff0c \u90a3\u8fb9\u4ed6\u7684\u8d1f\u8f7d\u4e0b\u6765\u4e86\uff0c \u6267\u884crelay log \u91cc\u9762\u7684SQL\u6548\u7387\u81ea\u7136\u5c31\u9ad8\u4e86\u3002<\/p>\n
c. \u589e\u52a0\u4ece\u670d\u52a1\u5668\u55bd\uff0c\u8fd9\u4e2a\u76ee\u7684\u8fd8\u662f\u5206\u6563\u8bfb\u7684\u538b\u529b\uff0c \u4ece\u800c\u964d\u4f4e\u670d\u52a1\u5668\u8d1f\u8f7d\u3002<\/p>\n
MySQL\u63d0\u4f9b\u4e86\u4ece\u670d\u52a1\u5668\u72b6\u6001\u547d\u4ee4\uff0c\u53ef\u4ee5\u901a\u8fc7 show slave status \u8fdb\u884c\u67e5\u770b\uff0c \u6bd4\u5982\u53ef\u4ee5\u770b\u770bSeconds_Behind_Master\u53c2\u6570\u7684\u503c\u6765\u5224\u65ad\uff0c\u662f\u5426\u6709\u53d1\u751f\u4e3b\u4ece\u5ef6\u65f6\u3002
\n\u5176\u503c\u6709\u8fd9\u4e48\u51e0\u79cd\uff1a
\nNULL - \u8868\u793aio_thread\u6216\u662fsql_thread\u6709\u4efb\u4f55\u4e00\u4e2a\u53d1\u751f\u6545\u969c\uff0c\u4e5f\u5c31\u662f\u8be5\u7ebf\u7a0b\u7684Running\u72b6\u6001\u662fNo,\u800c\u975eYes.
\n0 - \u8be5\u503c\u4e3a\u96f6\uff0c\u662f\u6211\u4eec\u6781\u4e3a\u6e34\u671b\u770b\u5230\u7684\u60c5\u51b5\uff0c\u8868\u793a\u4e3b\u4ece\u590d\u5236\u72b6\u6001\u6b63\u5e38<\/p>\n
\n\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/blog.csdn.net\/Soar_Away\/article\/details\/72615012<\/a><\/p>\n