{"id":347468,"date":"2023-05-15T09:02:10","date_gmt":"2023-05-15T09:02:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347468"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347468","title":{"rendered":"<span>\u041d\u0430\u0437\u0430\u0434 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0435: \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c MySQL \u043d\u0430 \u0442\u043e\u0447\u043a\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<h2>Intro<\/h2>\n<p>Point in Time Recovery (PiTR)&nbsp;\u2014 \u044d\u0442\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430&nbsp;\u043a\u0430\u043a\u043e\u0439\u2011\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e&nbsp;\u0441\u0435\u043a\u0443\u043d\u0434 \u0438\u043b\u0438&nbsp;\u0434\u043e&nbsp;\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438).<\/p>\n<p>PiTR \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f&nbsp;\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u00ab\u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043c\u043e\u0435\u00bb. \u0415\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u043d\u0430&nbsp;\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437&nbsp;\u043f\u043e\u0442\u0435\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7f8\/e92\/a93\/7f8e92a9348cf65fa02282924d3e48d3.jpg\" width=\"3000\" height=\"2668\"><\/figure>\n<blockquote>\n<p><strong>Fun fact:<\/strong> \u0432 MySQL client \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>--i-am-a-dummy<\/code> [<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/mysql-tips.html#safe-updates\" rel=\"noopener noreferrer nofollow\">doc<\/a>], \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u0430\u043a \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 &#8212; <code>UPDATE<\/code> \u0438 <code>DELETE<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0435\u0437 <code>WHERE<\/code> \/ <code>LIMIT<\/code> \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430<\/p>\n<\/blockquote>\n<p>\u0422\u0435\u043e\u0440\u0438\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e&nbsp;\u0434\u043b\u044f&nbsp;\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u043d\u0430&nbsp;\u0442\u043e\u0447\u043a\u0443 \u0432\u043e&nbsp;\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u043d\u0435\u043f\u0448\u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a&nbsp;\u043d\u0435\u043c\u0443 \u043b\u043e\u0433 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 (\u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Replicated State Machine). \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (\u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442&nbsp;\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435&nbsp;\u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442&nbsp;\u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432&nbsp;\u2014 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438\u043c\u0435\u043d\u0438 \u0445\u043e\u0441\u0442\u0430 \u0438&nbsp;\u0442.&nbsp;\u043f.), \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435&nbsp;\u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442&nbsp;\u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0432&nbsp;\u043f\u0440\u043e\u0448\u043b\u043e\u043c. \u041a&nbsp;\u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0442\u0443\u043b\u0438\u043d\u0433 \u0432\u043e\u043a\u0440\u0443\u0433 MySQL \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043d\u0435\u043f\u0448\u043e\u0442\u044b (\u0431\u0435\u043a\u0430\u043f\u044b), \u0430&nbsp;\u0431\u0438\u043d\u043b\u043e\u0433 \u043a\u0430\u043a&nbsp;\u0440\u0430\u0437 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u043e\u0433 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<h2>PiTR \u043a\u0430\u043a \u0437\u0430\u0432\u0435\u0449\u0430\u043b\u0438 \u0434\u0435\u0434\u044b<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/660\/89c\/c8c\/66089cc8c7eaf4526e7b059cf6a23444.jpg\" width=\"2952\" height=\"2528\"><\/figure>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0433\u043e\u0434\u0430\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0439 PiTR, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432&nbsp;\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 [<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/point-in-time-recovery.html\" rel=\"noopener noreferrer nofollow\">link<\/a>]:<\/p>\n<ol>\n<li>\n<p>\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 MySQL \u0438\u0437&nbsp;\u0431\u0435\u043a\u0430\u043f\u0430&nbsp;\u2014 \u043d\u0435&nbsp;\u0432\u0430\u0436\u043d\u043e, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e (<code>xtrabackup<\/code>) \u0438\u043b\u0438&nbsp;\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e (<code>mysqldump<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <code>mysqld<\/code><\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0440\u0451\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0438 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>mysqlbinlog --stop-datetime \"1985-10-26 01:21:00\" &lt;binlog_name&gt; | mysql<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u043a&nbsp;MySQL (\u043f\u0440\u0438&nbsp;\u0436\u0435\u043b\u0430\u043d\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c <code>--stop-position<\/code>, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441&nbsp;\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e&nbsp;\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438). \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\n<p><code>mysqlbinlog<\/code> \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437&nbsp;binlog \u0432&nbsp;plain SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0447\u0435\u0440\u0435\u0437 unix pipe \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 <code>mysql-client<\/code><\/p>\n<\/li>\n<li>\n<p><code>mysql-client<\/code> \u043f\u043e&nbsp;\u0441\u0435\u0442\u0438 (\u043e\u0431\u044b\u0447\u043d\u043e \u0447\u0435\u0440\u0435\u0437 localhost) \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432&nbsp;MySQL \u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>MySQL \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043e\u0434\u043d\u0443 \u0437\u0430&nbsp;\u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d \u0433\u043e\u0434\u0430\u043c\u0438&nbsp;\u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u043e. \u041d\u043e&nbsp;\u043a\u0430\u043a&nbsp;\u0432\u0438\u0434\u043d\u043e \u0438\u0437&nbsp;\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b&nbsp;\u2014 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u041a&nbsp;\u0442\u043e\u043c\u0443&nbsp;\u0436\u0435 \u043f\u0440\u0438&nbsp;\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0430 \u0432&nbsp;SQL \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e&nbsp;binlog grop commit [<a href=\"https:\/\/habr.com\/ru\/articles\/684474\/\" rel=\"noopener noreferrer nofollow\">link<\/a>] \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u0434\u043d\u0430 \u0437\u0430&nbsp;\u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<h2>PITR \u0441\u043e \u0441\u0442\u0438\u043b\u0435\u043c<\/h2>\n<p>\u0414\u043b\u044f&nbsp;\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0448\u0432\u0435\u0439\u0446\u0430\u0440\u0441\u043a\u0438\u0439 \u043d\u043e\u0436 \u0431\u0435\u043a\u0430\u043f\u043e\u0432 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445&nbsp;\u2014 <strong>wal\u2011g.<\/strong> \u042d\u0442\u043e\u0442 \u0442\u0443\u043b \u0437\u0430\u0431\u0451\u0440\u0435\u0442 \u043d\u0430&nbsp;\u0441\u0435\u0431\u044f \u0431\u041e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0433\u043e\u043b\u043e\u0432\u043d\u044f\u043a\u0430&nbsp;\u2014 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0431\u0435\u043a\u0430\u043f\u043e\u0432 \u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432 \u043d\u0430&nbsp;\u0432\u043d\u0435\u0448\u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (S3), \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/09d\/57d\/d28\/09d57dd2812dbf83a32b95ee24190e52.jpg\" width=\"3000\" height=\"2272\"><\/figure>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u0442\u0435\u043d\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c <code>percona-server<\/code> \u0438 \u044f\u0432\u043d\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043c:<\/p>\n<pre><code># Set unique server_id server_id=1  # Enable GTIDs gtid_mode=ON enforce_gtid_consistency=ON  # Enable Group Commit slave_parallel_type=LOGICAL_CLOCK slave_parallel_workers=8<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c [<a href=\"https:\/\/github.com\/wal-g\/wal-g#development\" rel=\"noopener noreferrer nofollow\">link<\/a>] (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u043e\u0447\u043d\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438) \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c wal-g :<\/p>\n<pre><code># Typical MySQL config WALG_MYSQL_DATASOURCE_NAME=root:Qwerty12345@tcp(localhost:3306)\/habr WALG_STREAM_CREATE_COMMAND=\/usr\/bin\/xtrabackup --backup --stream=xbstream --datadir=\/var\/lib\/mysql WALG_STREAM_RESTORE_COMMAND=xbstream -x -C \/var\/lib\/mysql WALG_MYSQL_BACKUP_PREPARE_COMMAND=xtrabackup --prepare --target-dir=\/var\/lib\/mysql WALG_MYSQL_BINLOG_REPLAY_COMMAND=mysqlbinlog --stop-datetime=\"$WALG_MYSQL_BINLOG_END_TS\" \"$WALG_MYSQL_CURRENT_BINLOG\" | mysql WALG_MYSQL_BINLOG_DST=\/var\/lib\/mysql\/my-binlogs  # (De)compress backup in 6 threads: WALG_STREAM_SPLITTER_PARTITIONS=6 WALG_COMPRESSION_METHOD=zstd  # Storage WALG_S3_PREFIX=s3:\/\/backet-name\/mysql\/ AWS_ENDPOINT=storage.yandexcloud.net AWS_ACCESS_KEY_ID=&lt;key_id&gt; AWS_SECRET_ACCESS_KEY=&lt;access_key&gt;<\/code><\/pre>\n<p>\u0421\u043d\u0438\u043c\u0435\u043c \u0431\u0435\u043a\u0430\u043f:<\/p>\n<pre><code>wal-g-mysql --turbo --config .walg.properties backup-push<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443:<\/p>\n<pre><code>sysbench --db-driver=mysql --mysql-user=&lt;user&gt; --mysql-password=&lt;pwd&gt; --mysql-db=habr --range_size=100 --table_size=10000000 --tables=16 --threads=32 --time=3000 \/usr\/share\/sysbench\/oltp_read_write.lua preapre sysbench --db-driver=mysql --mysql-user=&lt;user&gt; --mysql-password=&lt;pwd&gt; --mysql-db=habr --range_size=100 --table_size=10000000 --tables=16 --threads=32 --time=3000 \/usr\/share\/sysbench\/oltp_read_write.lua run<\/code><\/pre>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 (\u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u043b\u0430\u0442\u044c cron-\u043e\u043c \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0441 flock):<\/p>\n<pre><code>mysql &gt; FLUSH LOGS; bash  &gt; wal-g-mysql --config .walg.properties  binlog-push<\/code><\/pre>\n<p>\u0423\u0440\u0430! \u041c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438!<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0435\u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043c\u043e \u201c\u0438\u0441\u043f\u043e\u0440\u0442\u0438\u043c\u201d \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445\u2026 \u0418 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0435 \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441 \u0441\u0430\u0439\u0442\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 wal-g [<a href=\"https:\/\/wal-g.readthedocs.io\/MySQL\/\" rel=\"noopener noreferrer nofollow\">link<\/a>].<\/p>\n<pre><code>service mysql stop rm -rf \/var\/lib\/mysql\/*  # Oops!  (1) wal-g-mysql --turbo --config .walg.properties backup-fetch LATEST \u23f1\ufe0f&nbsp;real    1m44.531s  (2) service mysql start (3) gtids=$(tr -d '\\n' &lt; \/var\/lib\/mysql\/xtrabackup_binlog_info | awk '{print $3}') (4) mysql -e \"RESET MASTER; SET @@GLOBAL.GTID_PURGED='$gtids';\"  time wal-g-mysql --turbo --config .walg.properties binlog-replay --since LATEST --until \"2030-01-02T15:04:05Z \u23f1\ufe0f&nbsp;real    118m3.330s<\/code><\/pre>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0435\u043a\u0430\u043f\u0430 \u0437\u0430\u043d\u044f\u043b\u043e 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432 <strong>118 \u043c\u0438\u043d\u0443\u0442<\/strong>(!). \u041c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b sysbench (50 \u043c\u0438\u043d\u0443\u0442), \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438.<\/p>\n<p>\u0411\u0430\u0437\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430, PROD \u0441\u043f\u0430\u0441\u0435\u043d! \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<\/p>\n<h2>PiTR like a rock-star<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c68\/d0f\/3cb\/c68d0f3cb3bb2685568e31c96668c7bf.jpg\" width=\"2937\" height=\"1467\"><\/figure>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0443\u0432\u0438\u0434\u0435\u043b \u0432&nbsp;\u0431\u043b\u043e\u0433\u0435 [<a href=\"https:\/\/lefred.be\/content\/howto-make-mysql-point-in-time-recovery-faster\/\" rel=\"noopener noreferrer nofollow\">link<\/a>][<a href=\"https:\/\/www.slideshare.net\/lefred.descamps\/fosdem-mysql-friends-devroomffebruary-2018-mysql-pointintime-recovery-like-a-rockstar\" rel=\"noopener noreferrer nofollow\">slides<\/a>][<a href=\"https:\/\/www.youtube.com\/watch?v=PinKYCfv1MM&amp;t=1787s\" rel=\"noopener noreferrer nofollow\">video<\/a>] Fr\u00e9d\u00e9ric (Lefred) Descamps. \u0418\u0434\u0435\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432&nbsp;\u0442\u043e\u043c, \u0447\u0442\u043e&nbsp;\u043c\u043e\u0436\u043d\u043e \u00ab\u043f\u043e\u0434\u0441\u0443\u043d\u0443\u0442\u044c\u00bb \u0441\u0435\u0440\u0432\u0435\u0440\u0443 MySQL \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u043a\u0430\u043a&nbsp;\u0431\u0443\u0434\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e&nbsp;\u0441\u043a\u0430\u0447\u0430\u043b \u0441&nbsp;\u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u043d\u043e&nbsp;\u0435\u0449\u0435 \u043d\u0435&nbsp;\u0443\u0441\u043f\u0435\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c. \u0412&nbsp;MySQL \u0442\u0430\u043a\u0438\u0435 \u043b\u043e\u0433\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f relay logs. MySQL, \u0443\u0432\u0438\u0434\u0435\u0432 relay logs, \u043d\u0430\u0447\u043d\u0451\u0442 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0430\u043a&nbsp;\u0431\u044b\u0441\u0442\u0440\u043e, \u043a\u0430\u043a&nbsp;\u0441\u043c\u043e\u0436\u0435\u0442!<\/p>\n<p>\u0412 <code>my.cnf<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c slave\u2011threads, \u0447\u0442\u043e\u0431\u044b \u043d\u0435&nbsp;\u0441\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0444\u0430\u043b\u044c\u0441\u0442\u0430\u0440\u0442, \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u043a&nbsp;\u043c\u044b \u043d\u0430\u0437\u043e\u0432\u0451\u043c relay log\u2011\u0438:<\/p>\n<pre><code>skip-slave-start relay_log=mysql1<\/code><\/pre>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0431\u0430\u0437\u0443 \u0438\u0437 \u0431\u0435\u043a\u0430\u043f\u0430, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 (\u0448\u0430\u0433\u0438 1-4). \u0414\u0430\u043b\u0435\u0435, \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438:<\/p>\n<pre><code>time wal-g-mysql --turbo --config .walg.properties binlog-fetch --since LATEST --until \"2030-01-02T15:04:05Z\" \u23f1\ufe0f&nbsp;real    1m39.685s<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u043d\u0430\u0448\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0432 relay \u043b\u043e\u0433\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b\u043e \u0441 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435\u043c MySQL:<\/p>\n<pre><code>cd \/var\/lib\/mysql  for i in $(ls my-binlogs\/*.0*)  do     ext=$(echo $i | cut -d'.' -f2);    mv $i mysql1-relay-bin.$ext;  done<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code>cd \/var\/lib\/mysql ls .\/mysql1-relay-bin.0* &gt; mysql1-relay-bin.index<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438:<\/p>\n<pre><code>mysql&gt; SET GLOBAL SERVER_ID = 99; mysql&gt; CHANGE REPLICATION SOURCE  TO RELAY_LOG_FILE='mysql1-relay-bin.000057', RELAY_LOG_POS=1, SOURCE_HOST='dummy'; mysql&gt; START REPLICA SQL_THREAD;<\/code><\/pre>\n<p>\u042e\u2011\u0445\u0443! \u0411\u0435\u043a\u0430\u043f \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u0437\u0430 2&nbsp;\u043c\u0438\u043d\u0443\u0442\u044b, \u0437\u0430 2&nbsp;\u043c\u0438\u043d\u0443\u0442\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0438 \u0437\u0430 <strong>45&nbsp;\u043c\u0438\u043d\u0443\u0442<\/strong> \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438! \u0411\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432&nbsp;\u0434\u0432\u0430 \u0440\u0430\u0437\u0430&nbsp;\u0431\u044b\u0441\u0442\u0440\u0435\u0435!<\/p>\n<p>\u0422\u0430\u043a&nbsp;\u0436\u0435 \u0432&nbsp;\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c, \u0447\u0442\u043e&nbsp;MySQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043b\u044f&nbsp;\u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f group commit:<\/p>\n<pre><code>mysql&gt; SHOW PROCESSLIST +----+-----------------+-----------+------+---------+-------+---------------------------------------------+------------------+---------+-----------+---------------+ | Id | User            | Host      | db   | Command | Time  | State                                       | Info             | Time_ms | Rows_sent | Rows_examined | +----+-----------------+-----------+------+---------+-------+---------------------------------------------+------------------+---------+-----------+---------------+ |  5 | event_scheduler | localhost | NULL | Daemon  |   190 | Waiting on empty queue                      | NULL             |  190001 |         0 |             0 | | 10 | root            | localhost | NULL | Query   |     0 | init                                        | show processlist |       0 |         0 |             0 | | 35 | system user     |           | NULL | Query   |     0 | Waiting for dependent transaction to commit | NULL             |       0 |         0 |             0 | | 36 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 37 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 38 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 39 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 40 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 41 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 42 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 43 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | +----+-----------------+-----------+------+---------+-------+---------------------------------------------+------------------+---------+-----------+---------------+<\/code><\/pre>\n<h2>Supersonic PiTR<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eab\/9c3\/72c\/eab9c372ce650da4a05c27a5a9d04193.jpg\" width=\"3000\" height=\"3000\"><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u0431\u044b\u0441\u0442\u0440\u043e, \u0438 \u043d\u0435 \u0438\u0441\u043f\u0430\u0447\u043a\u0430\u0432\u0448\u0438\u0441\u044c \u0432 bash? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <code>wal-g binlog-server<\/code>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c\u0441\u044f MySQL master-\u043e\u043c \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0441 S3 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0441\u0440\u0430\u0437\u0443 \u0432 \u043d\u0430\u0448 MySQL. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d \u0432\u043e\u0437\u044c\u043c\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0437\u0430\u0431\u043e\u0442\u0443 \u043e \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u0414\u043e\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c mysql:<\/p>\n<pre><code>relay_log_space_limit=8589934592 skip-slave-start<\/code><\/pre>\n<p>\u0438 wal-g<\/p>\n<pre><code>WALG_MYSQL_BINLOG_SERVER_HOST=localhost WALG_MYSQL_BINLOG_SERVER_PORT=9306 WALG_MYSQL_BINLOG_SERVER_USER=walg WALG_MYSQL_BINLOG_SERVER_PASSWORD=walgpwd WALG_MYSQL_BINLOG_SERVER_ID=99  WALG_MYSQL_BINLOG_SERVER_REPLICA_SOURCE=root:Qwerty12345@127.0.0.1:3306\/habr<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c MySQL \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0438\u0437 \u0431\u0435\u043a\u0430\u043f\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>wal-g backup-fetch<\/code> (\u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u043d\u0430\u043c \u0448\u0430\u0433\u0438 1-4 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438)<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <code>wal-g binlog-server<\/code><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c MySQL<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0441 wal-g:<\/p>\n<\/li>\n<\/ul>\n<pre><code>SET GLOBAL SERVER_ID=999; CHANGE MASTER TO MASTER_HOST=\"127.0.0.1\", MASTER_PORT=9306, MASTER_USER=\"walg\", MASTER_PASSWORD=\"walgpwd\", MASTER_AUTO_POSITION=1; SHOW REPLICA STATUS \\G START REPLICA;<\/code><\/pre>\n<ul>\n<li>\n<p>\u043f\u043e\u043f\u0438\u0432\u0430\u0435\u043c \u0441\u043c\u0443\u0437\u0438, \u043f\u043e\u043a\u0430 wal-g \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430&nbsp;\u043c\u043e\u0451\u043c \u0441\u0442\u0435\u043d\u0434\u0435 \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0443\u043b\u043e\u0436\u0438\u043b\u0441\u044f \u0432 <strong>48&nbsp;\u043c\u0438\u043d\u0443\u0442<\/strong>, \u0447\u0442\u043e&nbsp;\u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u043e \u043a&nbsp;\u043f\u043e\u0434\u0445\u043e\u0434\u0443 \u00ablike a rock\u2011star\u00bb, \u0435\u0441\u043b\u0438 \u0443\u0447\u0435\u0441\u0442\u044c 2&nbsp;\u043c\u0438\u043d\u0443\u0442\u044b \u043d\u0430&nbsp;\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0443 \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432. \u0412&nbsp;\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 \u044f&nbsp;\u0431\u044b \u043e\u0436\u0438\u0434\u0430\u043b, \u0447\u0442\u043e&nbsp;\u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442&nbsp;\u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0437\u0430&nbsp;\u0441\u0447\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432 \u0438 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043b\u044e\u0441\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430&nbsp;\u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430&nbsp;\u0434\u0438\u0441\u043a\u0435 \u0438 \u0441&nbsp;\u043d\u0438\u043c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f =)<\/p>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u041c\u044b \u0442\u0440\u0438\u0436\u0434\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0431\u0430\u0437\u0443 MySQL \u043d\u0430&nbsp;\u0442\u043e\u0447\u043a\u0443 \u0432&nbsp;\u043f\u0440\u043e\u0448\u043b\u043e\u043c. PiTR like a rock\u2011star \u0447\u0443\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u0433\u0438\u0431\u043e\u043a&nbsp;\u2014 \u043e\u043d \u043d\u0435&nbsp;\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432\u043e&nbsp;\u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430&nbsp;\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041c\u0435\u0442\u043e\u0434<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>PiTR to time<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>PiTR to position<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>PiTR to GTID<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>PiTR \u0441 mysqlbinlog<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705&nbsp;[1]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705&nbsp;[1]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705&nbsp;[1]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>PiTR like a rock-star<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">?<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705&nbsp;[2]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705&nbsp;[3]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><strong>PiTR \u0441 binlog-server<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705&nbsp;[2]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2705&nbsp;[3]<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>[1] \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043b\u044f <code>mysqlbinlog<\/code><\/p>\n<p>[2] \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>CHANGE MASTER TO \u2026 MASTER_LOG_FILE=xxx MASTER_LOG_POS=yyy<\/code><\/p>\n<p>[3] \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>START REPLICA \u2026 SQL_BEFORE_GTIDS\/SQL_AFTER_GTIDS=xxx<\/code><\/p>\n<p>\u0415\u0441\u043b\u0438&nbsp;\u0436\u0435 \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f&nbsp;\u2014 \u0442\u043e \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0440\u0430\u0437\u0430 \u0432 2\u20133&nbsp;\u0431\u044b\u0441\u0442\u0440\u0435\u0435! \u0418 \u043f\u0440\u0438&nbsp;\u044d\u0442\u043e\u043c \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0435&nbsp;\u0441\u0438\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430 \u043d\u0430&nbsp;\u0434\u0438\u0441\u043a\u0435! \u0412\u0441\u0435 \u043c\u043e\u0438 \u0437\u0430\u043c\u0435\u0440\u044b \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0435\u0449\u0451 \u0440\u0430\u0437\u043e\u0433\u043d\u0430\u0442\u044c recovery \u0432&nbsp;\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0438\u0436\u0435:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"169\" width=\"169\">\n<p align=\"left\"><strong>\u041c\u0435\u0442\u043e\u0434<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\"><strong>PiTR<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"center\"><strong>PiTR + \u0445\u0430\u043a\u0438<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"169\" width=\"169\">\n<p align=\"left\"><strong>PiTR \u0441 mysqlbinlog<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">118min<\/p>\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"center\"> 65min [3][4]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043f\u0430\u0440\u0430 \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432[6]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"169\" width=\"169\">\n<p align=\"left\"><strong>PiTR like a rock-star<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">45min<\/p>\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"center\">17min [1][2][3]<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0431\u0438\u043d\u043b\u043e\u0433\u0438 [5]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"169\" width=\"169\">\n<p align=\"left\"><strong>PiTR \u0441 binlog-server<\/strong><\/p>\n<\/td>\n<td data-colwidth=\"91\" width=\"91\">\n<p align=\"center\">48min<\/p>\n<\/td>\n<td data-colwidth=\"149\" width=\"149\">\n<p align=\"center\">18min [2][3][4]<\/p>\n<\/td>\n<td>\n<p align=\"left\">2 x relay_log_space_limit [6]<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>[1] <code>log_replica_updates=0<\/code> &#8212; \u043e\u043f\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c redo log \u0432 \u043d\u043e\u0432\u044b\u0435 \u0431\u0438\u043d\u043b\u043e\u0433\u0438: (Note: \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f redo-\u043b\u043e\u0433\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0443\u0431\u0440\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c mysqld) [MySQL 8.0.26+]<\/p>\n<p>[2] <code>binlog_transaction_dependency_tracking=WRITESET<\/code> &#8212; \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439<\/p>\n<p>[3] \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c redo log: <code>ALTER INSTANCE DISABLE INNODB REDO_LOG;<\/code><\/p>\n<p>[4] <code>sync_binlog=3000<\/code> &#8212; \u0440\u0435\u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c fsync \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432<\/p>\n<p>[5] x2 \u043f\u043e \u043c\u0435\u0441\u0442\u0443 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>log_replica_updates=0<\/code><\/p>\n<p>[6] \u0412\u044b \u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0435\u0441\u044c \u043d\u0430 <code>binlog_expire_logs_seconds<\/code>, \u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0435 \u0431\u0438\u043d\u043b\u043e\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b wal-g?<\/p>\n<h2>Kudos<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/commitstrip.com\/\" rel=\"noopener noreferrer nofollow\">https:\/\/commitstrip.com\/<\/a>  \u0437\u0430 \u0438\u0434\u0435\u044e \u043a\u043e\u043c\u0438\u043a\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Fizic\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/Fizic<\/a> \u0437\u0430 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e binlog-server<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/734824\/\"> https:\/\/habr.com\/ru\/articles\/734824\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<h2>Intro<\/h2>\n<p>Point in Time Recovery (PiTR)&nbsp;\u2014 \u044d\u0442\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430&nbsp;\u043a\u0430\u043a\u043e\u0439\u2011\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e&nbsp;\u0441\u0435\u043a\u0443\u043d\u0434 \u0438\u043b\u0438&nbsp;\u0434\u043e&nbsp;\u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438).<\/p>\n<p>PiTR \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f&nbsp;\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u00ab\u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043c\u043e\u0435\u00bb. \u0415\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u043d\u0430&nbsp;\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u0443, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437&nbsp;\u043f\u043e\u0442\u0435\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><\/figure>\n<blockquote>\n<p><strong>Fun fact:<\/strong> \u0432 MySQL client \u0435\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>--i-am-a-dummy<\/code> [<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/mysql-tips.html#safe-updates\" rel=\"noopener noreferrer nofollow\">doc<\/a>], \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u0430\u043a \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 &#8212; <code>UPDATE<\/code> \u0438 <code>DELETE<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0435\u0437 <code>WHERE<\/code> \/ <code>LIMIT<\/code> \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0430<\/p>\n<\/blockquote>\n<p>\u0422\u0435\u043e\u0440\u0438\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e&nbsp;\u0434\u043b\u044f&nbsp;\u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u043d\u0430&nbsp;\u0442\u043e\u0447\u043a\u0443 \u0432\u043e&nbsp;\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u043d\u0435\u043f\u0448\u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a&nbsp;\u043d\u0435\u043c\u0443 \u043b\u043e\u0433 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 (\u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Replicated State Machine). \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 (\u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442&nbsp;\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435&nbsp;\u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442&nbsp;\u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432&nbsp;\u2014 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0438\u043c\u0435\u043d\u0438 \u0445\u043e\u0441\u0442\u0430 \u0438&nbsp;\u0442.&nbsp;\u043f.), \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435&nbsp;\u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442&nbsp;\u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0432&nbsp;\u043f\u0440\u043e\u0448\u043b\u043e\u043c. \u041a&nbsp;\u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0442\u0443\u043b\u0438\u043d\u0433 \u0432\u043e\u043a\u0440\u0443\u0433 MySQL \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043d\u0435\u043f\u0448\u043e\u0442\u044b (\u0431\u0435\u043a\u0430\u043f\u044b), \u0430&nbsp;\u0431\u0438\u043d\u043b\u043e\u0433 \u043a\u0430\u043a&nbsp;\u0440\u0430\u0437 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u043e\u0433 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<h2>PiTR \u043a\u0430\u043a \u0437\u0430\u0432\u0435\u0449\u0430\u043b\u0438 \u0434\u0435\u0434\u044b<\/h2>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0433\u043e\u0434\u0430\u043c\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0439 PiTR, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432&nbsp;\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 [<a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/point-in-time-recovery.html\" rel=\"noopener noreferrer nofollow\">link<\/a>]:<\/p>\n<ol>\n<li>\n<p>\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 MySQL \u0438\u0437&nbsp;\u0431\u0435\u043a\u0430\u043f\u0430&nbsp;\u2014 \u043d\u0435&nbsp;\u0432\u0430\u0436\u043d\u043e, \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e (<code>xtrabackup<\/code>) \u0438\u043b\u0438&nbsp;\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e (<code>mysqldump<\/code>)<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <code>mysqld<\/code><\/p>\n<\/li>\n<li>\n<p>\u0411\u0435\u0440\u0451\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0438 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>mysqlbinlog --stop-datetime \"1985-10-26 01:21:00\" &lt;binlog_name&gt; | mysql<\/code> \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u043a&nbsp;MySQL (\u043f\u0440\u0438&nbsp;\u0436\u0435\u043b\u0430\u043d\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c <code>--stop-position<\/code>, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441&nbsp;\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e&nbsp;\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438). \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\n<p><code>mysqlbinlog<\/code> \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437&nbsp;binlog \u0432&nbsp;plain SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043b\u0435\u0435 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0447\u0435\u0440\u0435\u0437 unix pipe \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 <code>mysql-client<\/code><\/p>\n<\/li>\n<li>\n<p><code>mysql-client<\/code> \u043f\u043e&nbsp;\u0441\u0435\u0442\u0438 (\u043e\u0431\u044b\u0447\u043d\u043e \u0447\u0435\u0440\u0435\u0437 localhost) \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432&nbsp;MySQL \u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>MySQL \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043e\u0434\u043d\u0443 \u0437\u0430&nbsp;\u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d \u0433\u043e\u0434\u0430\u043c\u0438&nbsp;\u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u043e. \u041d\u043e&nbsp;\u043a\u0430\u043a&nbsp;\u0432\u0438\u0434\u043d\u043e \u0438\u0437&nbsp;\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b&nbsp;\u2014 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438. \u041a&nbsp;\u0442\u043e\u043c\u0443&nbsp;\u0436\u0435 \u043f\u0440\u0438&nbsp;\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0430 \u0432&nbsp;SQL \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e&nbsp;binlog grop commit [<a href=\"https:\/\/habr.com\/ru\/articles\/684474\/\" rel=\"noopener noreferrer nofollow\">link<\/a>] \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u0434\u043d\u0430 \u0437\u0430&nbsp;\u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<h2>PITR \u0441\u043e \u0441\u0442\u0438\u043b\u0435\u043c<\/h2>\n<p>\u0414\u043b\u044f&nbsp;\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0448\u0432\u0435\u0439\u0446\u0430\u0440\u0441\u043a\u0438\u0439 \u043d\u043e\u0436 \u0431\u0435\u043a\u0430\u043f\u043e\u0432 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445&nbsp;\u2014 <strong>wal\u2011g.<\/strong> \u042d\u0442\u043e\u0442 \u0442\u0443\u043b \u0437\u0430\u0431\u0451\u0440\u0435\u0442 \u043d\u0430&nbsp;\u0441\u0435\u0431\u044f \u0431\u041e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0433\u043e\u043b\u043e\u0432\u043d\u044f\u043a\u0430&nbsp;\u2014 \u0441&nbsp;\u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0431\u0435\u043a\u0430\u043f\u043e\u0432 \u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432 \u043d\u0430&nbsp;\u0432\u043d\u0435\u0448\u043d\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (S3), \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<figure class=\"full-width\"><\/figure>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u0442\u0435\u043d\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c <code>percona-server<\/code> \u0438 \u044f\u0432\u043d\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043c:<\/p>\n<pre><code># Set unique server_id server_id=1  # Enable GTIDs gtid_mode=ON enforce_gtid_consistency=ON  # Enable Group Commit slave_parallel_type=LOGICAL_CLOCK slave_parallel_workers=8<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c [<a href=\"https:\/\/github.com\/wal-g\/wal-g#development\" rel=\"noopener noreferrer nofollow\">link<\/a>] (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043d\u043e\u0447\u043d\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438) \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c wal-g :<\/p>\n<pre><code># Typical MySQL config WALG_MYSQL_DATASOURCE_NAME=root:Qwerty12345@tcp(localhost:3306)\/habr WALG_STREAM_CREATE_COMMAND=\/usr\/bin\/xtrabackup --backup --stream=xbstream --datadir=\/var\/lib\/mysql WALG_STREAM_RESTORE_COMMAND=xbstream -x -C \/var\/lib\/mysql WALG_MYSQL_BACKUP_PREPARE_COMMAND=xtrabackup --prepare --target-dir=\/var\/lib\/mysql WALG_MYSQL_BINLOG_REPLAY_COMMAND=mysqlbinlog --stop-datetime=\"$WALG_MYSQL_BINLOG_END_TS\" \"$WALG_MYSQL_CURRENT_BINLOG\" | mysql WALG_MYSQL_BINLOG_DST=\/var\/lib\/mysql\/my-binlogs  # (De)compress backup in 6 threads: WALG_STREAM_SPLITTER_PARTITIONS=6 WALG_COMPRESSION_METHOD=zstd  # Storage WALG_S3_PREFIX=s3:\/\/backet-name\/mysql\/ AWS_ENDPOINT=storage.yandexcloud.net AWS_ACCESS_KEY_ID=&lt;key_id&gt; AWS_SECRET_ACCESS_KEY=&lt;access_key&gt;<\/code><\/pre>\n<p>\u0421\u043d\u0438\u043c\u0435\u043c \u0431\u0435\u043a\u0430\u043f:<\/p>\n<pre><code>wal-g-mysql --turbo --config .walg.properties backup-push<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443:<\/p>\n<pre><code>sysbench --db-driver=mysql --mysql-user=&lt;user&gt; --mysql-password=&lt;pwd&gt; --mysql-db=habr --range_size=100 --table_size=10000000 --tables=16 --threads=32 --time=3000 \/usr\/share\/sysbench\/oltp_read_write.lua preapre sysbench --db-driver=mysql --mysql-user=&lt;user&gt; --mysql-password=&lt;pwd&gt; --mysql-db=habr --range_size=100 --table_size=10000000 --tables=16 --threads=32 --time=3000 \/usr\/share\/sysbench\/oltp_read_write.lua run<\/code><\/pre>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 (\u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u043b\u0430\u0442\u044c cron-\u043e\u043c \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0441 flock):<\/p>\n<pre><code>mysql &gt; FLUSH LOGS; bash  &gt; wal-g-mysql --config .walg.properties  binlog-push<\/code><\/pre>\n<p>\u0423\u0440\u0430! \u041c\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u044e \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438!<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0435\u043f\u043e\u043f\u0440\u0430\u0432\u0438\u043c\u043e \u201c\u0438\u0441\u043f\u043e\u0440\u0442\u0438\u043c\u201d \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445\u2026 \u0418 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0435\u0435 \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441 \u0441\u0430\u0439\u0442\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 wal-g [<a href=\"https:\/\/wal-g.readthedocs.io\/MySQL\/\" rel=\"noopener noreferrer nofollow\">link<\/a>].<\/p>\n<pre><code>service mysql stop rm -rf \/var\/lib\/mysql\/*  # Oops!  (1) wal-g-mysql --turbo --config .walg.properties backup-fetch LATEST \u23f1\ufe0f&nbsp;real    1m44.531s  (2) service mysql start (3) gtids=$(tr -d '\\n' &lt; \/var\/lib\/mysql\/xtrabackup_binlog_info | awk '{print $3}') (4) mysql -e \"RESET MASTER; SET @@GLOBAL.GTID_PURGED='$gtids';\"  time wal-g-mysql --turbo --config .walg.properties binlog-replay --since LATEST --until \"2030-01-02T15:04:05Z \u23f1\ufe0f&nbsp;real    118m3.330s<\/code><\/pre>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0435\u043a\u0430\u043f\u0430 \u0437\u0430\u043d\u044f\u043b\u043e 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u0438\u043d\u043b\u043e\u0433\u043e\u0432 <strong>118 \u043c\u0438\u043d\u0443\u0442<\/strong>(!). \u041c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b sysbench (50 \u043c\u0438\u043d\u0443\u0442), \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0441\u043e\u0437\u0434\u0430\u043b\u0430 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438.<\/p>\n<p>\u0411\u0430\u0437\u0430 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430, PROD \u0441\u043f\u0430\u0441\u0435\u043d! \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0431\u044b\u0441\u0442\u0440\u0435\u0435?<\/p>\n<h2>PiTR like a rock-star<\/h2>\n<figure class=\"full-width\"><\/figure>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0443\u0432\u0438\u0434\u0435\u043b \u0432&nbsp;\u0431\u043b\u043e\u0433\u0435 [<a href=\"https:\/\/lefred.be\/content\/howto-make-mysql-point-in-time-recovery-faster\/\" rel=\"noopener noreferrer nofollow\">link<\/a>][<a href=\"https:\/\/www.slideshare.net\/lefred.descamps\/fosdem-mysql-friends-devroomffebruary-2018-mysql-pointintime-recovery-like-a-rockstar\" rel=\"noopener noreferrer nofollow\">slides<\/a>][<a href=\"https:\/\/www.youtube.com\/watch?v=PinKYCfv1MM&amp;t=1787s\" rel=\"noopener noreferrer nofollow\">video<\/a>] Fr\u00e9d\u00e9ric (Lefred) Descamps. \u0418\u0434\u0435\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432&nbsp;\u0442\u043e\u043c, \u0447\u0442\u043e&nbsp;\u043c\u043e\u0436\u043d\u043e \u00ab\u043f\u043e\u0434\u0441\u0443\u043d\u0443\u0442\u044c\u00bb \u0441\u0435\u0440\u0432\u0435\u0440\u0443 MySQL \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u043a\u0430\u043a&nbsp;\u0431\u0443\u0434\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e&nbsp;\u0441\u043a\u0430\u0447\u0430\u043b \u0441&nbsp;\u043c\u0430\u0441\u0442\u0435\u0440\u0430, \u043d\u043e&nbsp;\u0435\u0449\u0435 \u043d\u0435&nbsp;\u0443\u0441\u043f\u0435\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c. \u0412&nbsp;MySQL \u0442\u0430\u043a\u0438\u0435 \u043b\u043e\u0433\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f relay logs. MySQL, \u0443\u0432\u0438\u0434\u0435\u0432 relay logs, \u043d\u0430\u0447\u043d\u0451\u0442 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0430\u043a&nbsp;\u0431\u044b\u0441\u0442\u0440\u043e, \u043a\u0430\u043a&nbsp;\u0441\u043c\u043e\u0436\u0435\u0442!<\/p>\n<p>\u0412 <code>my.cnf<\/code> \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c slave\u2011threads, \u0447\u0442\u043e\u0431\u044b \u043d\u0435&nbsp;\u0441\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0444\u0430\u043b\u044c\u0441\u0442\u0430\u0440\u0442, \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u043a&nbsp;\u043c\u044b \u043d\u0430\u0437\u043e\u0432\u0451\u043c relay log\u2011\u0438:<\/p>\n<pre><code>skip-slave-start relay_log=mysql1<\/code><\/pre>\n<p>\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0431\u0430\u0437\u0443 \u0438\u0437 \u0431\u0435\u043a\u0430\u043f\u0430, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 (\u0448\u0430\u0433\u0438 1-4). \u0414\u0430\u043b\u0435\u0435, \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438:<\/p>\n<pre><code>time wal-g-mysql --turbo --config .walg.properties binlog-fetch --since LATEST --until \"2030-01-02T15:04:05Z\" \u23f1\ufe0f&nbsp;real    1m39.685s<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u0443\u0435\u043c \u043d\u0430\u0448\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0432 relay \u043b\u043e\u0433\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b\u043e \u0441 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435\u043c MySQL:<\/p>\n<pre><code>cd \/var\/lib\/mysql  for i in $(ls my-binlogs\/*.0*)  do     ext=$(echo $i | cut -d'.' -f2);    mv $i mysql1-relay-bin.$ext;  done<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441:<\/p>\n<pre><code>cd \/var\/lib\/mysql ls .\/mysql1-relay-bin.0* &gt; mysql1-relay-bin.index<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0431\u0438\u043d\u043b\u043e\u0433\u0438:<\/p>\n<pre><code>mysql&gt; SET GLOBAL SERVER_ID = 99; mysql&gt; CHANGE REPLICATION SOURCE  TO RELAY_LOG_FILE='mysql1-relay-bin.000057', RELAY_LOG_POS=1, SOURCE_HOST='dummy'; mysql&gt; START REPLICA SQL_THREAD;<\/code><\/pre>\n<p>\u042e\u2011\u0445\u0443! \u0411\u0435\u043a\u0430\u043f \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u043b\u0438 \u0437\u0430 2&nbsp;\u043c\u0438\u043d\u0443\u0442\u044b, \u0437\u0430 2&nbsp;\u043c\u0438\u043d\u0443\u0442\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0438 \u0437\u0430 <strong>45&nbsp;\u043c\u0438\u043d\u0443\u0442<\/strong> \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0431\u0438\u043d\u043b\u043e\u0433\u0438! \u0411\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0432&nbsp;\u0434\u0432\u0430 \u0440\u0430\u0437\u0430&nbsp;\u0431\u044b\u0441\u0442\u0440\u0435\u0435!<\/p>\n<p>\u0422\u0430\u043a&nbsp;\u0436\u0435 \u0432&nbsp;\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c, \u0447\u0442\u043e&nbsp;MySQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043b\u044f&nbsp;\u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f group commit:<\/p>\n<pre><code>mysql&gt; SHOW PROCESSLIST +----+-----------------+-----------+------+---------+-------+---------------------------------------------+------------------+---------+-----------+---------------+ | Id | User            | Host      | db   | Command | Time  | State                                       | Info             | Time_ms | Rows_sent | Rows_examined | +----+-----------------+-----------+------+---------+-------+---------------------------------------------+------------------+---------+-----------+---------------+ |  5 | event_scheduler | localhost | NULL | Daemon  |   190 | Waiting on empty queue                      | NULL             |  190001 |         0 |             0 | | 10 | root            | localhost | NULL | Query   |     0 | init                                        | show processlist |       0 |         0 |             0 | | 35 | system user     |           | NULL | Query   |     0 | Waiting for dependent transaction to commit | NULL             |       0 |         0 |             0 | | 36 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 37 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 38 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 39 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 40 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 41 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 42 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | | 43 | system user     |           | habr | Query   | 19129 | Applying batch of row changes (update)      | NULL             |       0 |         0 |             0 | +----+-----------------+-----------+------+---------+-------+---------------------------------------------+------------------+---------+-----------+---------------+<\/code><\/pre>\n<h2>Supersonic PiTR<\/h2>\n<figure class=\"full-width\"><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438 \u0431\u044b\u0441\u0442\u0440\u043e, \u0438 \u043d\u0435 \u0438\u0441\u043f\u0430\u0447\u043a\u0430\u0432\u0448\u0438\u0441\u044c \u0432 bash? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <code>wal-g binlog-server<\/code>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c\u0441\u044f MySQL master-\u043e\u043c \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0438\u043d\u043b\u043e\u0433\u0438 \u0441 S3 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0441\u0440\u0430\u0437\u0443 \u0432 \u043d\u0430\u0448 MySQL. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d \u0432\u043e\u0437\u044c\u043c\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0437\u0430\u0431\u043e\u0442\u0443 \u043e \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0438 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0435 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u0414\u043e\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c mysql:<\/p>\n<pre><code>relay_log_space_limit=8589934592 skip-slave-start<\/code><\/pre>\n<p>\u0438 wal-g<\/p>\n<pre><code>WALG_MYSQL_BINLOG_SERVER_HOST=localhost WALG_MYSQL_BINLOG_SERVER_PORT=9306 WALG_MYSQL_BINLOG_SERVER_USER=walg WALG_MYSQL_BINLOG_SERVER_PASSWORD=walgpwd WALG_MYSQL_BINLOG_SERVER_ID=99  WALG_MYSQL_BINLOG_SERVER_REPLICA_SOURCE=root:Qwerty12345@127.0.0.1:3306\/habr<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c MySQL \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0438\u0437 \u0431\u0435\u043a\u0430\u043f\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>wal-g backup-fetch<\/code> (\u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0435 \u043d\u0430\u043c \u0448\u0430\u0433\u0438 1-4 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438)<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <code>wal-g binlog-server<\/code><\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c MySQL<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e \u0441 wal-g:<\/p>\n<\/li>\n<\/ul>\n<pre><code>SET GLOBAL SERVER_ID=999; CHANGE MASTER TO MASTER_HOST=\"127.0.0.1\", MASTER_PORT=9306,<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-347468","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347468"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347468\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}