Server side my.cnf ------ log-bin binlog-do-db=cqrlog_common # input the database which should be replicated binlog-do-db=cqrlog001 binlog-do-db=cqrlog002 binlog-do-db=cqrlog003 binlog-do-db=cqrlog004 binlog-ignore-db=mysql # input the database that should be ignored for replication binlog-ignore-db=test binlog-ignore-db=mittaus binlog-ignore-db=maraton binlog-ignore-db=zmmy binlog-ignore-db=ais binlog-ignore-db=sata binlog-ignore-db=cqrlog_web server-id=1 Console commands to do: mysql> grant replication slave on *.* to 'replication'@'%' identified by 'my_rep_pass'; mysql> flush privileges; mysql> flush tables with read lock; mysql> show master status; mysql> unlock tables; mysql> show grants; mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.200', MASTER_USER='replication', MASTER_PASSWORD='my_rep_pass'; mysql> start slave; mysql> show slave status\G; Client (Cqrlog laptop) side. As above, but these changes: server-id=2 mysql> change master to master_host='192.168.1.10', master_user='replication', master_password='my_rep_pass' ---------------FIX broken replication.-------------------------------------- ---AT both ends: stop slave; reset slave all; reset master; ---In system that has complete database with all qsos: mysqldump -uUserName -pUserPass --databases cqrlog001 cqrlog_common > mysqlbackcqr.sql NOTE: all databases cqrlogXXX (see scripts below to do this) ---Then move database dump to one that is not up to date: mysql -uUserName -pUserPass < mysqlbackcqr.sql ---At server side: CHANGE MASTER TO MASTER_HOST='192.168.1.200', MASTER_USER='replication', MASTER_PASSWORD='my_rep_pass'; +++At client (Cqrlog) side: change master to master_host='192.168.1.1o', master_user='replication', master_password='my_rep_pass'; ---At both sides: start slave; show slave status\G; ---------------------------------------------------------------------------------- If no errors ---> test by making a fake qso at client (Cqrlog) end and see that it appears to server. Then remove this qso at server end and see that diappeared at client (Cqrlog) side too. If fails repeat "FIX broken replication" ======================================================================================== ----------------to do fix sync you can use scripts--------------------- Run these first at both ends: fix_sync1_client.sh #!/bin/bash if [[ $EUID -ne 0 ]]; then echo "You must be a root user" 2>&1 exit 1 else mysql -e "stop slave" mysql -e "reset slave all" mysql -e "reset master" rm /tmp/mysqlbackcqrC.sql mysql -uUserName -pUserPass -B -N -e 'show databases like "cqr%"' | xargs echo -n mysqldump -uUserName -pUserPass --databases > /tmp/mycmd.txt echo ' --result-file=/tmp/mysqlbackcqrC.sql' >> /tmp/mycmd.txt chmod a+x /tmp/mycmd.txt source /tmp/mycmd.txt rm -f /tmp/mycmd.txt echo "stop slave, reset slave all, reset master, mysqldump /tmp/mysqlbackcqrC.sql DONE !" rsync -avzu /tmp/mysqlbackcqrL.sql ServerUser@192.168.1.10:/tmp/ echo "If this database is complete restore it to server with:" echo "mysql -uUserName -pUserPass < /tmp/mysqlbackcqrL.sql" fi! --------------- fix_sync1_server.sh #This script is same as above, but: # filename is/tmp/mysqlbackcqrS.sql # rsync target is ClentUser@192.168.1.200:/tmp # -uUserName -pUserPass are ones that work for client (if database has different user/pass than server) --------- Notes for two scripts above: rsync uses ssh connect. You need to use ssh-copy-id at both ends to transfer keys to get rid of giving passwords when using rsync. After those prepare "sync1" scripts are run at both ends then the phase 2 scripts needs to be run. REMEMBER! You have to create a replication user with password and grants to both ends mysqls!! --------------------- fix_sync2_server.sh #!/bin/bash if [[ $EUID -ne 0 ]]; then echo "You must be a root user" 2>&1 exit 1 else mysql -e "CHANGE MASTER TO MASTER_HOST='192.168.1.200', MASTER_USER='replication', MASTER_PASSWORD='my_rep_pass'" mysql -e "start slave" mysql -e "show slave status\G" echo "Test sync after you have run client synx2 fix first" fi -------------------- fix_sync2_clinet.sh #!/bin/bash if [[ $EUID -ne 0 ]]; then echo "You must be a root user" 2>&1 exit 1 else mysql -e "change master to master_host='192.168.1.10', master_user='replication', master_password='my_rep_pass'" mysql -e "start slave" mysql -e "show slave status\G" echo "Test sync after you have run server synx2 fix first" fi --------- Notes for two scripts above: Before running fix_sync2 scripts you have to restore up to date database to one that has database with missing information. There is no specified order to run fix_sync2 scripts. Just run both before testing sync again.