{"id":5741,"date":"2020-08-05T00:35:51","date_gmt":"2020-08-04T17:35:51","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=5741"},"modified":"2020-08-05T00:35:51","modified_gmt":"2020-08-04T17:35:51","slug":"mariadb-advance-reduction-disk-binary-logs-relay-log-mariadb-replication","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/mariadb-advance-reduction-disk-binary-logs-relay-log-mariadb-replication\/","title":{"rendered":"MariaDB Advance: Reduction Disk BINARY LOGS &#038; Relay Log (MariaDB Replication)"},"content":{"rendered":"<p>Trong\u00a0 qua\u0301 tri\u0300nh hoa\u0323t \u0111\u00f4\u0323ng cu\u0309a h\u00ea\u0323 th\u00f4\u0301ng MariaDB Replication\u00a0 ba\u0323n se\u0303 g\u0103\u0323p v\u00e2\u0301n\u00a0 \u0111\u00ea\u0300 li\u00ean quan \u0111\u00ea\u0301n disk h\u00ea\u0323 th\u00f4ng th\u00f4\u0301ng khi ca\u0301c file Binary Log tr\u00ean server matster va\u0300 Relay Log tr\u00ean ca\u0301c server slaver\u00a0 gia t\u0103ng ki\u0301ch th\u01b0\u01a1\u0301c va\u0300\u00a0 t\u00f4\u0309ng s\u00f4\u0301 file log d\u00e2\u0303n \u0111\u00ea\u0301n full disk\u00a0 h\u00ea\u0323 th\u00f4\u0301ng. \u0110\u00ea\u0309 tra\u0301nh ti\u0300nh tra\u0323ng na\u0300y thi\u0300 ba\u0323n co\u0301 th\u00ea\u0309 c\u00e2\u0301u hi\u0300nh th\u00eam ca\u0301c tham s\u00f4\u0301 h\u00ea\u0323\u00a0 th\u00f4\u0301ng \u0111\u00ea\u0309 quy \u0111i\u0323nh disk \u0111\u01b0\u01a1\u0323c x\u01b0\u0309 ly\u0301\u00a0 cho ca\u0301c hoa\u0323t\u00a0 \u0111\u00f4\u0323ng ghi log Replication.<\/p>\n<p><span style=\"font-size: 18pt;\">C\u00e2\u0301u hi\u0300nh quy \u0111i\u0323nh BINARY LOGS tr\u00ean Master server<\/span><\/p>\n<p>Tr\u00ean mater server\u00a0 MariaDB chi\u0309 co\u0301 1 c\u00e2\u0301u hi\u0300nh duy nh\u00e2\u0301t quy \u0111i\u0323nh s\u1ed1 ng\u00e0y sau \u0111\u00f3 BINARY LOGS c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c t\u1ef1 \u0111\u1ed9ng x\u00f3a. Theo m\u1eb7c \u0111\u1ecbnh 0 co\u0301 nghi\u0303a la\u0300 kh\u00f4ng lo\u1ea1i b\u1ecf t\u1ef1 \u0111\u1ed9ng. Khi s\u1eed d\u1ee5ng relication, ph\u1ea3i lu\u00f4n lu\u00f4n\u00a0 \u0111\u1eb7t gia\u0301 tri\u0323\u0323 na\u0300y\u00a0 cao h\u01a1n \u0111\u1ed9 tr\u1ec5 t\u1ed1i \u0111a b\u1edfi b\u1ea5t k\u1ef3 ma\u0301y chu\u0309 Slaver na\u0300o kha\u0301c. Vi\u1ec7c x\u00f3a s\u1ebd di\u1ec5n ra khi m\u00e1y ch\u1ee7 kh\u1edfi \u0111\u1ed9ng, khi BINARY LOGS b\u1ecb x\u00f3a, BINARY LOGS ti\u00ea\u0301p\u00a0 theo se\u0303 \u0111\u01b0\u01a1\u0323c ta\u0323o ra cho \u0111\u00ea\u0301n khi ki\u0301ch th\u01b0\u01a1\u0301c file log na\u0300y \u0111a\u0323t \u0111\u00ea\u0301n gi\u01a1\u0301i ha\u0323n ho\u0103\u0323c th\u01b0\u0323c hi\u00ea\u0323n PURGE BINARY LOGS thu\u0309 c\u00f4ng se\u0303 xo\u0301a file tr\u00ean ho\u0103\u0323c ti\u00ea\u0301p tu\u0323c ta\u0323o ra file m\u01a1\u0301i va\u0300 \u0111\u01b0\u01a1\u0323c \u0111a\u0301nh s\u00f4\u0301 th\u01b0\u0301 t\u01b0\u0323 t\u0103ng d\u00e2\u0300n \u0111\u00ea\u0309 ca\u0301c Slaver co\u0301 th\u00ea\u0309\u0309 \u0111o\u0323c ti\u00ea\u0301p.<\/p>\n<p>Vi\u0301 du\u0323 c\u00e2\u0301u hi\u0300nh sau tr\u00ean my.cnf \u0111\u00ea\u0309 quy \u0111i\u0323nh xo\u0301a ca\u0301c file BINARY LOGS co\u0301 tu\u00f4\u0309i qua\u0301 8 nga\u0300y:<\/p>\n<p><code>expire-logs-days=8<\/code><\/p>\n<p><span style=\"font-size: 18pt;\">C\u00e2\u0301u hi\u0300nh Relay Log treen Slaver server<\/span><\/p>\n<p>Tr\u00ean Slaver server co\u0301 2 th\u00f4ng s\u00f4\u0301 c\u00e2\u0301u hi\u0300nh \u0111\u00ea\u0309 ha\u0323n ch\u00ea\u0301\u00a0 \u00a0la\u0323m du\u0323ng disk la\u0300 relay_log_purge\u00a0 va\u0300 relay_log_space_limit .<\/p>\n<p>Relay Log cu\u0303 s\u1ebd t\u1ef1 \u0111\u1ed9ng b\u1ecb x\u00f3a sau khi t\u1ea5t c\u1ea3 c\u00e1c s\u1ef1 ki\u1ec7n \u0111\u00e3 \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n tr\u00ean Slave v\u00e0 Relay Log kh\u00f4ng c\u00f2n c\u1ea7n thi\u1ebft n\u1eefa. H\u00e0nh vi n\u00e0y c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c thay \u0111\u1ed5i b\u1eb1ng c\u00e1ch \u0111i\u1ec1u ch\u1ec9nh bi\u1ebfn h\u1ec7 th\u1ed1ng Relay_log_purge t\u1eeb m\u1eb7c \u0111\u1ecbnh l\u00e0 1 th\u00e0nh 0, trong tr\u01b0\u1eddng h\u1ee3p \u0111\u00f3, nh\u1eadt k\u00fd chuy\u1ec3n ti\u1ebfp s\u1ebd \u0111\u01b0\u1ee3c \u0111\u1ec3 l\u1ea1i tr\u00ean m\u00e1y ch\u1ee7.<\/p>\n<div class=\"ddict_div\">\n<p class=\"ddict_sentence\">N\u1ebfu c\u00e1c Relay Log \u0111ang chi\u1ebfm qu\u00e1 nhi\u1ec1u kh\u00f4ng gian tr\u00ean Slaver, bi\u1ebfn h\u1ec7 th\u1ed1ng Relay_log_space_limit c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111\u1eb7t \u0111\u1ec3 gi\u1edbi h\u1ea1n k\u00edch th\u01b0\u1edbc. Lu\u1ed3ng IO s\u1ebd d\u1eebng cho \u0111\u1ebfn khi lu\u1ed3ng SQL x\u00f3a ph\u1ea7n t\u1ed3n \u0111\u1ecdng. Theo m\u1eb7c \u0111\u1ecbnh kh\u00f4ng c\u00f3 gi\u1edbi h\u1ea1n.<\/p>\n<p>Trong vi\u0301 du\u0323 sau ta se\u0303 c\u00e2\u0301u hi\u0300nh kh\u00f4ng xo\u0301a Relay Log khi du\u0300ng xong va\u0300 chi\u0309 quy \u0111i\u0323nh gi\u01a1\u0301i ha\u0323n 5GB Disk \u0111\u01b0\u01a1\u0323c s\u01b0\u0309 du\u0323ng cho vi\u00ea\u0323c ghi Relay Log, ca\u0301c log\u00a0 cu\u0303 nh\u00e2\u0301t se\u0303 \u0111\u01b0\u01a1\u0323c xo\u0301a kho\u0309i Slave:<\/p>\n<p><code>relay-log-purge=1<br \/>\nrelay-log-space-limit=5G<br \/>\n<\/code><\/p>\n<p>V\u01a1\u0301i ca\u0301c c\u00e2\u0301u hi\u0300nh tr\u00ean hy vo\u0323ng ba\u0323n se\u0303 kh\u00f4ng co\u0300n g\u0103\u0323p l\u00f4\u0303i full disk do\u00a0 log h\u00ea\u0323 th\u00f4\u0301ng Replicate g\u00e2y ra.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Trong\u00a0 qua\u0301 tri\u0300nh hoa\u0323t \u0111\u00f4\u0323ng cu\u0309a h\u00ea\u0323 th\u00f4\u0301ng MariaDB Replication\u00a0 ba\u0323n se\u0303 g\u0103\u0323p v\u00e2\u0301n\u00a0 \u0111\u00ea\u0300 li\u00ean quan \u0111\u00ea\u0301n disk h\u00ea\u0323 th\u00f4ng th\u00f4\u0301ng khi ca\u0301c file Binary Log tr\u00ean server matster va\u0300 Relay Log tr\u00ean ca\u0301c server slaver\u00a0 gia t\u0103ng ki\u0301ch th\u01b0\u01a1\u0301c va\u0300\u00a0 t\u00f4\u0309ng s\u00f4\u0301 file log d\u00e2\u0303n \u0111\u00ea\u0301n full disk\u00a0 h\u00ea\u0323 th\u00f4\u0301ng. \u0110\u00ea\u0309 tra\u0301nh ti\u0300nh [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[5156],"class_list":["post-5741","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-mariadb"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/5741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=5741"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/5741\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=5741"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=5741"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=5741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}