-
Notifications
You must be signed in to change notification settings - Fork 284
Home
whitesock edited this page Mar 23, 2012
·
1 revision
Open Replicator is a high performance MySQL binlog parser written in Java. It unfolds the possibilities that you can parse, filter and broadcast the binlog events in a real time manner.
<dependency> <groupId>open-replicator</groupId> <artifactId>open-replicator</artifactId> <version>1.0.0</version> </dependency>
final OpenReplicator or = new OpenReplicator(); or.setUser("xjq"); or.setPassword("123456"); or.setHost("localhost"); or.setPort(3306); or.setServerId(6789); or.setBinlogPosition(4); or.setBinlogFileName("mysql_bin.000033"); or.setBinlogEventListener(new BinlogEventListener() { public void onEvents(BinlogEventV4 event) { // your code goes here } }); or.start(); System.out.println("press 'q' to stop"); final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); for(String line = br.readLine(); line != null; line = br.readLine()) { if(line.equals("q")) { or.stop(); break; } }
- 1 Row based replication*
mysql> insert into ta values(null, 'kevin', 100, 99.99); QueryEvent[...,databaseName=test,sql=BEGIN] TableMapEvent[...] WriteRowsEvent[...,rows=[Row[columns=[1, kevin, 100, 99.99]]]] XidEvent[...,xid=9] mysql> update ta set grade=100.00 where id = 1; QueryEvent[...,databaseName=test,sql=BEGIN] TableMapEvent[...] UpdateRowsEvent[...,rows=[Pair[before=Row[columns=[1, kevin, 100, 99.99]],after=Row[columns=[1, kevin, 100, 100.00]]]]] XidEvent[...,xid=10] mysql> delete from ta where id = 1; QueryEvent[...,databaseName=test,sql=BEGIN] TableMapEvent[...] DeleteRowsEvent[...,rows=[Row[columns=[1, kevin, 100, 100.00]]]] XidEvent[...,xid=11]
- 2 Statement based replication*
mysql> insert into ta values(null, 'kevin', 100, 99.99); QueryEvent[...,databaseName=test,sql=BEGIN] IntvarEvent[...,type=2,value=2] QueryEvent[...,databaseName=test,sql=insert into ta values(null, 'kevin', 100, 99.99)] XidEvent[...,xid=13] mysql> update ta set grade=100.00 where id = 2; QueryEvent[...,databaseName=test,sql=BEGIN] QueryEvent[...,databaseName=test,sql=update ta set grade=100.00 where id = 2] XidEvent[...,xid=14] mysql> delete from ta where id = 2; QueryEvent[...,databaseName=test,sql=BEGIN] QueryEvent[...,databaseName=test,sql=delete from ta where id = 2] XidEvent[...,xid=15]