自建slave报错Last_IO_Error: error connecting to master 'user@xx:xx' - retry-tim

2023-09-13 20:00:37 浏览数 (1)

代码语言:javascript复制
> show slave statusG
*************************** 1. row ***************************
               Slave_IO_State: Connecting to master
                  Master_Host: xxx
                  Master_User: slave
                  Master_Port: 21229
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 4
        Relay_Master_Log_File: 
             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
          Exec_Master_Log_Pos: 0
              Relay_Log_Space: 154
              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: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 2003
                Last_IO_Error: error connecting to master 'slave@42.194.248.5:21229' - retry-time: 60  retries: 1
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 0
                  Master_UUID: 
             Master_Info_File: /var/lib/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 230913 19:23:08
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

1、先检查账号密码,host是否正确,命令行是否可以正常登陆master。

2、若账号密码可以正常登陆在从库执行命令,查看是否有如下报错

代码语言:javascript复制
cat /var/log/audit/audit.log
代码语言:javascript复制
type=SYSCALL msg=audit(1694604668.405:175): arch=c000003e syscall=42 success=no exit=-13 a0=2f a1=7fa7f800e570 a2=10 a3=72 items=0 ppid=1 pid=2564 auid=4294967295 uid=27 gid=27 euid=27 suid=27 fsuid=27 egid=27 sgid=27 fsgid=27 tty=(none) ses=4294967295 comm="mysqld" exe="/usr/sbin/mysqld" subj=system_u:system_r:mysqld_t:s0 key=(null)

如果有这个报错,解决办法两种:

1、slave操作系统执行如下命令,修改端口号为3307,之后再次stop并start试试

代码语言:javascript复制
semanage port -a -t mysqld_port_t -p tcp 3307    (3307指端口号)

2、编辑/etc/selinux/config禁用 SELinux,将“SELINUX=enforcing”行更改为“SELINUX=disabled”,然后重新启动系统,之后重新chage_master并start slave;

原因:selinux限制,方法一通过修改为允许的端口号解决,方法二禁用selinux解决,推荐方法二。

报错信息:

Last_IO_Errno: 2003

0 人点赞