主从不同步(Slave_IO_Running: Connecting)

主从不同步(Slave_IO_Running: Connecting)

在从库上面查看:

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes

查看从库状态:

show slave status\G;

记得关注这么几个字段

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
                  Master_Host: 127.0.0.1
                  Master_User: slave
                  Master_Port: 3307
                Connect_Retry: 60
               // 下面这个表示从库中读取到的主库的文件
              Master_Log_File: mysql-bin.000001
			// 下面这个表示从库中读取到的主库文件中的位置
          Read_Master_Log_Pos: 858
              // 下面这个表示从库中SQL线程执行的文件
               Relay_Log_File: shizi-2-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          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
        // 下面这个表示从库中SQL线程执行的文件的位置
          Exec_Master_Log_Pos: 858
              

然后查看下主库中的binary log文件

查看主库

show binary logs;

mysql> show binary logs;
+------------------+-----------+-----------+
| Log_name         | File_size | Encrypted |
+------------------+-----------+-----------+
| mysql-bin.000001 |     27893 | No        |
| mysql-bin.000002 |      2297 | No        |
| mysql-bin.000003 |     37078 | No        |
+------------------+-----------+-----------+
3 rows in set (0.00 sec)

查看当前状态

show master status;

mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 |    37078 | demo1        |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

可以看到是从库的IO线程没有将数据给同步过来,只同步了主库的 0001文件中的靠前的位置。我们看下从库的日志

查看从库日志

show variables like ‘log_error’;

mysql> show variables like 'log_error';
+---------------+-----------------------------------------------------+
| Variable_name | Value                                               |
+---------------+-----------------------------------------------------+
| log_error     | /Users/zhouzhenyong/mysql-cluster/slave1/mysqld.log |
+---------------+-----------------------------------------------------+
1 row in set (0.00 sec)

看到这里有大量的这个错误

Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection. Error_code: MY-002061

原因是mysql8的密码方式采用的跟之前的不同,需要这么来使用就可以了在从库进行授权位置的时候添加参数:get_master_public_key=1,就可以了
鉴于我们的从库已经有一段没有同步了,那么从那个没有同步的位置开始(即主库的858位置)

进入从库:

// 停止
stop slave;

// 重新授权
change master to master_host=‘127.0.0.1’,master_port=3307,master_user=‘slave’,master_password=‘slave1234’,master_log_file=‘mysql-bin.000001’,master_log_pos=858,get_master_public_key=1;

// 启动从库
start slave;

// 查看状态
show status slave;

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 127.0.0.1
                  Master_User: slave
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 37078
               Relay_Log_File: shizi-2-relay-bin.000004
                Relay_Log_Pos: 37293
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
参考:

http://blog.itpub.net/30393770/viewspace-2660966/

  • 7
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值