{"id":5160,"date":"2017-02-22T14:33:22","date_gmt":"2017-02-22T12:33:22","guid":{"rendered":"http:\/\/skeletor.org.ua\/?p=5160"},"modified":"2017-03-06T14:45:13","modified_gmt":"2017-03-06T12:45:13","slug":"mysql-got-fatal-error-1236-from-master-when-reading-data-from-binary-log","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=5160","title":{"rendered":"[mysql] Got fatal error 1236 from master when reading data from binary log"},"content":{"rendered":"<p><code>Got fatal error 1236 from master when reading data from binary log: 'Cannot replicate anonymous transaction when AUTO_POSITION = 1, at file \/database\/mysql\/mysql-bin.030053, position 154.; the first event '' at 4, the last event read from 'mysql-bin.030053' at 219, the last byte read from '\/database\/mysql\/mysql-bin.030053' at 219.'<\/code><\/p>\n<p>\u0422\u0430\u043a\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>online migration to GTID replication<\/strong>. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0438 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0431.<\/p>\n<p><!--more--><\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<p>1. \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c <strong>slave<\/strong> \u0432 \u0440\u0435\u0436\u0438\u043c <strong>ON_PERMISSIVE<\/strong>:<\/p>\n<p><code>slave&gt;\u00a0set @@GLOBAL.GTID_MODE = ON_PERMISSIVE;<\/code><\/p>\n<p>2. \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c <strong>slave<\/strong> \u043d\u0430 <strong>master&#8217;e<\/strong> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c (\u0434\u0430\u043b\u0435\u0435, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 <strong><span style=\"color: #ff0000;\">\u043f.4<\/span><\/strong> \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 <strong>gtid_purged<\/strong> \u043d\u0430 <strong>slave<\/strong>)<\/p>\n<pre>master&gt; show global variables like 'gtid_executed';\r\n+---------------+-----------------------------------------------------------------------------------------------+\r\n| Variable_name | Value |\r\n+---------------+-----------------------------------------------------------------------------------------------+\r\n| gtid_executed | 1136d9c4-0ecf-11e5-be7e-28d2445d8ed0:1-83091,\r\nbcdd5c11-9d7b-11e2-8070-49715e847bda:1-22016897 |\r\n+---------------+-----------------------------------------------------------------------------------------------+\r\n1 row in set (0.00 sec)\r\n<\/pre>\n<p>3. \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c <strong>slave<\/strong> \u043d\u0430 <strong>gtid<\/strong>:<\/p>\n<p><code>slave&gt; stop slave; set gtid_mode=on;change master to master_auto_position=1;<\/code><\/p>\n<p>4. \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438\u0437 \u043b\u043e\u0433\u0430, \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0442\u043e\u0439, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0437 <span style=\"color: #ff0000;\"><strong>\u043f.1<\/strong><\/span>:<\/p>\n<p><code>slave&gt; set global GTID_PURGED='1136d9c4-0ecf-11e5-be7e-28d2445d8ed0:1-83091,bcdd5c11-9d7b-11e2-8070-49715e847bda:1-22016897;<\/code><\/p>\n<p>\u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430<\/p>\n<p><code>ERROR 1840 (HY000): GTID_PURGED can only be set when GTID_EXECUTED is empty.<\/code><\/p>\n<p>\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c<\/p>\n<pre>slave&gt; reset master;\r\nslave&gt; show global variables like 'GTID_EXECUTED';\r\n+---------------+-------+\r\n| Variable_name | Value |\r\n+---------------+-------+\r\n| gtid_executed |       |\r\n+---------------+-------+\r\n<\/pre>\n<p>\u0438 \u0441\u043d\u043e\u0432\u0430<\/p>\n<p><code>slave&gt; set global GTID_PURGED='1136d9c4-0ecf-11e5-be7e-28d2445d8ed0:1-83091,bcdd5c11-9d7b-11e2-8070-49715e847bda:1-22016897;<\/code><\/p>\n<p>5. \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <strong>slave<\/strong><\/p>\n<p><code>slave&gt;start slave;<\/code><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff6600;\"><em><strong>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/strong><\/em><\/span><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u043e, \u0442\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a:<\/p>\n<p>a) \u0434\u0435\u043b\u0430\u0435\u043c <strong>stop slave, reset slave, reset master, change master to &#8230; master_auto_position=1;<\/strong><\/p>\n<p>b) \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u043b\u043e\u0433 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e (\u0447\u0435\u0440\u0435\u0437 <strong>stop slave<\/strong>, \u0438\u0431\u043e \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u043d\u043e \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043b\u043e\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0434\u043d\u0435\u0439 \u0438\u0434\u0451\u0442 \u0440\u0430\u043d\u044c\u0448\u0435) \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0442\u0430\u043a\u043e\u0435 (\u0443 \u043c\u0435\u043d\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0438\u0437 \u043c\u0430\u0441\u0442\u0435\u0440-\u0441\u043b\u0435\u0439\u0432\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0430\u0436 3):<\/p>\n<p><code># at 123<br \/>\n#170306 9:21:20 server id 25 end_log_pos 274 CRC32 0xadda8e15 Previous-GTIDs<br \/>\n# 1136d9c4-0ecf-11e5-be7e-28d2445d8ed0:<span style=\"color: #ff0000;\">1-93203839<\/span>,<br \/>\n# 53d58b0f-eb6f-11e6-9215-392e3ca483a1:<span style=\"color: #339966;\">1-564449<\/span>,<br \/>\n# bcdd5c11-9d7b-11e2-8070-49715e847bda:<span style=\"color: #0000ff;\">1-36168727<\/span><\/code><\/p>\n<p>c) \u0442\u0435\u043f\u0435\u0440\u044c \u0432 <strong>gtid_purged<\/strong> \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0438; \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0442\u0430\u043a (\u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043b \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 <strong>id<\/strong> \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432):<\/p>\n<p><code>Executed_Gtid_Set:<br \/>\n1136d9c4-0ecf-11e5-be7e-28d2445d8ed0:<span style=\"color: #ff0000;\">1-28:1219-83091<\/span>,<br \/>\n53d58b0f-eb6f-11e6-9215-392e3ca483a1:<span style=\"color: #008000;\">1-39715<\/span>,<br \/>\nb6f43c68-8a31-11e2-82ab-003048c1b686:1-4376,<br \/>\nbcdd5c11-9d7b-11e2-8070-49715e847bda:<span style=\"color: #0000ff;\">1-21286887<\/span><\/code><\/p>\n<p>\u0430 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u0442\u0430\u043b\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p><code>Executed_Gtid_Set:<br \/>\n1136d9c4-0ecf-11e5-be7e-28d2445d8ed0:<span style=\"color: #ff0000;\">1-93203839<\/span>,<br \/>\n53d58b0f-eb6f-11e6-9215-392e3ca483a1:<span style=\"color: #008000;\">1-564449<\/span>,<br \/>\nb6f43c68-8a31-11e2-82ab-003048c1b686:1-4377,<br \/>\nbcdd5c11-9d7b-11e2-8070-49715e847bda:<span style=\"color: #0000ff;\">1-36168727<\/span><\/code><\/p>\n<p>\u0442\u043e \u0435\u0441\u0442\u044c \u044f \u0437\u0430\u043c\u0435\u043d\u0438\u043b 3 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 4-\u043e\u0445 (4-\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u043b\u0435\u0439\u0432\u0430)<\/p>\n<p>d) \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <strong>slave<\/strong>;<\/p>\n<p><code>slave&gt;start slave;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Got fatal error 1236 from master when reading data from binary log: &#8216;Cannot replicate anonymous transaction when AUTO_POSITION = 1, at file \/database\/mysql\/mysql-bin.030053, position 154.; the first event &#8221; at 4, the last event read from &#8216;mysql-bin.030053&#8217; at 219, the last byte read from &#8216;\/database\/mysql\/mysql-bin.030053&#8242; at 219.&#8217; \u0422\u0430\u043a\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-5160","post","type-post","status-publish","format-standard","hentry","category-databases"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5160"}],"version-history":[{"count":5,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5160\/revisions"}],"predecessor-version":[{"id":5168,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5160\/revisions\/5168"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}