首页 > 代码库 > MYSQL主从复制配置遇到的问题
MYSQL主从复制配置遇到的问题
在进行配置从服务器时遇到的错误。
mysql> change master to master_host=‘192.168.136.129‘,master_user=‘repl‘,master_password=‘123456‘,master_log_file=‘mysql-bin.000003‘,master_log_pos=2610;
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log
查看日志
[root@slave mysql]# ls -a
. ib_logfile0 relay-log.info slave-relay-bin.000002 slave-relay-bin.000006 slave-relay-bin.000010 slave-relay-bin.000014
.. ib_logfile1 slave.err slave-relay-bin.000003 slave-relay-bin.000007 slave-relay-bin.000011 slave-relay-bin.index
discuz master.info slave.pid slave-relay-bin.000004 slave-relay-bin.000008 slave-relay-bin.000012 test
ibdata1 mysql slave-relay-bin.000001 slave-relay-bin.000005 slave-relay-bin.000009 slave-relay-bin.000013
[root@slave etc]# tail /data/mysql/slave.err
Version: ‘5.1.40‘ socket: ‘/tmp/mysql.sock‘ port: 3306 MySQL Community Server (GPL)
141103 15:42:29 mysqld_safe A mysqld process already exists
141103 16:48:32 [ERROR] Failed to open the relay log ‘./localhost-relay-bin.000001‘ (relay_log_pos 4)
141103 16:48:32 [ERROR] Could not find target log during relay log initialization
141103 16:49:51 [ERROR] Failed to open the relay log ‘./localhost-relay-bin.000001‘ (relay_log_pos 4)
141103 16:49:51 [ERROR] Could not find target log during relay log initialization
141103 16:49:52 [ERROR] Failed to open the relay log ‘./localhost-relay-bin.000001‘ (relay_log_pos 4)
141103 16:49:52 [ERROR] Could not find target log during relay log initialization
141103 16:49:53 [ERROR] Failed to open the relay log ‘./localhost-relay-bin.000001‘ (relay_log_pos 4)
141103 16:49:53 [ERROR] Could not find target log during relay log initialization
解决:
由于之前配置过,生成了一些*relay*,使得再次配置无法生成,删除掉之前生成的文件就可以。
[root@slave mysql]# rm *bin*
rm:是否删除 一般文件 “slave-relay-bin.000001”? y
rm:是否删除 一般文件 “slave-relay-bin.000002”? y
rm:是否删除 一般文件 “slave-relay-bin.000003”? y
rm:是否删除 一般文件 “slave-relay-bin.000004”? y
rm:是否删除 一般文件 “slave-relay-bin.000005”? y
rm:是否删除 一般文件 “slave-relay-bin.000006”? y
rm:是否删除 一般文件 “slave-relay-bin.000007”? y
rm:是否删除 一般文件 “slave-relay-bin.000008”? y
rm:是否删除 一般文件 “slave-relay-bin.000009”? y
rm:是否删除 一般文件 “slave-relay-bin.000010”? y
rm:是否删除 一般文件 “slave-relay-bin.000011”? y
rm:是否删除 一般文件 “slave-relay-bin.000012”? y
rm:是否删除 一般文件 “slave-relay-bin.000013”? y
rm:是否删除 一般文件 “slave-relay-bin.000014”? y
rm:是否删除 一般文件 “slave-relay-bin.index”? y
[root@slave mysql]# ls -a
. .. discuz ibdata1 ib_logfile0 ib_logfile1 master.info mysql relay-log.info slave.err slave.pid test
[root@slave mysql]# rm relay-log.info
rm:是否删除 一般文件 “relay-log.info”? y
[root@slave mysql]# rm master.info
rm:是否删除 一般文件 “master.info”? y
[root@slave mysql]# ls -a
. .. discuz ibdata1 ib_logfile0 ib_logfile1 mysql slave.err slave.pid test
[root@slave mysql]# /usr/local/mysql/bin/mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.40 MySQL Community Server (GPL)
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> slave stop;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> change master to master_host=‘192.168.136.129‘,master_user=‘repl‘,master_password=‘123456‘,master_log_file=‘mysql-bin.000003‘,master_log_pos=2610;
Query OK, 0 rows affected (0.06 sec)
mysql> slave start;
Query OK, 0 rows affected (0.03 sec)
不再报错,配置成功!
另计,发现master.info 文件里面记录的是自己配置的选项。
本文出自 “学习” 博客,请务必保留此出处http://tyl00.blog.51cto.com/6576378/1571338
MYSQL主从复制配置遇到的问题