免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1989 | 回复: 8
打印 上一主题 下一主题

【讨论中】mysql双机热备--问题(help!!!) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-07-06 16:43 |只看该作者 |倒序浏览
本帖最后由 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

求解!!!!
感谢大家。

论坛徽章:
0
2 [报告]
发表于 2012-07-06 17:07 |只看该作者
先试试在slave能不能用mysql客户端登陆master

论坛徽章:
0
3 [报告]
发表于 2012-07-06 17:08 |只看该作者
然后ping下是否丢包

论坛徽章:
0
4 [报告]
发表于 2012-07-06 17:27 |只看该作者
回复 2# rucypli

该怎么操作??

两台虚拟机相互能ping通



   

论坛徽章:
0
5 [报告]
发表于 2012-07-06 17:52 |只看该作者
system error: 113 的意思是no route to host,就是主机不通。也就是Bping不通,查看网络吧。

论坛徽章:
0
6 [报告]
发表于 2012-07-06 17:52 |只看该作者
perror 113
OS error code 113:  No route to host

说明slave不能到达master,

论坛徽章:
0
7 [报告]
发表于 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


这样算两台虚拟机可以联通吗

论坛徽章:
0
8 [报告]
发表于 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

论坛徽章:
0
9 [报告]
发表于 2012-07-07 09:56 |只看该作者
问题已解决
是iptables没有关闭
#service iptables stop

就可以连接上了

再次感谢大家的帮忙!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP