Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2814091
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2010-01-22 10:37:11

在做mysql replication时,后台的日志中弹出如下的错误:
 

100122 10:21:04 [ERROR] Slave I/O thread: error connecting to master : Error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 111' errno: 2013 retry-time: 3306 retries: 86400

 

Slave_io_running 为NO,显然这有问题,其实我的一切配置都正常!
解决方法如下:
If you have already done some settings with the slave...do a 'reset slave' before 'change master' query ,also do not forget to comment you #bind-address
 

 

###解决问题的过程!

mysql> reset slave;
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)

mysql> reset slave;
Query OK, 0 rows affected (0.02 sec)

mysql> change master to master_host='172.17.61.127',master_user='slaveuser1',master_password='slaveuser1',master_log_file='mysql-bin.000009',master_log_pos=1356;
Query OK, 0 rows affected (0.01 sec)

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)

mysql> show slave status \G
*************************** 1. row ***************************
             Slave_IO_State: Waiting for master to send event
                Master_Host: 172.17.61.127
                Master_User: slaveuser1
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.000009
        Read_Master_Log_Pos: 1356
             Relay_Log_File: slave-relay.000002
              Relay_Log_Pos: 235
      Relay_Master_Log_File: mysql-bin.000009
           Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
            Replicate_Do_DB: test
        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: 1356
            Relay_Log_Space: 235
            Until_Condition: None
             Until_Log_File:
              Until_Log_Pos: 0
         Master_SSL_Allowed: No
         Master_SSL_CA_File: 0
         Master_SSL_CA_Path:
            Master_SSL_Cert:
          Master_SSL_Cipher:
             Master_SSL_Key:
      Seconds_Behind_Master: 0
1 row in set (0.00 sec)

mysql>

还有一种解决方法:
mysql> STOP SLAVE;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.00 sec)

mysql> UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)

mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysqld-bin.00000*';
Query OK, 0 rows affected (0.00 sec)

mysql> CHANGE MASTER TO MASTER_LOG_POS=*;
Query OK, 0 rows affected (0.00 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

The Slave IO and SQL are now both yes. Slave_IO_State: Waiting for master to send event .

显然问题即可解决!

mysql replcation中遇到的小问题(easy!)

问题2:

由于我在change ***中将mysql_log_file='filename' 中的filename写错了。故出现以上的错误!
 

问题3:

原因:在change ××××时master_user='*",master_password='*"写错一个或全部写错或用户根本不存在!


问题4:

出错如下:

ERROR 1598 (HY000): Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'

解决方法:在/etc/my.cnf中加入 binlog_format           = mixed

问题5:在做master/slave时,为了确保数据的一致性,原想把master库锁住,将master上的所有库都复制到slave库上去,结果执行flush tables with read lock后很快就可以插入数据了,flush tables with read lock很快就释放锁了!

原因: 

wait_timeout        = 10
interactive_timeout  = 10
设置太小导致锁失败
修改为:
wait_timeout        = 28800    #8个小时
interactive_timeout  = 28800 #8个小时

阅读(2335) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~