zoukankan      html  css  js  c++  java
  • MysqlRouter 实现mysql5.6读写分离

    • 下载,安装
     
    [root@localhost src]# cd /usr/local/src/
    [root@localhost src]# tar zxvf mysql-router-2.0.3-linux-glibc2.12-x86-64bit.tar.gz -C /usr/local/soft/
    [root@localhost src]# cd /usr/local/soft/
    [root@localhost soft]# ll
    total 36
    drwxr-xr-x.  9 xiaojf xiaojf 4096 Oct 30 00:20 elasticsearch
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 filebeat
    drwxr-xr-x.  8 uucp      143 4096 Apr  1  2016 jdk
    drwxrwxr-x. 11   1000   1000 4096 Jul 10  2016 kibana
    drwxr-xr-x.  6 root   root   4096 Jul  9  2016 logstash
    drwxrwxr-x.  7   7161 wheel  4096 Feb 22  2016 mysql-router-2.0.3-linux-glibc2.12-x86-64bit
    drwxrwxr-x.  6 root   root   4096 Dec  6 00:38 redis-3.2.6
    drwxr-xr-x.  5 root   root   4096 Jan 13 22:57 redis_cluster
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 tar
    [root@localhost soft]# mv mysql-router-2.0.3-linux-glibc2.12-x86-64bit mysql-router
    [root@localhost soft]# ll
    total 36
    drwxr-xr-x.  9 xiaojf xiaojf 4096 Oct 30 00:20 elasticsearch
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 filebeat
    drwxr-xr-x.  8 uucp      143 4096 Apr  1  2016 jdk
    drwxrwxr-x. 11   1000   1000 4096 Jul 10  2016 kibana
    drwxr-xr-x.  6 root   root   4096 Jul  9  2016 logstash
    drwxrwxr-x.  7   7161 wheel  4096 Feb 22  2016 mysql-router
    drwxrwxr-x.  6 root   root   4096 Dec  6 00:38 redis-3.2.6
    drwxr-xr-x.  5 root   root   4096 Jan 13 22:57 redis_cluster
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 tar
    • 配置文件
     
    [root@localhost mysql-router]# cd /usr/local/soft/mysql-router/
    [root@localhost mysql-router]# touch mysqlrouter.ini
    [root@localhost mysql-router]# vi mysqlrouter.ini
     
    [DEFAULT]
    logging_folder = /usr/local/soft/mysql-router/logs
     
    [logger]
    level = INFO
     
    [routing:read_write]
    bind_address = 192.168.59.128
    bind_port = 8001
    destinations = 192.168.59.128:3306
    mode = read-write
    max_connections = 1024
    max_connect_errors = 100
    client_connect_timeout = 9
     
    [routing:read_only]
    bind_address = 192.168.59.128
    bind_port = 8002
    destinations = 192.168.59.129:3306
    mode = read-only
    max_connections = 65535
    max_connect_errors = 100
    client_connect_timeout = 9
     
    [root@localhost mysql-router]# mkdir -p /usr/local/soft/mysql-router/logs
     
    • 开发  8001 8002 端口
    • 启动
     
    [root@localhost mysql-router]./bin/mysqlrouter -c ./mysqlrouter.ini &
     
    • 监控日志
     
    [root@localhost ~]# tail -f /usr/local/soft/mysql-router/logs/mysqlrouter.log
     
    • 连接
     
    [root@localhost mysql-router]# mysql -uxiaojf -pxiaojf -P 8001
    Warning: Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 29
    Server version: 5.6.28-log MySQL Community Server (GPL)
     
    Copyright (c) 2000, 2015, 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> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | elearning          |
    | mysql              |
    | performance_schema |
    +--------------------+
    4 rows in set (0.00 sec)
     
    mysql>
    • 下载,安装
     
    [root@localhost src]# cd /usr/local/src/
    [root@localhost src]# tar zxvf mysql-router-2.0.3-linux-glibc2.12-x86-64bit.tar.gz -C /usr/local/soft/
    [root@localhost src]# cd /usr/local/soft/
    [root@localhost soft]# ll
    total 36
    drwxr-xr-x.  9 xiaojf xiaojf 4096 Oct 30 00:20 elasticsearch
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 filebeat
    drwxr-xr-x.  8 uucp      143 4096 Apr  1  2016 jdk
    drwxrwxr-x. 11   1000   1000 4096 Jul 10  2016 kibana
    drwxr-xr-x.  6 root   root   4096 Jul  9  2016 logstash
    drwxrwxr-x.  7   7161 wheel  4096 Feb 22  2016 mysql-router-2.0.3-linux-glibc2.12-x86-64bit
    drwxrwxr-x.  6 root   root   4096 Dec  6 00:38 redis-3.2.6
    drwxr-xr-x.  5 root   root   4096 Jan 13 22:57 redis_cluster
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 tar
    [root@localhost soft]# mv mysql-router-2.0.3-linux-glibc2.12-x86-64bit mysql-router
    [root@localhost soft]# ll
    total 36
    drwxr-xr-x.  9 xiaojf xiaojf 4096 Oct 30 00:20 elasticsearch
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 filebeat
    drwxr-xr-x.  8 uucp      143 4096 Apr  1  2016 jdk
    drwxrwxr-x. 11   1000   1000 4096 Jul 10  2016 kibana
    drwxr-xr-x.  6 root   root   4096 Jul  9  2016 logstash
    drwxrwxr-x.  7   7161 wheel  4096 Feb 22  2016 mysql-router
    drwxrwxr-x.  6 root   root   4096 Dec  6 00:38 redis-3.2.6
    drwxr-xr-x.  5 root   root   4096 Jan 13 22:57 redis_cluster
    drwxr-xr-x.  2 root   root   4096 Jul  9  2016 tar
    • 配置文件
     
    [root@localhost mysql-router]# cd /usr/local/soft/mysql-router/
    [root@localhost mysql-router]# touch mysqlrouter.ini
    [root@localhost mysql-router]# vi mysqlrouter.ini
     
    [DEFAULT]
    logging_folder = /usr/local/soft/mysql-router/logs
     
    [logger]
    level = INFO
     
    [routing:read_write]
    bind_address = 192.168.59.128
    bind_port = 8001
    destinations = 192.168.59.128:3306
    mode = read-write
    max_connections = 1024
    max_connect_errors = 100
    client_connect_timeout = 9
     
    [routing:read_only]
    bind_address = 192.168.59.128
    bind_port = 8002
    destinations = 192.168.59.129:3306
    mode = read-only
    max_connections = 65535
    max_connect_errors = 100
    client_connect_timeout = 9
     
    [root@localhost mysql-router]# mkdir -p /usr/local/soft/mysql-router/logs
     
    • 开发  8001 8002 端口
    • 启动
     
    [root@localhost mysql-router]./bin/mysqlrouter -c ./mysqlrouter.ini &
     
    • 监控日志
     
    [root@localhost ~]# tail -f /usr/local/soft/mysql-router/logs/mysqlrouter.log
     
    • 连接
     
    [root@localhost mysql-router]# mysql -uxiaojf -pxiaojf -P 8001
    Warning: Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 29
    Server version: 5.6.28-log MySQL Community Server (GPL)
     
    Copyright (c) 2000, 2015, 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> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | elearning          |
    | mysql              |
    | performance_schema |
    +--------------------+
    4 rows in set (0.00 sec)
     
    mysql>
  • 相关阅读:
    js代码细嚼慢咽
    HTML知识点记录

    css知识点
    算法第五章作业
    算法第五章上机实践报告
    算法第四章上机实践报告
    算法第四章作业
    算法第三章上机实践报告
    算法第三章作业
  • 原文地址:https://www.cnblogs.com/xiaojf/p/6561309.html
Copyright © 2011-2022 走看看