MySql主从同步问题,求教!

铁衣 2015-03-25 10:16:45
我现在需要在同一台服务器上配置两个MySql数据库服务。
服务器操作系统为windows XP。

A服务为主库,端口3306
B服务为从库,端口3506

主库需要同步的数据库名为test-master
从库需要同步的数据库名为test2-slave

主库my.ini配置:
[mysqld]

port = 3306
character-set-server=gbk
server-id=1
log-bin=D:\mysql\logs\log-bin.log
binlog-do-db=test-master

mysql>show master status\G
*************************** 1. row ***************************
File: log-bin.000006
Position: 1118
Binlog_Do_DB: test-master
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)

从库my.ini配置:
[mysqld]

port = 3506
character-set-server=gbk
server-id=2
replicate_do_db=test2-slave

mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: localhost
Master_User: sync
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: log-bin.000006
Read_Master_Log_Pos: 1118
Relay_Log_File: zhxiang-relay-bin.000002
Relay_Log_Pos: 506
Relay_Master_Log_File: log-bin.000006
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: test2-slave
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 1118
Relay_Log_Space: 681
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: ae9f6304-b627-11e2-a154-c89cdc38d8be
Master_Info_File: D:\aslave\mysql\data\master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)

从上面的信息看来,所有配置都一切正常。
从库的IO和SQL两个线程启动状态是YES。
我在主库更新数据的时候,从库的日志指针也会跟着变。

但问题是:从库的数据从来不会改变。不管主库怎么更改数据,从库的数据从来都不相应的更新。
但查看各种状态,又一切正常。
真的搞不懂是什么原因。
请大家帮忙分析一下,谢谢!
这里我要再强调一点的是,主库和从库是在同一台机器上的两个MySql服务,版本完全相同,服务端口不同。
...全文
106 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
铁衣 2015-03-26
  • 打赏
  • 举报
回复
引用 1 楼 u012459865 的回复:
启动主从同步,start slave,LZ你有没有开启?
问题原因已经找到了,是因为我主从两个服务里的库名称不一致引起的。 我原先是est-master和test2-slave,后来把库名改成一致就能同步数据了。 谢谢你回答我的问题,分都给你吧。
猫神jdx 2015-03-26
  • 打赏
  • 举报
回复
启动主从同步,start slave,LZ你有没有开启?

56,678

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧