{"id":844,"date":"2021-12-12T03:10:10","date_gmt":"2021-12-11T21:10:10","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=844"},"modified":"2021-12-12T03:16:33","modified_gmt":"2021-12-11T21:16:33","slug":"how-to-delete-mysql-relay-bin-log-file","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-delete-mysql-relay-bin-log-file.html","title":{"rendered":"How to &#8216;safely&#8217; delete Mysql relay-bin log file?"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"530\" src=\"https:\/\/mellowhost.com\/blog\/wp-content\/uploads\/sites\/3\/2021\/12\/mysql.png\" alt=\"\" class=\"wp-image-846\" srcset=\"https:\/\/mellowhost.com\/blog\/wp-content\/uploads\/sites\/3\/2021\/12\/mysql.png 1024w, https:\/\/mellowhost.com\/blog\/wp-content\/uploads\/sites\/3\/2021\/12\/mysql-300x155.png 300w, https:\/\/mellowhost.com\/blog\/wp-content\/uploads\/sites\/3\/2021\/12\/mysql-768x398.png 768w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><strong>Question<\/strong><\/p>\n\n\n\n<p>My disk is full. When using du, I could see my MySQL log folder is taking up all the disk. These files are not mysql-bin files, instead, these are mysql-relay-bin files. How can I truncate or purge these files?<\/p>\n\n\n\n<p><strong>Answer<\/strong><\/p>\n\n\n\n<p>Mysql creates mysql-bin files which are called binary files for MySQL on the master side. It then streams the binary files to the replicas to reflect the changes. Mysql doesn&#8217;t really store the binaries on the replica side, hence it is safe to delete the relay-bin files. Although, there are other safe strategies to accomplish this or never fall into a situation of &#8216;out of space&#8217;.<\/p>\n\n\n\n<p>Firstly, we need to understand, expire_log_days MySQL attribute doesn&#8217;t work for the replica. The reason is simple, it doesn&#8217;t store the binary files. Hence, using this is worthless for replicas. You can&#8217;t use &#8216;PURGE&#8217; SQL command either for Replica log purging. Replica has a special attribute &#8216;relay_log_purge&#8217; which purges the relay-bin logs periodically. You can also set replica to follow a specific size of the log file by using &#8216;relay_log_space_limit&#8217; attribute. <\/p>\n\n\n\n<p>Now at a very certain time, if you want to free up space, other than gross and brutal deleting relay-bin log files, what you can do is the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># start your mysql console session\nmysql\n\n# stop the slave\nstop slave;\n# reset the slave\nreset slave;\n# now start the slave again\nstart slave;<\/pre>\n\n\n\n<p>Now, once the slave is reset, it will start streaming the bin log from the &#8220;pos&#8221; it has in its queue to populate the pending jobs. <\/p>\n\n\n\n<p>Once the sync is done, you may check the replica status using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">show slave status \\G;<\/pre>\n\n\n\n<p>Make sure the following two are set to yes:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Slave_IO_Running: Yes\nSlave_SQL_Running: Yes\n<\/pre>\n\n\n\n<p>If not, you should look at the &#8216;Last_SQL_Error&#8217; or &#8216;Last_IO_Error&#8217; section to find out why these are not pushing.<\/p>\n\n\n\n<p>Good luck.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question My disk is full. When using du, I could see my MySQL log folder is taking up all the disk. These files are not mysql-bin files, instead, these are mysql-relay-bin files. How can I truncate or purge these files? Answer Mysql creates mysql-bin files which are called binary files for MySQL on the master &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-delete-mysql-relay-bin-log-file.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to &#8216;safely&#8217; delete Mysql relay-bin log file?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[636,87,638,637],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/844"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=844"}],"version-history":[{"count":3,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/844\/revisions"}],"predecessor-version":[{"id":848,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/844\/revisions\/848"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}