MaxDB:SynchMan:Create Synchronization Scenario
From Wiki
This is a step-by-step tutorial on how to create a simple Synchronization Scenario. It assumes that you've already installed MaxDB. For more information about the Synchronization Manager, see my article on the topic in the MySQL Developer Zone or my blog entry, which provides some use cases.
- maxdb <-> maxdb
- single table
- single column
- single row
Create databases
$ cd ~/src $ svn co http://colliertech.org/svn/mysql/maxdb/createDB $ cd createDB $ for i in DBMASTER SYNCMANA SYNCMANB ; do # dbmcli -u dbm,dbm -d $i db_offline ; # dbmcli -u dbm,dbm -d $i db_drop ; ./createDB.pl -d $i; sqlcli -u TEST,TEST -d $i "CREATE TABLE TEST.T ( i INT, c VARCHAR(32), PRIMARY KEY(i) )"; sqlcli -u TEST,TEST -d $i "GRANT ALTER, INSERT, UPDATE, DELETE, SELECT ON TABLE TEST.T TO DBSERVICE" done
Configure your Java environment
Download J2EE package
Download J2SE package
Install J2EE package
Troubleshooting
- I needed to create a symlink from current libstdc++ library to old name:
$ sudo ln -s /usr/lib/libstdc++.so.6 /usr/lib/libstdc++-libc6.2-2.so.3
- I moved gcj java implementation out of the way
Eclipse
Download eclipse ide
Install swt .so files
If you trust me, you can get these shared objects (as compiled for x86 linux) from me.
$ cd /tmp $ wget http://colliertech.org/~cjcollier/mysql/maxdb/syncman/libswt-pi-gtk-3139.so $ wget http://colliertech.org/~cjcollier/mysql/maxdb/syncman/libswt-gtk-3139.so $ cp libswt-*.so /var/opt/sdb/data/app/syncman/extern/
Message Server
Configure the Message Server
$ msgserver config
Generating access key 'MESSAGESERVER', since it does not exist yet. Please specify the following parameters: database host [127.0.0.1]: database name [DBMASTER]: database user [DBSERVICE]: password of database user [SECRET]: message server admin password [MSGSERVERADMIN]: message server admin port [7220]: JNDI port [7221]: JMS port [7222]:
Start the Message Server
$ screen -S msgserver msgserver start
Sync Service
Configure the Sync Service
$ syncservice config -d DBMASTER
synchronization user [DBSERVICE]: synchronization user password [SECRET]: message server host [127.0.0.1]: synchronization service admin port [7223]: JNDI port of message server [7221]: service port of message server [7222]:
$ syncservice config -d SYNCMANA
synchronization user [DBSERVICE]: synchronization user password [SECRET]: message server host [127.0.0.1]: synchronization service admin port [7223]: 7224 JNDI port of message server [7221]: service port of message server [7222]:
$ syncservice config -d SYNCMANB
synchronization user [DBSERVICE]: synchronization user password [SECRET]: message server host [127.0.0.1]: synchronization service admin port [7223]: 7225 JNDI port of message server [7221]: service port of message server [7222]:
Bring the databases online
$ for i in DBMASTER SYNCMANA SYNCMANB ; do
dbmcli -d $i -u dbm,dbm db_online
done
Ensure that the indices are in a good state
$ for i in DBMASTER SYNCMANA SYNCMANB ; do
dbmcli -u dbm,dbm -d $i sql_recreateindex
done
Start the Sync Service
Is your x_server running? Good. msgserver? Nice.
$ screen -S syncservice-master syncservice start -d DBMASTER $ screen -S syncservice-CL0 syncservice start -d SYNCMANA $ screen -S syncservice-CL1 syncservice start -d SYNCMANB
Stop the Sync Service
$ syncservice stop -d DBMASTER $ syncservice stop -d SYNCMANA $ syncservice stop -d SYNCMANB
SyncManGUI
Be sure to stop the syncservices before starting syncmangui
Start syncmangui
$ syncmangui
Connect to Database
- Click Session -> Connect to Database
- Enter "127.0.0.1" in the Host field
- Enter "DBMASTER" in the Database field
- Leave the Service User field set to "DBSERVICE"
- Enter "SECRET" in the Password field
- Click OK
Connect to Message Server
- Click Session in the application drop-down menu
- Click Connect to Message Server ...
- Enter "127.0.0.1" in the Host field
- Enter "7220" in the Port field
- Enter "MSGSERVERADMIN" in the Password field
- Click OK
Add a Replication Table
- Select Replication Tables -> Add Table ...
- Click on T
- Click OK
Create a Column Group
- Expand the Test element (click the arrow to the left)
- Click on table T's icon
- To the right, you will see a form appear
- Click the New Column Group button
- Enter "g0" into the field
- Click OK
- Click C in the Columns of Table field
- Click the left arrow
Creating a Master Replication Unit
- Click the Replication Units tab
- Click Replication Units -> Add Master Unit
- Enter "Unit0" into the Unit name field
- Leave Unit Type as In/Out
- Press OK
Adding Table to Replication Unit
- Expand the Unit0 element (click the triangle to the left)
- Right-click on the Tables element
- Click Add Table
- Chose T and click OK
- Expand the Tables element
Creating a Client Replication Unit
- Right-click on the Client Units element
- Click Add Client Unit ...
- For Unit Name, enter "CL0"
- For Host, enter "localhost"
- For Database, enter "SYNCMANA"
- For User, enter "DBSERVICE"
- For Password, enter "SECRET"
- Click the Save Password checkbox
- Leave Unit Type as "In/Out"
- Click the OK button
Now, do the same as above, but substitute "CL1" for "CL0" and "SYNCMANB" for "SYNCMANA".
Initialize Message Server
- Click Replication Units
- Click Initialize Message Server (at the bottom)
Activating Replication Units
- Right-click on Unit0's icon at the top of the Replication Units field.
- Click Activate Master Unit
- Right-click on Unit0's icon at the top of the Replication Units field.
- Click Activate All Units
Test to see if it's working
Insert something into DBMASTER
$ sqlcli -u TEST,TEST -d DBMASTER "INSERT INTO T(I, C) VALUES(1, 'a')"
Push content to clients
(back to syncmangui)
- Right-click the CL0 icon under Client Units
- Click Send Content to Client
Do the same for the CL1 client unit.
Re-start the Sync Service
Test replication
$ sqlcli -u TEST,TEST -d SYNCMANA "INSERT INTO T(I, C) VALUES(2, 'b')" $ sqlcli -u TEST,TEST -d SYNCMANB "INSERT INTO T(I, C) VALUES(3, 'c')"
Wait.... Patience... Stretch...
There!
$ sqlcli -u TEST,TEST -d DBMASTER "SELECT * FROM T" $ sqlcli -u TEST,TEST -d SYNCMANA "SELECT * FROM T" $ sqlcli -u TEST,TEST -d SYNCMANB "SELECT * FROM T"

