찾다

 >  Q&A  >  본문

mysql优化 - mysql 主从复制 Slave_IO_Running 进程为no ?

主从复制失败,发现Slave_IO_Running这个进程一直是NO

查看错误日志,得到信息是slave用户无法连接到master服务器上

 position 98, relay log './mysqld-relay-bin.000001' position: 4
150921  4:11:08 [ERROR] Slave I/O thread: error connecting to master 'repl@192.168.126.132:3306': Error: 'Host '192.168.126.132' is not allowed to connect to this MySQL server'  errno: 1130  retry-time: 60  retries: 86400
150921  5:06:57 [Note] Slave I/O thread killed while connecting to master
150921  5:06:57 [Note] Slave I/O thread exiting, read up to log 'binlog_name.000001', position 98
150921  5:06:57 [Note] Error reading relay log event: slave SQL thread was killed

但是我在slave主机,可以直接使用repl用户连接到master服务器上查询相关的表,为什么说我不允许连接这个机器呢?

天蓬老师天蓬老师2767일 전561

모든 응답(2)나는 대답할 것이다

  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:18:19

    我后来解决了

    1.应该在slave机器上使用change master to 写上 master机器的ip,我却写了slave自己的ip地址

    2.当我修改完ip后,发现报一个The slave I/O thread stops because master and slave have equal MySQL server ids(slave和master使用了公共的一个server-id号)

    查询了一下my.cnf文件,发现原来默认已经分配了relication的server-id号

    # Replication Master Server (default)
    # binary logging is required for replication
    # log-bin=mysql-bin 
    
    # required unique id between 1 and 2^32 - 1
    # defaults to 1 if master-host is not set
    # but will not function as a master if omitted
    server-id       = 2 

    而这个默认的server_id号,把我上面的server_id号给覆盖了,导致了两个server_id号相同了

    회신하다
    0
  • 黄舟

    黄舟2017-04-17 13:18:19

    可能在master上'binlog_name.000001', position 98,如果是以为文件被截断了或者删除了,这样可以通过change master to 里面的master_log_file和master_log_pos来设置到下一个binlog的位置

    회신하다
    0
  • 취소회신하다