Chinaunix

标题: 【讨论中】mysql双机热备--问题(help!!!) [打印本页]

作者: shuimuyq    时间: 2012-07-06 16:43
标题: 【讨论中】mysql双机热备--问题(help!!!)
本帖最后由 cenalulu 于 2012-07-08 21:59 编辑

本人在虚拟机下虚拟两台 centos5.4 都装了同一版本的mysql(Server version: 5.0.95-log Source distribution)
在[mysqld]中加入以下内容
server-id=1 #设置服务器的ID号
log-bin #设置同步
logbinlog-do-db=test #设置同步数据库
max_binlog_size=104857600
replicate-same-server-id
master-host=192.168.254.2 #主机IP
master-user=backup
master-password=qawsed
master-port=3306
master-connect-retry=60 #断点重试间隔为60秒
replicate-do-db=test #表示同步test数据库
binlog-ignore-db=mysql #不同步的数据库

两台虚拟机都差不多添加上面的内容 只是ip什么的变了一下
都弄好了以后 在一台虚拟机(A)上
mysql > show master status;
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| mysqld-bin.000002 |       98 | test         | mysql            |
+-------------------+----------+--------------+------------------+

在另一台虚拟机(B)上
mysql > start slave;
mysql > show slave status\G
*************************** 1. row ***************************
             Slave_IO_State: Connecting to master
                Master_Host: 192.168.96.133
                Master_User: backup
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File:
        Read_Master_Log_Pos: 4
             Relay_Log_File: mysqld-relay-bin.000002
              Relay_Log_Pos: 98
      Relay_Master_Log_File:
           Slave_IO_Running: No
          Slave_SQL_Running: Yes
            Replicate_Do_DB: test
        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: 0
            Relay_Log_Space: 98
            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: NULL

mysql日志error为
120706  1:06:16 [ERROR] Slave I/O thread: error connecting to master 'backup@192.168.96.133:3306': Error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 113'  errno: 2013  retry-time: 60  retries: 86400

求解!!!!
感谢大家。
作者: rucypli    时间: 2012-07-06 17:07
先试试在slave能不能用mysql客户端登陆master
作者: rucypli    时间: 2012-07-06 17:08
然后ping下是否丢包
作者: shuimuyq    时间: 2012-07-06 17:27
回复 2# rucypli

该怎么操作??

两台虚拟机相互能ping通



   
作者: horizonhyg    时间: 2012-07-06 17:52
system error: 113 的意思是no route to host,就是主机不通。也就是Bping不通,查看网络吧。
作者: RogerZhuo    时间: 2012-07-06 17:52
perror 113
OS error code 113:  No route to host

说明slave不能到达master,
作者: shuimuyq    时间: 2012-07-07 08:30
我的两台虚拟机 用NAT跟主机连接 虚拟机a的 ip:192.168.96.130 虚拟机b的 ip:192.168.96.133
在虚拟机a 终端
#ping 192.168.96.133
PING 192.168.96.133 (192.168.96.133) 56(84) bytes of data.
64 bytes from 192.168.96.133: icmp_seq=1 ttl=64 time=0.575 ms
64 bytes from 192.168.96.133: icmp_seq=2 ttl=64 time=0.231 ms
64 bytes from 192.168.96.133: icmp_seq=3 ttl=64 time=0.235 ms
64 bytes from 192.168.96.133: icmp_seq=4 ttl=64 time=0.459 ms
64 bytes from 192.168.96.133: icmp_seq=5 ttl=64 time=0.238 ms

在虚拟机b 终端
#ping 192.168.96.130
PING 192.168.96.130 (192.168.96.130) 56(84) bytes of data.
64 bytes from 192.168.96.130: icmp_seq=1 ttl=64 time=0.614 ms
64 bytes from 192.168.96.130: icmp_seq=2 ttl=64 time=0.226 ms
64 bytes from 192.168.96.130: icmp_seq=3 ttl=64 time=0.331 ms
64 bytes from 192.168.96.130: icmp_seq=4 ttl=64 time=0.240 ms
64 bytes from 192.168.96.130: icmp_seq=5 ttl=64 time=0.248 ms


这样算两台虚拟机可以联通吗
作者: shuimuyq    时间: 2012-07-07 08:46
说明一下
我两台虚拟机是克隆体
所有东西都一模一样
这样可以吗
是否要改动什么数据才行
我在虚拟机b 的终端上输入
#mysql -h192.168.96.130 -ubackup -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.96.130' (113)


确实是没法连接到虚拟机a的mysql
作者: shuimuyq    时间: 2012-07-07 09:56
问题已解决
是iptables没有关闭
#service iptables stop

就可以连接上了

再次感谢大家的帮忙!!!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2