MYSQL主從複製配置遇到的問題

來源:互聯網
上載者:User

標籤:change master   error   mysql主從   bin   

在進行配置從伺服器時遇到的錯誤。

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


查看日誌

[[email protected] 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


[[email protected] 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*,使得再次配置無法產生,刪除掉之前產生的檔案就可以。

[[email protected] 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

[[email protected] mysql]# ls -a

.  ..  discuz  ibdata1  ib_logfile0  ib_logfile1  master.info  mysql  relay-log.info  slave.err  slave.pid  test

[[email protected] mysql]# rm relay-log.info 

rm:是否刪除 一般檔案 “relay-log.info”? y

[[email protected] mysql]# rm master.info 

rm:是否刪除 一般檔案 “master.info”? y

[[email protected] mysql]# ls -a

.  ..  discuz  ibdata1  ib_logfile0  ib_logfile1  mysql  slave.err  slave.pid  test


[[email protected] 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主從複製配置遇到的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.