设为首页 加入收藏

TOP

MySQL读写分离(二)
2014-11-24 08:14:01 来源: 作者: 【 】 浏览:10
Tags:MySQL 读写 分离
000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: 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: 107 Relay_Log_Space: 410 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: Replicate_Ignore_Server_Ids: Master_Server_Id: 2 1 row in set (0.00 sec) ERROR: No query specified mysql> select user,password,host from mysql.user; +------+-------------------------------------------+-----------------+ | user | password | host | +------+-------------------------------------------+-----------------+ | root | | localhost | | root | | serv08.host.com | | root | | 127.0.0.1 | | root | | ::1 | | | | localhost | | | | serv08.host.com | | rep | *0CDC8D34246E22649D647DB04E7CCCACAB4368B6 | 192.168.1.% | +------+-------------------------------------------+-----------------+ 7 rows in set (0.00 sec) mysql> create database larrydb; Query OK, 1 row affected (0.00 sec) mysql> use larrydb; Database changed mysql> create table user(id int, name varchar(30)); Query OK, 0 rows affected (0.01 sec) mysql> insert into user values(1,'larrywen'); Query OK, 1 row affected (0.01 sec) mysql> insert into user values(2,'wentasy'); Query OK, 1 row affected (0.00 sec) mysql> select * from user; +------+----------+ | id | name | +------+----------+ | 1 | larrywen | | 2 | wentasy | +------+----------+ 2 rows in set (0.00 sec) serv09 mysql> select * from larrydb.user; +------+----------+ | id | name | +------+----------+ | 1 | larrywen | | 2 | wentasy | +------+----------+ 2 rows in set (0.00 sec)

第五步,为了查看现象,serv09从服务器关闭slave

mysql> stop slave;
Query OK, 0 rows affected (0.01 sec)

第六步,serv 01查看是否有MySQL用户,修改rw-splitting.lua文件,修改如下几个参数

[root@serv01 mysql-proxy]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)

[root@serv01 mysql-proxy]# vim rw-splitting.lua 
[root@serv01 mysql-proxy]# cat rw-splitting.lua | grep -e min_idle_connections -e max_idle_connections -e is_debug
    min_idle_connections = 1,--最小空闲连接数,为了测试,这里设置为1
    max_idle_connections = 1,--最大空闲连接数,为了测试,这里设置为1
    is_debug = true--是否打开Debug调试,为了查看调试信息,这里设置为true

第七步,启动mysql-proxy

[root@serv01 mysql-proxy]# /etc/init.d/mysql-proxy start
Starting mysql-proxy:
  
--先确定是否可以连接
[root@serv01 ~]# mysql -ularry -plarry -h 192.168.1.18
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.29-log Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
[root@serv01 ~]# mysql -ularry -plarry -h 192.168.1.19
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection
首页 上一页 1 2 3 4 5 下一页 尾页 2/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇mysql一个简单查询中的group by和.. 下一篇高性能MySql进化论(十):查询优化..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Java 集合框架 - 菜 (2025-12-27 02:19:36)
·Java集合框架最全详 (2025-12-27 02:19:33)
·为什么安卓开发要用J (2025-12-27 02:19:30)
·C/C++ 类模板与模板 (2025-12-27 01:49:52)
·C语言 模板化<templ (2025-12-27 01:49:49)