Log in

No account? Create an account
grossest mysql hack ever - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

grossest mysql hack ever [Jan. 5th, 2004|01:20 pm]
Brad Fitzpatrick
[Tags|, , ]


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?


-- 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)


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)

[User Picture]From: taral
2004-01-05 09:40 pm (UTC)
Mmm, yummy!
(Reply) (Thread)
[User Picture]From: jarodrussell
2004-01-05 10:06 pm (UTC)
I could have sworn the ugliest MySQL hack was:

create table newtable select * from oldtable;
(Reply) (Thread)
[User Picture]From: krow
2004-01-05 10:23 pm (UTC)
That is actually pretty handy for creating materialized views of specific data. If you are doing data warehousing applications where you need to do a lot of work on a specific subset of data it very handy.
(Reply) (Parent) (Thread)