zoukankan      html  css  js  c++  java
  • mysql读写分离

    首先server1,server2,配置好主从关系
    在server3中;
    tar zxf mysql-proxy-0.8.5-linux-el6-x86-64bit.tar.gz -C /usr/local/
    cd /usr/local/
    ln -s mysql-proxy-0.8.5-linux-el6-x86-64bit/ mysql-proxy
    mkdir /usr/local/mysql-proxy/log  
    mkdir /usr/local/mysql-proxy/etc
    cd mysql-proxy
    vim etc/mysql-proxy.conf
     
    user=root
    daemon=true
    keepalive=true
    log-level=info
    pid-file=/usr/local/mysql-proxy/log/mysql-proxy.pid
    log-file=/usr/local/mysql-proxy/log/mysql-proxy.log
    proxy-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
    proxy-address=172.25.8.3:3306
    proxy-backend-addresses=172.25.8.1:3306
    proxy-read-only-backend-addresses=172.25.8.2:3306
    plugins=proxy
    chmod 660 etc/mysql-proxy.conf
    vim share/doc/mysql-proxy/rw-splitting.lua
    bin/mysql-proxy --defaults-file=/usr/local/mysql-proxy/etc/mysql-proxy.conf
    更改lua脚本

    netstat -antlp

    server1,2,3,:
    yum install lsof -y
    lsof -i :3306
    在server3:

    在seerer2:

    在server1:

    server1:
    mysql> grant select,insert,update on westos.* to bss@'%' identified by 'Westos-123';

    物理机
    mysql -uproxy -p -h 172.25.8.3
    MySQL [(none)]> use test;
    MySQL [test]> select * from userlist;
    MySQL [test]> insert into userlist values ('user3','666');
    MySQL [test]> insert into userlist values ('user4','888');
    MySQL [test]> select * from userlist;

     
  • 相关阅读:
    NPTL 线程同步方式
    mysql事物处理
    DHCP服务器-DNS服务器-Samba服务器
    NTP服务器
    wsgiref 源代码分析
    集群负载均衡LVS
    百万数据查询优化技巧三十则
    Shell 基本运算符
    Shell 数组
    Shell 传递参数
  • 原文地址:https://www.cnblogs.com/zhengyipengyou/p/9750967.html
Copyright © 2011-2022 走看看