Brad Fitzpatrick (brad) wrote,
Brad Fitzpatrick
brad

grossest mysql hack ever

http://www.bradfitz.com/programming/hacks/mysql-remaster.pl.txt

Gross hack to "re-master" or "re-parent" MySQL hosts before 4.1.1
which has the wonderful "SLAVE START UNTIL" command. (the UNTIL part is new)

Basically, if you have B and C both replicating from A, how do you make C
replicate from B instead of A?

Constraints:

-- can't touch A.
-- can't copy files from A or B to C, since C is a different file format
(InnoDB instead of MyISAM)

Solution:

Keep watching the replication position of B and C until they're the same.
Then stop the replication thread in both, verify they're still the same,
then make C feed off B instead. (this requires that B is already setup
to log-master-updates and log-bin)

Go ugly hacks!

(There's a lot of LJ-specific code in here, but you should figure out
what it does and how to write a non-LJ equivalent. Like, DBI->connect
instead of the LJ-low-level $LJ::DBIRole->get_dbh_conn)
Tags: mysql, perl, tech
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments