{"id":3125,"date":"2011-10-18T22:53:58","date_gmt":"2011-10-18T14:53:58","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=3125"},"modified":"2011-10-27T20:21:46","modified_gmt":"2011-10-27T12:21:46","slug":"semy-sync-slave-protocol-slave-reply","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2011\/10\/semy-sync-slave-protocol-slave-reply\/","title":{"rendered":"MySQL5.5 Semi-sync\u5907\u5e93\u54cd\u5e94\u534f\u8bae\u5206\u6790"},"content":{"rendered":"<p>\u8fd9\u53c8\u662f\u4e00\u7bc7\u4ecb\u7ecdSemi-sync\u7684\u6587\u7ae0\u3002<\/p>\n<p>Semi-sync\u4e3b\u5e93\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\uff08\u53ef\u914d\u7f6e\u7684\u8d85\u65f6\u65f6\u95f4\uff09\uff0c\u5982\u679c\u6ca1\u6709\u6536\u5230\u5907\u5e93\u7684\u54cd\u5e94\uff0c\u5219\u4f1a\u8d85\u65f6\u4ece\u800c\u964d\u7ea7\u4e3a\u666e\u901a\u7684replication\u590d\u5236\u3002\u5982\u679c\u8d85\u65f6\u53d1\u751f\uff0c\u6709\u65f6\u9700\u8981\u67e5\u6e05\u4ec0\u4e48\u539f\u56e0\u5bfc\u81f4\u5907\u5e93\u6ca1\u6709\u53ca\u65f6\u54cd\u5e94\uff0c\u4e00\u65b9\u9762\u53ef\u4ee5\u4ece\u5907\u5e93\u7684\u65e5\u5fd7\u7740\u624b\uff0c\u53e6\u4e00\u65b9\u9762\uff0c\u5982\u679c\u9700\u8981\u66f4\u7ec6\u81f4\u7684\u4fe1\u606f\u5219\u9700\u8981\u4ece\u5907\u5e93\u7aef\u7684\u7f51\u7edc\u5305\u67e5\u627e\u539f\u56e0\u3002\u8fd9\u91cc\u4ecb\u7ecd\u5982\u4f55\u5206\u6790\u4e00\u4e2aSemi-sync\u5907\u5e93\u54cd\u5e94\u4e3b\u5e93\u7684\u6570\u636e\u5305\u3002<\/p>\n<p>\u6982\u8ff0\uff1a\u5148\u4f7f\u7528tcpdump\u6293\u53d6\u6b63\u786e\uff08\u4e3b\u8981\u662fsrc\u548cdst\u90fd\u6b63\u786e\uff09\u7684\u6570\u636e\u5305\uff1b\u7136\u540e\u501f\u52a9wireshark\u73bb\u7483TCP\/IP\u7b49\u5c42\u7684\u5934\u4fe1\u606f\uff0c\u4ec5\u4fdd\u7559\u53d1\u9001\u7684MySQL\u6570\u636e\u5305\uff1b\u518d\u5206\u6790MySQL Semi-sync Slave\u54cd\u5e94\u7684\u534f\u8bae\u3002<\/p>\n<div class=\"myt1\">1. tcpdump\u539f\u59cb\u6570\u636e\u5305<\/div>\n<p>\u901a\u8fc7\u5982\u4e0btcpdump\u6293\u53d6\u4e3b\u673a\u7684\u7f51\u7edc\u5305\uff1a<\/p>\n<pre><div class=\"mycode\">nohup tcpdump -n -nn -tttt -i bond0 -s 65535 'port 3306 and ((dst host master.host and src host slave.host and len &lt 100) or (dst host slave.host and src host master.host))' -w tcpdump.ret -C 50 &\r\n<\/div><\/pre>\n<p>\u53c2\u6570\u7b80\u5355\u8bf4\u660e\uff1a<\/p>\n<pre><div class=\"mycode\">-n  \u8868\u793aip\u4e0d\u8981\u8f6c\u6362\u4e3a\u4e3b\u673a\u540d\r\n-nn\u8868\u793a\u7aef\u53e3\u53f7\uff0c\u4e0d\u8981\u8f6c\u4e3a\u4e3a\u670d\u52a1\u540d\uff08\u4f8b\u59823306\u4f1a\u88ab\u8f6c\u6362\u4e3amysql\uff09\r\n-tttt \u6253\u5370\u51fa\u5b8c\u6210\u7684\u683c\u5f0f\u5316\u7684\u65f6\u95f4\u6233\r\n-C 50 \u8868\u793a\u6293\u53d6\u7684\u7ed3\u679c\u653e\u5230\u6587\u4ef6\u4e2d\uff0c\u6587\u4ef6\u5927\u5c0f\u4e0d\u8d85\u8fc750MB\r\n<\/div><\/pre>\n<div class=\"myt1\">2. \u4f7f\u7528wireshark\u627e\u5230\u5bf9\u5e94\u7684\u5305<\/div>\n<p><!--more--><\/p>\n<p>Semi-sync\u5907\u5e93\u54cd\u5e94\u4e3b\u5e93\u5305\uff0c\u4e00\u822c\u5927\u5c0f\u6574\u4e2a\u5305\u5927\u5c0f\u7ea695\u5b57\u8282\u3002\u627e\u5230\u8be5\u7f51\u7edc\u5305\u5982\u4e0b\uff1a<\/p>\n<p><a href=\"http:\/\/www.orczhou.com\/wp-content\/uploads\/2011\/10\/tmp.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.orczhou.com\/wp-content\/uploads\/2011\/10\/tmp.jpg\" alt=\"\" title=\"tmp\" width=\"618\" height=\"156\" class=\"alignleft size-full wp-image-3151\" \/><\/a><\/p>\n<p>\u5b8c\u6574\u7f51\u7edc\u5305\u5185\u5bb9\uff1a<\/p>\n<pre><div class=\"mycode\">0000  00 24 e8 57 76 5e 00 1d  70 82 ca c0 08 00 45 00   .$.Wv^.. p.....E.\r\n0010  00 51 a6 e2 40 00 3e 06  89 34 ac 13 46 44 ac 17   .Q..@.>. .4..FD..\r\n0020  6e 21 b3 35 0c ea b2 2d  26 2a da 46 3c df 80 18   n!.5...- &*.F<...\r\n0030  04 82 35 ef 00 00 01 01  08 0a 5a a2 7f cd 50 43   ..5..... ..Z...PC\r\n0040  c1 5b 19 00 00 00 ef 38  40 01 00 00 00 00 00 6d   .[.....8 @......m\r\n0050  79 73 71 6c 2d 62 69 6e  2e 30 30 31 35 31 36      ysql-bin .001516 \r\n<\/div><\/pre>\n<div class=\"myt1\">3. MySQL\u6570\u636e\u5305\u5206\u6790<\/div>\n<p>\u5265\u53bbTCP\/IP\u7b49\u5c42\uff08\u4f7f\u7528wireshark\u5c31\u53ef\u4ee5\u4e86\uff09\uff0c\u5269\u4e0bMySQL \u5305\u5982\u4e0b\uff1a<\/p>\n<pre><div class=\"mycode\">0040        19 00 00 00 ef 38  40 01 00 00 00 00 00 6d   .[.....8 @......m\r\n0050  79 73 71 6c 2d 62 69 6e  2e 30 30 31 35 31 36      ysql-bin .001516 \r\n<\/div><\/pre>\n<p>\u66f4\u5177Semi-sync\u5907\u5e93\u54cd\u5e94\u6e90\u7801\u5206\u6790\u5982\u4e0b\uff1a<\/p>\n<pre><div class=\"mycode\">+============================+\r\n| packetlength      0 : 4    | \u5bf9\u5e94\u7684\uff1a19 00 00 00 \u8868\u793a\u5305\u6570\u636e\u957f\u5ea6\u4e3a0x19=25\u5b57\u8282\r\n+----------------------------+\r\n| magic_num         4 : 1    | \u5bf9\u5e94\u7684\uff1aef \u8fd9\u662f\u4e00\u4e2akPacketMagicNum\uff0c\u8868\u793a\u8fd9\u662f\u4e00\u4e2aSemi-sync slave\u54cd\u5e94\r\n+----------------------------+\r\n| binlog_pos        5 : 4    | \u5bf9\u5e94\u7684\uff1a38  40 01 00 Binlog Pos:0x14038 = 81976\r\n+----------------------------+\r\n| event_length      9 : 20   | \u5bf9\u5e94\u7684\uff1a00 00 00 00 6d 79 73 71 6c .... 31 36 \uff08mysql-bin.001516\uff09\r\n+----------------------------+\r\n<\/div><\/pre>\n<p>\u53ef\u4ee5\u770b\u51fa\uff0c\u6539\u7f51\u7edc\u5305\uff0c\u54cd\u5e94\u4e3b\u5e93\u7aef\u7684mysql-bin.001516\u4e2d\u7684\u504f\u79fb\u4e3a81976\u7684\u4e8b\u52a1\u3002<\/p>\n<div class=\"myt1\">4. \u6700\u540e\u3010\u66f4\u65b02011-10-19\u3011<\/div>\n<p>\u901a\u8fc7tcpdump\u7684\u7f51\u7edc\u5305\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u6beb\u79d2\uff08\u751a\u81f3\u5fae\u79d2\uff09\u7ea7\u522b\u6570\u636e\u5305\u7684\u4f20\u9001\u60c5\u51b5\u3002\u4f9d\u636e\u6b64\uff0c\u901a\u5e38\u53ef\u4ee5\u7cbe\u786e\u5206\u6790\u51faSemi-sync\u5728\u4f55\u65f6\u3001\u4f55\u5904\u51fa\u73b0\u8d85\u65f6\u3002\u7136\u540e\uff0c\u53ef\u4ee5\u7ee7\u7eed\u5206\u6790\u4e3a\u4f55\u51fa\u73b0\u8d85\u65f6\u3002<\/p>\n<p>That&#8217;s all&#8230;  \u8fd9\u7bc7\u67af\u71e5\u5427\uff0c\u54c8\u54c8  <\/p>\n<p><embed src=\"http:\/\/www.xiami.com\/widget\/0_1769845026\/singlePlayer.swf\" type=\"application\/x-shockwave-flash\" width=\"257\" height=\"33\" wmode=\"transparent\"><\/embed><\/p>\n<p>\u5e7f\u544a\uff1a<a href=\"http:\/\/www.orczhou.com\/index.php\/projects\/we-are-hunting-mysql-hacker\/\">\u6211\u4eec\u5bfb\u627e\u9760\u8c31\u7684\u4eba<\/a> | <a href=\"http:\/\/www.orczhou.com\/index.php\/wish-list\/\">\u611f\u8c22\u4f5c\u8005<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u53c8\u662f\u4e00\u7bc7\u4ecb\u7ecdSemi-sync\u7684\u6587\u7ae0\u3002 Semi-sync\u4e3b\u5e93\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\uff08\u53ef\u914d\u7f6e\u7684\u8d85\u65f6\u65f6\u95f4\uff09\uff0c\u5982\u679c\u6ca1\u6709\u6536\u5230\u5907\u5e93\u7684\u54cd\u5e94\uff0c\u5219\u4f1a\u8d85\u65f6\u4ece\u800c\u964d\u7ea7\u4e3a\u666e\u901a\u7684replication\u590d\u5236\u3002\u5982\u679c\u8d85\u65f6\u53d1\u751f\uff0c\u6709\u65f6\u9700\u8981\u67e5\u6e05\u4ec0\u4e48\u539f\u56e0\u5bfc\u81f4\u5907\u5e93\u6ca1\u6709\u53ca\u65f6\u54cd\u5e94\uff0c\u4e00\u65b9\u9762\u53ef\u4ee5\u4ece\u5907\u5e93\u7684\u65e5\u5fd7\u7740\u624b\uff0c\u53e6\u4e00\u65b9\u9762\uff0c\u5982\u679c\u9700\u8981\u66f4\u7ec6\u81f4\u7684\u4fe1\u606f\u5219\u9700\u8981\u4ece\u5907\u5e93\u7aef\u7684\u7f51\u7edc\u5305\u67e5\u627e\u539f\u56e0\u3002\u8fd9\u91cc\u4ecb\u7ecd\u5982\u4f55\u5206\u6790\u4e00\u4e2aSemi-sync\u5907\u5e93\u54cd\u5e94\u4e3b\u5e93\u7684\u6570\u636e\u5305\u3002 \u6982\u8ff0\uff1a\u5148\u4f7f\u7528tcpdump\u6293\u53d6\u6b63\u786e\uff08\u4e3b\u8981\u662fsrc\u548cdst\u90fd\u6b63\u786e\uff09\u7684\u6570\u636e\u5305\uff1b\u7136\u540e\u501f\u52a9wireshark\u73bb\u7483TCP\/IP\u7b49\u5c42\u7684\u5934\u4fe1\u606f\uff0c\u4ec5\u4fdd\u7559\u53d1\u9001\u7684MySQL\u6570\u636e\u5305\uff1b\u518d\u5206\u6790MySQL Semi-sync Slave\u54cd\u5e94\u7684\u534f\u8bae\u3002 1. tcpdump\u539f\u59cb\u6570\u636e\u5305 \u901a\u8fc7\u5982\u4e0btcpdump\u6293\u53d6\u4e3b\u673a\u7684\u7f51\u7edc\u5305\uff1a nohup tcpdump -n -nn -tttt -i bond0 -s 65535 &#8216;port 3306 and ((dst host master.host and src host slave.host and len &#038;lt 100) or (dst host slave.host and src host master.host))&#8217; -w tcpdump.ret -C 50 &#038; \u53c2\u6570\u7b80\u5355\u8bf4\u660e\uff1a -n \u8868\u793aip\u4e0d\u8981\u8f6c\u6362\u4e3a\u4e3b\u673a\u540d -nn\u8868\u793a\u7aef\u53e3\u53f7\uff0c\u4e0d\u8981\u8f6c\u4e3a\u4e3a\u670d\u52a1\u540d\uff08\u4f8b\u59823306\u4f1a\u88ab\u8f6c\u6362\u4e3amysql\uff09 -tttt \u6253\u5370\u51fa\u5b8c\u6210\u7684\u683c\u5f0f\u5316\u7684\u65f6\u95f4\u6233 -C 50 \u8868\u793a\u6293\u53d6\u7684\u7ed3\u679c\u653e\u5230\u6587\u4ef6\u4e2d\uff0c\u6587\u4ef6\u5927\u5c0f\u4e0d\u8d85\u8fc750MB 2. \u4f7f\u7528wireshark\u627e\u5230\u5bf9\u5e94\u7684\u5305<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[6,5],"tags":[69,70,71],"class_list":["post-3125","post","type-post","status-publish","format-standard","hentry","category-mysql","category-code-staff","tag-mysql5-5","tag-semi-sync-replication","tag-71"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/3125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=3125"}],"version-history":[{"count":21,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/3125\/revisions"}],"predecessor-version":[{"id":3249,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/3125\/revisions\/3249"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=3125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=3125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=3125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}