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;sql

ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log服務器

 

查看日誌socket

[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.indexblog

discuz   master.info  slave.pid               slave-relay-bin.000004  slave-relay-bin.000008  slave-relay-bin.000012  testget

ibdata1  mysql        slave-relay-bin.000001  slave-relay-bin.000005  slave-relay-bin.000009  slave-relay-bin.000013input

 

[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

相關文章
相關標籤/搜索