处理一则MySQL Slave环境出现ERROR 1201 (HY000): Could not initialize master info structure的案例

mysql> start slave;
ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository

处理一则MySQL Slave环境出现ERROR 1201 (HY000): Could not initialize master info structure的案例。

冷备份方式复制一份新的slave,初始化参数中已经修改了相关文件路径及server_id等关联参数。

但在启动slave时发现error_log中出现下列错误信息:

120326 11:10:23 [ERROR] /usr/local/mysql//libexec/mysqld: File ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000002‘ not found (Errcode: 2)
120326 11:10:23 [ERROR] Failed to open log (file ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000002‘, errno 2)
120326 11:10:23 [ERROR] Failed to open the relay log ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000002‘ (relay_log_pos 126074557)
120326 11:10:23 [ERROR] Could not open log file
120326 11:10:23 [ERROR] Failed to initialize the master info structure

由于新的slave改变了服务端口和文件路径,分析应该是由于mysql-relay-bin.index中仍然保存着旧relay日志文件的路径,而这些路径下又找不到合适的文件,因此报错。

对于这类问题解决起来是比较简单的,重置slave的参照即可,执行命令如下:

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

mysql> change master to
    -> master_host=‘10.0.0.101‘,
    -> master_port=3306,
    -> master_user=‘repl‘,
    -> master_password=‘repl‘,
    -> master_log_file=‘mysql-bin.000011‘,
    -> master_log_pos=1;

ERROR 29 (HY000): File ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000001‘ not found (Errcode: 2)

看来应该还是mysql-relay-bin.index的问题,删除该文件及关联的relay-bin文件。再次配置master:

mysql> change master to
    -> master_host=‘10.0.0.101‘,
    -> master_port=3306,
    -> master_user=‘repl‘,
    -> master_password=‘repl‘,
    -> master_log_file=‘mysql-bin.000011‘,
    -> master_log_pos=1;
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log

出现了新的错误,按照提示查看error_log也没发现更多错误信息,error_log中只是显示一条:

120326 11:14:27 [ERROR] Error reading master configuration
在操作系统端查看master/slave的配置文件,发现是两个0字节文件:
-rw-rw---- 1 mysql mysql     0 Mar 26 11:13 master.info
-rw-rw---- 1 mysql mysql     0 Mar 26 11:13 relay-log.info

会不会是这个原因呢,直接删除这两个文件,然后尝试重新执行change master:

mysql> change master to
    -> master_host=‘10.0.0.101‘,
    -> master_port=3306,
    -> master_user=‘repl‘,
    -> master_password=‘repl‘,
    -> master_log_file=‘mysql-bin.000011‘,
    -> master_log_pos=1;
Query OK, 0 rows affected (0.00 sec)

成功,启动slave并查看状态:

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

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.0.0.101
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000011
          Read_Master_Log_Pos: 101

...........

故障解决。

转自: http://blog.itpub.net/7607759/viewspace-719707/

时间: 2024-10-25 16:03:52

处理一则MySQL Slave环境出现ERROR 1201 (HY000): Could not initialize master info structure的案例的相关文章

mysql连接报错 ERROR 2002 (HY000): Can't connect to local MySQL server through socket

安装完mysql连接报错: [[email protected] app]# mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) [[email protected] app]# mysql -uroot -p Enter password:  ERROR 2002 (HY000): Can't connect to local M

Mysql添加用户错误:ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value解决方法

添加用户 insert into mysql.user(Host,User,Password) values("localhost","test",password("1234")); 报以下的错误 ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value错误 mysql5.1以上版本,我是在5.6版本上操作的. 错语原因: mysql用户表的中某些字段不能为空,没有默

IT忍者神龟之mysql远程连接:ERROR 1130 (HY000): Host '*.*.*.*' is not allowed to connect to this MySQL server解决

安装完MySQL后,远程连接数据库的时候,出现 ERROR 1130 (HY000): Host '192.168.0.1' is not allowed to connect to this MySQL server提示信息,不能远程连接数据库.考虑可能是因为系统数据库mysql中user表中的host是localhost的原因,于是,我尝试把这个值改为自己服务器的ip,果然就好用了,不过用 mysql -u root -p命令就连不上数据库了,需要用mysql -h 服务器ip -u roo

mysql连接错误解决(ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol ref used (client option 'secure_auth' enabled))

当使用mysql的新版本是,连接老版本的mysql,就会有可能报: ERROR 2049 (HY000): Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)这个错误. 异常原因在于服务器端的密码管理协议陈旧,使用的是旧有的用户密码格式存储:但是客户端升级之后采用了新的密码格式.mysql新版本遇到这种不一致的情况就会拒绝连接. 所以在连接是:

MYSQL错误解决:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 据说这个问题的原因很多,当然,我自己这个问题我是清楚的,就是mysql.sock的位置所致,一个是PHP要求的,一个是MYSQLD定义的,一个是MY.CONF指定的...SO.... 暂时不能统一的话,用软链接LN -S命令解决吧.. 方案5 摘要:解决不能通过mysql.sock连接MySQ

MySQL远程连接出现ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'的问题

MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXXXX'的问题 问题描述: 从一台linux远程连接另一台linux上的MySQL, 出现ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.85'(111)错误. [[email protected] ~]$ mysql -hxxx.xxx.xxx.85 -uroot -p Enter pa

MySQL登录报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

[[email protected] mysql3307]# /opt/mysql3307/bin/mysql -upisp [email protected]123 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.so

mysql登陆时出现ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

有4到5天没开mysql,这天晚上打=打开phpstudy,想进去mysql练习练习,结果丢给我这个 ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 错误2013 (HY000):读取初始通信包时MySQL服务器连接丢失,系统错误0 windows进cmd命令行,输入server.msc,然后找到mysql的服务,重启一下就

【Problem】xampp in ubuntu下命令行启动mysql报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock' (2)

xampp in ubuntu下命令行启动mysql报错: [email protected]:/opt/lampp$ ./bin/mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/lampp/var/mysql/mysql.sock' (2) 启动mysql服务: [email protected]:/opt/lampp$ /