`
sillycat
  • 浏览: 2552719 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Mysql Scalability(4)Amoeba - Separate Reads and Writes

 
阅读更多

Mysql Scalability(4)Amoeba - Separate Reads and Writes

Separate Reads and Writes by Rules

Comments out the MysqlQueryRouter Configuration
<property name="sqlFunctionFile">${amoeba.home}/conf/functionMap.xml</property><property name="LRUMapSize">1500</property><property name="defaultPool">master1</property><!--<property name="writePool">master1</property><property name="readPool">slavePool1</property>--><property name="needParse">true</property>

A very simple rules in conf/rule.xml
<amoeba:rule xmlns:amoeba="http://amoeba.meidusa.com/">        <tableRule name="message"schema="sillycat"readPools="slavePool1"writePools="master1"/></amoeba:rule>

That means that database sillycat, table message will follow the reads and writes rules and separate in different databases, but all the other tables will go through the master1.

Sharding Across 4 Machines
4 machines, 2 masters, 2 slaves

Create Table
create table message(id int primary key, title char(255), message char(255) );
create table EVENTS (ID INT primary key, EVENT_REQUEST char(255), EVENT_RESPONSE char(255));

It does not work based on the message and events. So I use branduser at last.

This rule works.
        <tableRule name="branduser"schema="sillycat"defaultPools="slavePool1,slavePool2">                <rule name="rule1">                        <parameters>id</parameters>                        <expression><![CDATA[                                id <= 100                            ]]>                        </expression>                        <defaultPools>master1</defaultPools>                        <readPools>slavePool1</readPools>                        <writePools>master1</writePools>                </rule>                <rule name="rule2">                        <parameters>id</parameters>                        <expression><![CDATA[                                id > 100                        ]]>                        </expression>                        <defaultPools>master2</defaultPools>                        <readPools>slavePool2</readPools>                        <writePools>master2</writePools>                </rule>        </tableRule>

log from the router.log
2014-07-29 18:29:27,702 DEBUG route.AbstractQueryRouter - query={sql=[select * from branduser], parameter=[]}, no Column rule, using table:sillycat.branduser default rules:[slavePool1, slavePool2],  route to pools:[slavePool1, slavePool2] 2014-07-29 18:30:22,282 DEBUG route.AbstractQueryRouter - query={sql=[insert into branduser(id, username, age) values (15,"manager", 32)], parameter=[]}, matched table:sillycat.branduser, rule:rule1,  route to pools:[master2] 2014-07-29 18:30:47,326 DEBUG route.AbstractQueryRouter - query={sql=[select * from branduser], parameter=[]}, no Column rule, using table:sillycat.branduser default rules:[slavePool1, slavePool2],  route to pools:[slavePool1, slavePool2] 2014-07-29 18:31:07,936 DEBUG route.AbstractQueryRouter - query={sql=[insert into branduser(id, username, age) values (5,"developer", 28)], parameter=[]}, matched table:sillycat.branduser, rule:rule1,  route to pools:[master1]

This rule also works.
        <tableRule name="branduser"schema="sillycat"defaultPools="slavePool1,slavePool2">                <rule name="rule1"ruleResult="POOLNAME">                   <parameters>id</parameters>                   <expression><![CDATA[                           var hashid = abs(id) % 16;                           case  hashid         when range(0,8,1,1)  then (isReadStatement ? 'slavePool1' : 'master1');                                                when range(9,15,1,1) then (isReadStatement ? 'slavePool2' : 'master2');                           END CASE;                   ]]></expression>                </rule>        </tableRule>

And I place 4 amoeba proxy on all 4 machines. That should be 
ubuntu-master:8066   
ubuntu-client1:8066    
ubuntu-client2:8066    
ubuntu-client3:8066    

Then use my haproxy to proxy all these things on tcp level. It is on the machine ubuntu-client4. The configuration file is as follow:
#logging options global       

log 127.0.0.1 local0 info       

maxconn 5120       

chroot /opt/haproxy       

uid 99       

gid 99       

daemon       

quiet       

nbproc  2       

pidfile /opt/haproxy/haproxy.pid

 

#load balancing defaults

defaults      

log        global      

#使用4层代理模式,"mode   http"为7层代理模式      

mode       tcp      

#if you set mode to tcp,then you nust change tcplog into httplog      

option     tcplog      

option     dontlognull      

retries    3      

option redispatch      

maxconn 2000      

contimeout      5s      

clitimeout      120s      

srvtimeout      120s

#front-end IP for consumers and producters

listen rabbitmq_local_cluster ubuntu-client4:8066      

#配置TCP模式      

mode      tcp      

#balance url_param userid      

#balance url_param session_id check_post 64      

#balance hdr(User-Agent)      

#balance hdr(host)      

#balance hdr(Host) use_domain_only      

#balance rdp-cookie      

#balance leastconn      

#balance source  //ip      

#简单的轮询      

balance roundrobin      

#amoeba 集群节点配置      

server amoeba1  ubuntu-master:8066 check inter 5000 rise 2 fall 2      

server amoeba2  ubuntu-client1:8066 check inter 5000 rise 2 fall 2      

server amoeba2  ubuntu-client2:8066 check inter 5000 rise 2 fall 2      

server amoeba2  ubuntu-client3:8066 check inter 5000 rise 2 fall 2

#配置haproxy web监控,查看统计信息

listen private_monitoring :80      

mode    http      

option  httplog      

stats   enable      

#设置haproxy监控地址为http://ubuntu-client4/haproxy-status      

stats   uri  /haproxy-status      

stats   refresh 5s

Then I can connect the mysql server as follow:
mysql -h ubuntu-client4 -P 8066 -u root -p password

References:
http://sillycat.iteye.com/blog/2098033

http://docs.hexnova.com/amoeba/rule-configuration.html
http://docs.hexnova.com/amoeba/rw-splitting.html





分享到:
评论

相关推荐

    Designing for Scalability with Erlang-OTP.pdf

    Designing for Scalability with Erlang-OTP.pdf Designing for Scalability with Erlang-OTP.pdf Designing for Scalability with Erlang-OTP.pdf

    Overview of fine granularity scalability in MPEG-4 video standard

    ### 细粒度可伸缩性(Fine Granularity Scalability, FGS)在MPEG-4视频标准中的概述 #### 引言 随着互联网技术的发展,流媒体视频应用的需求日益增长,传统视频编码方法已无法满足网络视频传输的灵活性与高效性...

    Robustness Communication Software -- Extreme Availability, Reliability and Scalability for Carrier-Grade System

    综上所述,《Robustness Communication Software -- Extreme Availability, Reliability and Scalability for Carrier-Grade System》这本书提供了关于如何设计高性能、高可靠性、高可用性以及高伸缩性的电信级系统...

    Java Performance and Scalability(Server-Side Programming Techniques)

    学习java性能调优的好书,国外专家写的,很不错

    Bit-Rate-Scalability-in-Audio-Coding

    4. **自适应码率控制**:编码器能够根据网络状况实时调整编码参数,以确保音频流的稳定传输。例如,通过动态调整编码帧的大小或使用更高效的编码算法,来适应变化的带宽。 5. **多描述编码**:这种方法将音频信号...

    mysql-ref-5.6-en.pdf

    - **HA/Scalability Guide**:提供了关于如何构建高可用和可扩展MySQL架构的指南。 - **备份与恢复**:介绍了备份策略和恢复流程,确保数据的安全性和可靠性。 - **虚拟化**:讨论了MySQL在虚拟化环境中的部署和管理...

    mysql_refman-5.6-en.a4.pdf

    - **HA/Scalability Guide**:高可用性和可扩展性指南,讲解如何构建高可用和高性能的MySQL集群。 - **Server Administration**:服务器管理指南,涵盖服务器的安装、配置和维护等内容。 - **MySQL Yum ...

    MySQL 8 Administrator's Guide

    MySQL 8 Administrator's Guide pdf ...MySQL 8 - Scalability & High Availability MySQL 8 - Security Optimizing MySQL 8 Extending MySQL 8 MySQL 8 Best Practices & Benchmarking Troubleshooting MySQL 8

    mysql5.0参考手册-english

    根据提供的文件信息,我们可以从多个角度来探讨与MySQL 5.0相关的知识点。以下是对这些知识点的详细解析: ### MySQL 5.0 参考手册概述 #### 1. **MySQL 5.0版本覆盖范围** - **版本详情**:此手册涵盖了MySQL ...

    MySQL5.5使用手册---refman-5.5-en.pdf

    为了满足企业级应用的需求,MySQL 5.5 提供了一系列高可用性和可扩展性的解决方案,例如 MySQL Thread Pool、MySQL Cluster NDB 7.2、MySQL and DRBD 以及分区功能。这些特性有助于提高数据库的性能并确保其稳定性。...

    Pro-Java-Clustering-and-Scalability.pdf

    My name is Jorge Acetozi, and I’m a Brazilian software engineer who has worked for many years as a Java developer. During my career, I have been interested in subjects such as these: • Linux • ...

    hyperledger-fabric-linux-amd64-1.4.0-and-ca.zip

    hyperledger-fabric-linux-amd64-1.4.0-and-ca.zip

    Java Performance and Scalability

    Each optimization discusses techniques to improve the performance and scalability of your code. Every claim is substantiated with hard numbers and an experience-based evaluation. Java(TM) Performance...

    designing-for-scalability-with-erlang-otp-exercises:“Designing for Scalability with ErlangOTP”书籍练习

    在这个存储库中,我将阅读 Francesco Cesarini 和 Steve Vinoski 所著的“Designing for scaling with Erlang and Otp”一书时编写的代码组合在一起,你可以在购买这本书。 指数 第 3 章:行为 第 4 章:通用服务器

    mysql5.6手册英文版本

    - **扩展性**: 如 MySQL Proxy、MySQL and Virtualization 等。 #### 四、安全与合规 ##### 4.1 Security - **安全性**: MySQL Enterprise Security 功能介绍。 - **功能**: 包括加密、身份验证、访问控制等。 #...

    mysql-installer-web-community-5.7.29.0.msi + .NET Framework 4.5.2 安装包

    MySQL + .NET Framework 4.5.2 安装包 ...MySQL Cluster enables users to meet the database challenges of next generation web, cloud, and communications services with uncompromising scalability, uptime...

    Advanced Computer Architecture - Parallelism, Scalability, and Programmability

    Advanced Computer Architecture - Parallelism, Scalability, and Programmability 高级计算机体系结构

    OSG Scalability Area Tools-开源

    4. **故障检测与恢复**:检测系统故障并自动触发恢复机制,提高系统的可靠性。 5. **配置分析**:分析Glidein配置的合理性,提出改进建议。 6. **日志分析**:解析系统日志,找出性能问题的根源。 在使用...

Global site tag (gtag.js) - Google Analytics