資源描述:
《MySQL主主循環(huán)同步》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、MYSQLMASTER<---->MASTER主主循環(huán)同步仲偉成MySQL的主主同步。把步驟寫下來,至于會(huì)出現(xiàn)的什么問題,以后隨時(shí)更新。這里我同步的數(shù)據(jù)庫是TEST1、環(huán)境描述。??主機(jī):192.168.108.151(A)??主機(jī):192.168.108.153(B)??MYSQL版本為5.1.542、授權(quán)用戶。A:mysql>grantreplicationslave,fileon*.*to'repl1'@'192.168.108.153'identified?by'123456';QueryOK,0rowsaffected(0
2、.00sec)mysql>flushprivileges;QueryOK,0rowsaffected(0.00sec)B:mysql>grantreplicationslave,fileon*.*to'repl2'@'192.168.108.151'identified?by'123456';QueryOK,0rowsaffected(0.00sec)mysql>flushprivileges;QueryOK,0rowsaffected(0.00sec)然后都停止MYSQL服務(wù)器。3、配置文件。在兩個(gè)機(jī)器上的my.cnf里面都開啟二
3、進(jìn)制日志。A:user=mysqllog-bin=mysql-binserver-id??????=1binlog-do-db=testbinlog-ignore-db=mysqlreplicate-do-db=testreplicate-ignore-db=mysqllog-slave-updatesslave-skip-errors=alllower_case_table_names=1binlog_format=rowsync_binlog=1auto_increment_increment=2auto_increment_o
4、ffset=1B:user=mysqllog-bin=mysql-binserver-id??????=2binlog-do-db=testbinlog-ignore-db=mysqlreplicate-do-db=testreplicate-ignore-db=mysqllog-slave-updatesslave-skip-errors=alllower_case_table_names=1binlog_format=rowsync_binlog=1auto_increment_increment=2auto_increment
5、_offset=2至于這些參數(shù)的說明具體看手冊(cè)。紅色的部分非常重要,如果一個(gè)MASTER掛掉的話,另外一個(gè)馬上接管。紫紅色的部分指的是服務(wù)器頻繁的刷新日志。這個(gè)保證了在其中一臺(tái)掛掉的話,日志刷新到另外一臺(tái)。從而保證了數(shù)據(jù)的同步。藍(lán)色部分是忽略表名大小寫的區(qū)分;后者用于以后實(shí)時(shí)同步到Oracle庫中的日志格式4、重新啟動(dòng)MYSQL服務(wù)器。在A和B上執(zhí)行相同的步驟[root@localhost~]#/usr/local/mysql/bin/mysqld_safe&[1]4264[root@localhost~]#07121314:53:
6、20mysqld_safeLoggingto'/usr/local/mysql/data/localhost.localdomain.err'./usr/local/mysql/bin/mysqld_safe:line366:[:-eq:unaryoperatorexpected07121314:53:20mysqld_safeStartingmysqlddaemonwithdatabasesfrom/usr/local/mysql/data5、進(jìn)入MYSQL的SHELL。A:mysql>flushtableswithreadloc
7、kGQueryOK,0rowsaffected(0.00sec)mysql>showmasterstatusG***************************1.row***************************???????????File:mysql-bin.000007???????Position:528???Binlog_Do_DB:testBinlog_Ignore_DB:mysql1rowinset(0.00sec)B:mysql>flushtableswithreadlock;QueryOK,0r
8、owsaffected(0.00sec)mysql>showmasterstatusG***************************1.row***************************???????????Fil