Upload
kurniawan-setyo-nugroho
View
215
Download
0
Embed Size (px)
Citation preview
8/9/2019 Running Low on Disk Space Using MySQL Replication
1/3
Running Low on Disk Space Using MySQLReplication?ByJustin Kulesza| Publise!" #eb$ua$y %& '())
*ne o+ te $e,ui$e-ents +o$ setting
up $eplication wit MySQL is to tu$n on bina$y logging. Bina$y logs contain $eco$!s o+
!atabase canges o$ canges to actual !ata. /e bina$y logs !o not $eco$! $esults o+
gene$al ,ue$ies wic !o not a++ect !ata suc asSELECTo$ SHOW. 0owe1e$& $esults o+
,ue$ies wic a++ect te !atabase an! its !ata& suc as DELETEan! UPDATEa$e
$eco$!e!.
/e bina$y logs allow MySQL to $ec$eate e1ents wic le! to te cu$$ent !atabase state./is is necessa$y to $eco1e$ +$o- ce$tain e$$o$s& an! to b$ing a !atabase +ully up2to2!ate
a+te$ $esto$ing +$o- backup. Since te bina$y logs contain all !ata canging e1ents& it is
possible to $eco1e$ canges wic occu$$e! a+te$ a !atabase !u-p was c$eate!.
3n a!!ition& te bina$y logs a$e use! by te $eplication p$ocess to con1ey in+o$-ation
about !ata canges a-ong te MySQL se$1e$s. 4ctual !ata canges a$e -a!e on
te MySQL $eplication 5-aste$6& an! !etails o+ tese canges a$e w$itten to te bina$y
log. /e MySQL $eplication 5sla1es6 subsc$ibe to te bina$y logs in o$!e$ to !ete$-ine
wat canges a1e been -a!e to te $eplication -aste$6s !ataset. /e $eplication sla1eten applies tese canges to its own !ataset in o$!e$ to keep te sla1e !ataset +ully
sync$onize! wit te -aste$ !ataset. 3n tis way& +ull $eplication is acie1e!.
Un+o$tunately& bina$y logs 7o+ten abb$e1iate! 5bin2logs68 !o not a1e a !e+ault e9pi$ation
in MySQL. /is -eans tat bina$y logs a$e constantly gene$ate!& but ne1e$ $e-o1e!.
/is is o+ conce$n because te bina$y logs a$e not s-all& an! will soon take up a
signi+icant a-ount o+ space on !isk. /e +i$st in!ication o+ tis is usually a -ultitu!e o+
low !isk space wa$nings 7o$ su!!en se$1e$ e$$o$s : c$ases !ue to lack o+ +$ee space8.
/e i--e!iate solution to tis p$oble- is to pu$ge ol! an! unnee!e! bina$y logs.;ene$ally& 1e$y ol! logs a$e sa+e to $e-o1e. But& i+ $eplication is enable!& you nee! to
ensu$e tat all $eplication sla1es a1e +inise! $ea!ing te logs be+o$e $e-o1al. /is can
be !one by ,ue$ying te$eplication sla1e6s status.
On each replication slave:
1234
56
mysql> SHOW SLAVE STATUS\G
************************** 1. r! ***************************
Sl"#$%&O%S'"'$( W")')+ ,r m"s'$r ' s$- $#$'
"s'$r%Hs'( 1/./.132.1/ "s'$r%Us$r( r$0l
http://spin.atomicobject.com/author/kulesza/http://spin.atomicobject.com/author/kulesza/http://dev.mysql.com/doc/refman/5.0/en/replication.htmlhttp://www.mysql.com/http://dev.mysql.com/doc/refman/5.0/en/binary-log.htmlhttp://dev.mysql.com/doc/refman/5.0/en/replication-howto-masterbaseconfig.htmlhttp://dev.mysql.com/doc/refman/5.0/en/replication-howto-slavebaseconfig.htmlhttp://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.htmlhttp://dev.mysql.com/doc/refman/5.0/en/show-slave-status.htmlhttp://dev.mysql.com/doc/refman/5.0/en/show-slave-status.htmlhttp://dev.mysql.com/doc/refman/5.0/en/replication.htmlhttp://www.mysql.com/http://dev.mysql.com/doc/refman/5.0/en/binary-log.htmlhttp://dev.mysql.com/doc/refman/5.0/en/replication-howto-masterbaseconfig.htmlhttp://dev.mysql.com/doc/refman/5.0/en/replication-howto-slavebaseconfig.htmlhttp://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.htmlhttp://dev.mysql.com/doc/refman/5.0/en/show-slave-status.htmlhttp://spin.atomicobject.com/author/kulesza/8/9/2019 Running Low on Disk Space Using MySQL Replication
2/3
1
011
"s'$r%Pr'( 33/6
C$'%$'ry( 6/
"s'$r%L+%)l$( mysql78).////4
$"-%"s'$r%L+%Ps( 1//33/3
$'.
PUGE 9&:A; LOGS TO
8/9/2019 Running Low on Disk Space Using MySQL Replication
3/3
!o can see the list of binary logs maintained by MySQL by rnning:
mysql> SHOW 9&:A; LOGS=
3+ te log +iles a$e liste! e$e& tey a$e still -aintaine! by MySQL an! soul! be $e-o1e!
using te PUGE 9&:A; LOGSco--an! !etaile! ea$lie$.