MySQL主从同步、读写分离配置步骤、问题解决(二)

2014-11-24 14:29:42 · 作者: · 浏览: 1
---+--------------+------------------+

| updatelog.000012 | 15016 | data | mysql |

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)

由此可见两者的File、Position存在问题,所要要去Slave上设置对应主库的Master_Log_File、Read_Master_Log_Pos;执行如下语句;

mysql>slave stop;

mysql>CHANGE MASTER TO MASTER_HOST='192.168.0.1',MASTER_USER='test', MASTER_PASSWORD='******',MASTER_LOG_FILE='updatelog.000012',MASTER_LOG_POS=15016;

确保Slave_IO_Running: Yes 、Slave_SQL_Running: Yes都要为YES才能证明Slave的I/O和SQL进行正常。

9、解锁主库表;

UNLOCK TABLES;

到此主从MySQL服务器配置完成,测试结果如下;

mysql> show master status;

+------------------+----------+--------------+------------------+

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| updatelog.000012 | 717039 | data | mysql |

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)

mysql> show slave status\G;

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.0.1

Master_User: test

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: updatelog.000012

Read_Master_Log_Pos: 717039

Relay_Log_File: onlinevc-relay-bin.000013

Relay_Log_Pos: 1222

Relay_Master_Log_File: updatelog.000012

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB: data

Replicate_Ignore_DB: mysql

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: 717039

Relay_Log_Space: 1834

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

1 row in set (0.00 sec)

ERROR:

No query specified

#################################### 如下是MySQL数据库读写分离操作步骤##########################################

此处使用MySQL自己(Mysql-proxy)的代理实现数据库的读写分离;

所需要安装包如下;

1、check-0.9.8

2、glib-2.18.4

3、libevent-2.0.6-rc

4、lua-5.1.4

wget http://www.lua.org/ftp/lua-5.1.4.tar.gz

5、pkg-config-0.23

6、mysql-5.0.56

7、mysql-proxy-0.8.0

http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/mysql-proxy-0.8.0.tar.gz

别的安装包地址当时没有记下载地址,不过大部分都在这个网站上找的;http://sourceforge.net/

&&&&&&&&&& 安装开始&&&&&&&&

1、tar -zxvf check-0.8.4.tar.gz

cd check-0.8.4

./configure

make

make install

2、tar -zxvf glib-2.18.4.tar.gz //系统rpm包可能版本低出现了问题3;

./configure

make

make install

3、tar -zxvf libevent-2.0.6-r