-
target : The main library data (IP1) sync to standby every five minutes (IP2) sync increase only
-
ideas :
-
use crontab Timed execution of the script every five minutes for data synchronization
-
compile in script to implement query data increase in five minutes , implementation process and code ( with record ):
-
Bash contents in script
VI transaction.sh----CREATE transaction script to implement synchronization
#!/bin/bash
Source.bash_profile
( you need to add the environment variable in bash because the timed execution function is implemented using crontab)
Exportid= ' mysql-n-utest-ptest\[email protected]#$-dtest-e ' Select
Max (transaction_id) from record "'
( use alternate variable ID to define the current maximum transaction_id value in the repository)
Mysql-n-hip2-uslaveroot-p7pyw#7ahh7-dtest-e "Use
test;select* from record where transaction_id > $ID ;" > Backup.sql
(Finding a value greater than transaction_id in the Main library is the amount of data growth in the record in that five minute and importing it
to the backup.sql file )
Sed-i ' S#null#\\n#g ' Backup.sql
( error in import due to character set problem "null", using sed directives to replace NULL as \ n)
Mysql-n-utest-ptest\[email protected]#$-dtest-e "Use Test;load datainfile
'/home/mysql/backup.sql ' into table record;
( Import the generated backup.sql file )
crontab Script Writing
crontab-e ( edit timed script )
5,10,15,20,25,30,35,40,45,50,55* * * */home/mysql/transaction.sh
( executes transaction.sh every five minutes )
The results of the implementation test
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/02/wKioL1Tz4jWSXGaiAAC9WrRequ0816.jpg "style=" float: none; "title=" 1.png "alt=" Wkiol1tz4jwsxgaiaac9wrrequ0816.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/06/wKiom1Tz4STTqRp1AACrfbrAP5Q098.jpg "style=" float: none; "title=" 2.png "alt=" Wkiom1tz4sttqrp1aacrfbrap5q098.jpg "/>
This article is from the "Sunny" blog, make sure to keep this source http://dbasunny.blog.51cto.com/9192126/1616432
Synchronization of MySQL master to standby with scripting (one increment per five minutes)