Last_IO_Error: error connecting to master 'tl@192.168.199.151:3306'

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: <p>环境:</p> <p>centoos 6.5  主从</p> <p>mysql 5.6.12</p> <p><br></p> <p>主: 192.168.199.11</p> <p>从:192.168.199.12</p> <p><br></p> <p>主从切换</p> <p><br></p> <p>把 12 变为主,从为11 </p> <p>结果报错:</p>

环境:

centoos 6.5  主从

mysql 5.6.12


主: 192.168.199.11

从:192.168.199.12


主从切换


把 12 变为主,从为11 

结果报错:


Last_IO_Error: error connecting to master 'tl@192.168.199.151:3306'


11 从机上看到的:

刚配置的MySQL主从,在从机上看到

点击(此处)折叠或打开

  1. mysql> SHOW slave STATUS \\G
  2. *************************** 1. row ***************************
  3.                Slave_IO_State: Connecting to master
  4.                   Master_Host: 172.17.210.199
  5.                   Master_User: my
  6.                   Master_Port: 3306
  7.                 Connect_Retry: 60
  8.               Master_Log_File: masters-bin.000003
  9.           Read_Master_Log_Pos: 1224
  10.                Relay_Log_File: testmysql-relay-bin.000001
  11.                 Relay_Log_Pos: 4
  12.         Relay_Master_Log_File: masters-bin.000003
  13.              Slave_IO_Running: Connecting
  14.             Slave_SQL_Running: NO
  15.               Replicate_Do_DB: 
  16.           Replicate_Ignore_DB:
看日志有很多:

点击(此处)折叠或打开

  1. 141010 0:02:48 [ERROR] Slave I/O: error connecting to master \'my@172.17.210.199:3306\' - retry-time: 60 retries: 1, Error_code: 2003
  2. 141010 0:03:48 [ERROR] Slave I/O: error connecting to master \'my@172.17.210.199:3306\' - retry-time: 60 retries: 2, Error_code: 2003
  3. 141010 0:04:48 [ERROR] Slave I/O: error connecting to master \'my@172.17.210.199:3306\' - retry-time: 60 retries: 3, Error_code: 2003
  4. 141010 0:05:48 [ERROR] Slave I/O: error connecting to master \'my@172.17.210.199:3306\' - retry-time: 60 retries: 4, Error_code: 2003
  5. 141010 0:06:48 [ERROR] Slave I/O: error connecting to master \'my@172.17.210.199:3306\' - retry-time: 60 retries: 5, Error_code: 2003
  6. 141010 0:07:48 [ERROR] Slave I/O: error connecting to master \'my@172.17.210.199:3306\' - retry-time: 60 retries: 6, Error_code: 2003
  1. 解决方法:  
  2.   
  3. 导致lave_IO_Running 为connecting 的原因主要有以下 3 个方面:  
  4.   
  5. 1、网络不通  
  6. 2、密码不对  
  7. 3、pos不对
  8. 解决步骤:
  9. 1、对于第一个问题,一般情况下都是可以排除的,也是最容易排除的。
  10. 2、在主库上修改用来复制的用户的密码。
  11. 3、 在做chang to 的时候注意log_pos 是否跟此时主机的一样。在主机上 show master status \G ;可以查看到

主机上:

mysql> show master status \G;
*************************** 1. row ***************************
             File: masters-bin.000003
         Position: 2392
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: 
1 row in set (0.00 sec)

ERROR: 
No query specified

11上执行:

stop slave
从机上面执行change to 的正确
CHANGE MASTER TO 
MASTER_HOST='192.168.199.12', 
MASTER_USER='my', 
MASTER_PASSWORD='123456', 
MASTER_LOG_FILE='masters-bin.000003', 
MASTER_LOG_POS= 2392;


01  start  slave  show slave status;

需要注意的几个问题:

要在change master to语句的master_password部分使用原始的密码而非散列过的密码。

注意在第一时间查看错误日志文件,可使用perror工具根据错误代码查看具体的错误。


另外几个常见问题:

mysql无法启动:先看错误日志文件中提示的错误,依据错误找原因;查看配置文件中数据目录等配置是否正确;检查MySQL相关目录属主和属组是否正确;查看是否有之前未被正确关闭的mysqld进程仍在运行。

mysql无法连接:先看mysqld进程是否正确启动了;再看提供的连接串是否争取无误。


参考:

http://blog.itpub.net/27099995/viewspace-1294075/

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
17天前
|
Kubernetes 容器 Perl
error: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is cu
error: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is cu
20 0
|
8月前
|
数据安全/隐私保护
Do Sync Disk 0 Part 0 Failed, code=S3_F42, msg=Sync Failed after retry 5 times
Do Sync Disk 0 Part 0 Failed, code=S3_F42, msg=Sync Failed after retry 5 times
143 1
|
网络协议 Java
filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer
filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer
321 0
filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer
ERROR node.Application: A fatal error occurred while running
ERROR node.Application: A fatal error occurred while running
|
NoSQL MongoDB
运行 mongo 出现 Error: couldn‘t connect to server 127.0.0.1:27017, connection attempt failed
运行 mongo 出现 Error: couldn‘t connect to server 127.0.0.1:27017, connection attempt failed
503 0
运行 mongo 出现 Error: couldn‘t connect to server 127.0.0.1:27017, connection attempt failed
|
关系型数据库 MySQL Linux
Slave_IO_Running: No 的解决
原因:两台主从数据库的uuid相同了(没猜错的话,各位应该是直接克隆了linux服务器,然后配置主从数据库,一通操作,到最后启动从数据库,发现的这个问题吧)。1:使用 find / -iname "auto.cnf" 命令查找你数据库的auto.cnf 配置文件。我的在这个目录下,同学们的也可能在其他目录,取决于你mysql放的位置哈。譬如:你把最后的f改成e,跟主数据库不一样就行。4: 登录mysql,重启slave,再次验证。2:对这个配置文件的uuid进行更改。
149 0
Slave_IO_Running: No 的解决
|
测试技术
The concurrent snapshot for publication 'xxx' is not available because it has not been fully generated or the Log Reader Agent is not running to activ
在两台测试服务器部署了复制(发布订阅)后,发现订阅的表一直没有同步过来。重新生成过snapshot ,也重新初始化过订阅,都不能同步数据,后面检查Distributor To Subscriber History, 发现有如下日志信息: The concurrent snapshot for pub...
1505 0
|
应用服务中间件 nginx
[error] 17755#0: *58522 readv() failed (104: Connection reset by peer) while reading upstream
[error] 17755#0: *58522 readv() failed (104: Connection reset by peer) while reading upstream
4897 0