时间:2021-07-01 10:21:17 帮助过:63人阅读
插入数据:
mysql> insert into qinglv values(‘wuba‘,25);
[read_query] 188.188.1.138:56958
current backend = 0
client default db = ckl
client username = root
query = insert into qinglv values(‘wuba‘,25)
sending to backend : 188.188.1.144:3306
is_slave : false
server default db: ckl
server username : root
in_trans : false
in_calc_found : false
COM_QUERY : true
Query OK, 1 row affected (0.01 sec)
查看表:
mysql> select * from qinglv;
[read_query] 188.188.1.138:56958
current backend = 0
client default db = ckl
client username = root
query = select * from qinglv
server default db:
client default db: ckl
syncronizing
sending to backend : 188.188.1.175:3306
is_slave : true
server default db:
server username : root
in_trans : false
in_calc_found : false
COM_QUERY : true
+-----------+------+
| name | age |
+-----------+------+
| ckl | 26 |
| xiong | 24 |
| ckl | 26 |
| xiong | 24 |
| kangle | 0 |
| kangkang | 26 |
| xiaoxiong | 24 |
| haha | 33 |
| ceshi | 34 |
| wukaka | 30 |
| heixiu | 28 |
| zengjia | 22 |
| mama | 23 |
| meko | 32 |
| kkk | 89 |
| jkl | 20 |
| jia | 23 |
+-----------+------+
17 rows in set (0.00 sec)
没有数据
启动主从同步,再查看:
mysql> select * from qinglv;
[read_query] 188.188.1.138:56958
current backend = 0
client default db = ckl
client username = root
query = select * from qinglv
sending to backend : 188.188.1.175:3306
is_slave : true
server default db: ckl
server username : root
in_trans : false
in_calc_found : false
COM_QUERY : true
+-----------+------+
| name | age |
+-----------+------+
| ckl | 26 |
| xiong | 24 |
| ckl | 26 |
| xiong | 24 |
| kangle | 0 |
| kangkang | 26 |
| xiaoxiong | 24 |
| haha | 33 |
| ceshi | 34 |
| wukaka | 30 |
| heixiu | 28 |
| zengjia | 22 |
| mama | 23 |
| meko | 32 |
| kkk | 89 |
| jkl | 20 |
| jia | 23 |
| bba | 12 |
| wuba | 25 |
+-----------+------+
19 rows in set (0.00 sec)
查看日志:
[root@localhost logs]# cat /usr/local/mysql-proxy/logs/mysq-proxy.log
2012-03-29 21:10:48: (message) mysql-proxy 0.8.1 started
2012-03-29 21:10:48: (message) proxy listening on port :4040
2012-03-29 21:10:48: (message) added read/write backend: 188.188.1.144:3306
2012-03-29 21:10:48: (message) added read-only backend: 188.188.1.175:3306
2012-03-29 21:14:45: (message) mysql-proxy 0.8.1 started
2012-03-29 21:14:45: (message) proxy listening on port :4040
2012-03-29 21:14:45: (message) added read/write backend: 188.188.1.144:3306
2012-03-29 21:14:45: (message) added read-only backend: 188.188.1.175:3306
至此,读写分离完成。
本文出自 “运维菜鸟” 博客,请务必保留此出处http://ckl893.blog.51cto.com/8827818/1682262
mysql-proxy 读写分离
标签:mysql-proxy 读写分离