进入slave服务器,运行:

  1.  
    ​mysql> show slave status\G
  2.  
     
  3.  
             .......
  4.  
                 Relay_Log_File: localhost-relay-bin.000535
  5.  
                  Relay_Log_Pos: 21795072
  6.  
          Relay_Master_Log_File: localhost-bin.000094
  7.  
               Slave_IO_Running: Yes
  8.  
              Slave_SQL_Running: No
  9.  
                Replicate_Do_DB: 
  10.  
            Replicate_Ignore_DB: 
  11.  
          ......
  12.  
     
  13.  

解决办法一、

Slave_SQL_Running: No
1.程序可能在slave上进行了写操作

2.也可能是slave机器重起后,事务回滚造成的.

一般是事务回滚造成的:
解决办法:

  1.  
    mysqlstop slave ;
  2.  
    mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
  3.  
    mysqlstart slave ;

 

解决办法二、

首先停掉Slave服务:slave stop
到主服务器上查看主机状态:
记录File和Position对应的值

进入master

  1.  
    mysql> show master status;
  2.  
    +----------------------+----------+--------------+------------------+
  3.  
    | File                 | Position | Binlog_Do_DB | Binlog_Ignore_DB |
  4.  
    +----------------------+----------+--------------+------------------+
  5.  
    | localhost-bin.000094 | 33622483 |              |                  | 
  6.  
    +----------------------+----------+--------------+------------------+
  7.  
    1 row in set (0.00 sec)

然后到slave服务器上执行手动同步:

  1.  
    mysql> change master to 
  2.  
    > master_host='master_ip',
  3.  
    > master_user='user', 
  4.  
    > master_password='pwd', 
  5.  
    > master_port=3306, 
  6.  
    > master_log_file=localhost-bin.000094', 
  7.  
    > master_log_pos=33622483 ;
  8.  
    1 row in set (0.00 sec)
  9.  
    mysql> start slave ;
  10.  
    1 row in set (0.00 sec)
  11.  
     
  12.  
    mysql> show slave status\G
  13.  
    *************************** 1. row ***************************
  14.  
    ........
  15.  
                Master_Log_File: localhost-bin.000094
  16.  
            Read_Master_Log_Pos: 33768775
  17.  
                 Relay_Log_File: localhost-relay-bin.000537
  18.  
                  Relay_Log_Pos: 1094034
  19.  
          Relay_Master_Log_File: localhost-bin.000094
  20.  
               Slave_IO_Running: Yes
  21.  
              Slave_SQL_Running: Yes
  22.  
                Replicate_Do_DB:

手动同步需要停止master的写操作!