来自:mjsws > 馆藏分类
配色: 字号:
mysql数据库双向同步热备
2018-07-03 | 阅:  转:  |  分享 
  
mysql数据库双向同步热备环境:Masterserver:10.224.194.239Slave???server:10.224.
194.237步骤:1.分别在Master/Slaver?mysql?db创建backupuser:GRANTFILEON
.TObackup@10.224.194.239IDENTIFIEDBY''pass'';GRANTREPLICAT
IONSLAVEON.TObackup@10.224.194.239IDENTIFIEDBY''pass'';?G
RANTFILEON.TObackup@10.224.194.237IDENTIFIEDBY''pass'';GR
ANTREPLICATIONSLAVEON.TObackup@10.224.194.237IDENTIFIED
BY''pass'';2.在Masterserver配置/etc/my.cf文件:server-id=1binlog-do-
db=testbinlog-ignore-db=mysql?replicate-do-db=testreplicate-ign
ore-db=mysql?master-host=10.224.194.237master-user=backupmaster
-password=passmaster-port=3306master-connect-retry=60?slave-skip-
errors=all3.在Masterserver配置/etc/my.cf文件:server-id=2?binlog-do
-db=testbinlog-ignore-db=mysql?replicate-do-db=testreplicate-ig
nore-db=mysql?master-host=10.224.194.239master-user=backupmaste
r-password=passmaster-port=3306master-connect-retry=60?slave-skip
-errors=all4.重启mysql数据库,验证命令如下:查看Master状态showmasterstatus;mysql
>showmasterstatus;+-----------------+----------+--------------
+------------------+|File???????????|Position|Binlog_Do_DB|
Binlog_Ignore_DB|+-----------------+----------+--------------+-
-----------------+|mysqllog.000003|?????301|test????????|m
ysql???????????|+-----------------+----------+--------------+---
---------------+1rowinset(0.00sec)查看Slave状态来运棋牌http://www.
411196.comshowslavestatus\G;mysql>showslavestatus\G;
1.rowSlave_IO
_State:ReconnectingafterafailedmastereventreadMaster_Host
:10.224.194.239Master_User:backupMaster_Port:3306Connect_Re
try:60Master_Log_File:mysqllog.000003Read_Master_Log_Pos:301
Relay_Log_File:mysqlgsb-relay-bin.000082Relay_Log_Pos:348Rel
ay_Master_Log_File:mysqllog.000003Slave_IO_Running:NoSlave_SQ
L_Running:YesReplicate_Do_DB:testReplicate_Ignore_DB:mysqlR
eplicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Tabl
e:Replicate_Wild_Ignore_Table:Last_Errno:0Last_Error:Skip_Co
unter:0Exec_Master_Log_Pos:301Relay_Log_Space:650Until_Cond
ition:NoneUntil_Log_File:?Until_Log_Pos:0Master_SSL_Allowed:
NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Maste
r_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master:NULLMaster_S
SL_Verify_Server_Cert:NoLast_IO_Errno:0Last_IO_Error:Last_SQ
L_Errno:0Last_SQL_Error:1rowinset(0.00sec)?ERROR:Noquery
specified查看同步进程:mysql>showprocesslist\G;
1.rowId:1User:systemuser
Host:?db:NULLCommand:ConnectTime:4186State:Waitingformas
tertosendeventInfo:NULL2.row
Id:2User:systemuserHost:?db:NULL
Command:ConnectTime:3745State:Hasreadallrelaylog;waitin
gfortheslaveI/OthreadtoupdateitInfo:NULL捕鱼游戏http://ww
w.44771.net3.row
Id:5User:rootHost:mysqlpri.webex.com:28293db:NULL
Command:QueryTime:0State:NULLInfo:showprocesslist
4.rowId:6User
:backupHost:10.224.194.237:41729db:NULLCommand:BinlogDumpTime:135State:Hassentallbinlogtoslave;waitingforbinlogtobeupdatedInfo:NULL4rowsinset(0.00sec)?ERROR:?Noqueryspecified
献花(0)
+1
(本文系mjsws首藏)