zoukankan      html  css  js  c++  java
  • mysql-router

    mysql-router是一个轻量级的中间间,可以做mysql的故障自动转移以及读写分离功能

    1.官网下载mysql-router二进制包

    2.主机介绍:

    主机 作用
    192.168.11.4 master
    192.168.11.5 slave1
    192.168.11.6 slave2
    192.168.11.7 mysql-router

    3,创建目录

    >>mkdir  -p  /var/log/mysqlrouter         :日志目录

    >>mkdir -p /etc/mysqlrouter/mysqlrouter.conf  :这个是配置文件

    [root@node04 mysqlrouter]# cat mysqlrouter.conf 
    [default]
    logging_folder=/var/log/mysqlrouter
    
    [logger]
    leverl=info
    
    [routing:failover]
    bind_address=0.0.0.0
    bind_port=7001
    max_connections=1024
    mode=read-write
    destinations=192.168.11.4:3307,192.168.11.5:3307
    
    [routing:balancing]
    bind_address=0.0.0.0
    bind_port=7002
    max_connections=1024
    mode=read-only
    destinations=192.168.11.5:3307,192.168.11.6:3307

    4.启动

    >>mysql -uroot -p123 -h192.168.11.7 -P7001 &        后台启动,这里可以下载启动脚本进行启动(自己下载)

    >>mysql -uroot -p123 -h192.168.11.7 -P7002&        

    说明:7001端口是故障自动切换端口以及可读写

       7002端口是负载均衡端口,可以实现负载均衡效果,但是只能读,不能写

    5.效果如下:

    [root@node04 bin]# ./mysql -umysqlrouter -p123 -h192.168.11.7 -P7002 -e 'select @@server_id'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    +-------------+
    | @@server_id |
    +-------------+
    |          67 |
    +-------------+
    [root@node04 bin]# ./mysql -umysqlrouter -p123 -h192.168.11.7 -P7002 -e 'select @@server_id'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    +-------------+
    | @@server_id |
    +-------------+
    |          57 |
    +-------------+
    [root@node04 bin]# ./mysql -umysqlrouter -p123 -h192.168.11.7 -P7002 -e 'select @@server_id'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    +-------------+
    | @@server_id |
    +-------------+
    |          67 |
    +-------------+
    [root@node04 bin]# ./mysql -umysqlrouter -p123 -h192.168.11.7 -P7002 -e 'select @@server_id'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    +-------------+
    | @@server_id |
    +-------------+
    |          57 |
    +-------------+
  • 相关阅读:
    cocos2dx 菜鸟实习生学习篇(四) 锚点的理解
    cocos2dx 菜鸟进阶篇(三) scrollView(下)
    2012年终总结!
    cocos2dx 菜鸟进阶篇(二) 重力感应
    cocos2dx 菜鸟进阶篇(三) ScrollView(上)
    cocos2dx 菜鸟进阶篇(一) 在游戏中添加music
    Mobile Web项目中碰到的问题及解决
    struts验证框架的使用
    错误解决办法收集
    JSONP跨域访问实现登录验证
  • 原文地址:https://www.cnblogs.com/zmc60/p/14454266.html
Copyright © 2011-2022 走看看