tags:

views:

33

answers:

2

Suggest me solution to track the change in test DB and replicate in Another DB...

My Client need a script or any solution, if he has two Database, One Test DB in which he tests his data on test portal and if he find it appropriate he can use those changes to be done in main DB to display on Live site.. Fior this he needs the solution to record or track all updation/deletion/insertion, so that he can do the same in main DB if found appropriate,

NOTE:

we have only one server, no separate server, hence binary log replication doesnt seems to be working for my case...

+1  A: 

Assuming that both test and production databases can evolve independently during the test period, I'd say a good starting point for thinking about a solution would be to activate query logging on the test database then, at the end of the day, extract ALTER, CREATE, DROP, INSERT, UPDATE, DELETE etc. statements from the test database query log file and simply try to play those statements back on the production database, possibly separating DDL and DML (with the DML in one transaction.)

If any of your tables have auto-increment columns used as foreign keys in other tables, use an AFTER trigger to capture actual auto-increment values for INSERT and UPDATE statements and write a corresponding SQL statement to a separate file for production playback; you may still use query logging to capture DDL statements (and DELETEs, although they can be captured via trigger too.)

Unlike binary logs, query logs (or equivalent logs produced from a trigger) are clear-text and allow you to further manually tweak queries to resolve any potential conflicts or divergences between the production and test systems.

vladr
@Vlad I have created a trigger script tracj any change in any atable will be recorded in a separate audit table, but as due to the Db structure, few tables do not have PK or any autioincremented field which i need to record in Audit table so that i can insert these values in my Main production DB, hence trigger concept is not working for me, and as far as log file is concerned, if it gets switched OFF/fluched due to memory then where will I find the changes?
OM The Eternity
CAn U put some more light on this issue @Vlad?
OM The Eternity
You should ensure (with those who connect to the system) that they do not disable logging (just like you'd have to ensure, in the case of the trigger solution, that they don't `DROP` your triggers) and that they will not remove log files if disk space goes down (just like you'd have to ensure, in the case of the trigger solution, that they don't `DROP` your audit table :) ).
vladr
Indeed, there will be a problem with query log playback if autoincrement PK values are then referred to as FKs in other tables. In that case using `AFTER` (!) triggers will capture the autoincrement PK value (so go for that solution to track e.g. `INSERT`s), but you will still need query logging to capture DDL commands, if any are issued. :)
vladr
A: 

Does http://adamspiers.org/computing/mysqldiff/ help?

Michael Shimmins
Thanks Mike for the link, but it only gives me the idea of comparing the structure of two DBs, It does not solve my problem, Any other idea?
OM The Eternity