• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Mysql Scalability(三)Amoeba – Proxy – Reads and Writes_mysql

mysql 搞代码 7年前 (2018-06-07) 207次浏览 已收录 0个评论

mysql Scalability(3)Amoeba – Proxy – Reads and Writes

Mysql Scalability(3)Amoeba – Proxy – Reads and Writes

Oh, seem that the Amoeba is working with version 2.2.0. I will try this version with source codes.

Find the start script file bin/amoeba, find the line which configure the java_OPTS, change it as follow:
DEFAULT_OPTS=-server -Xms256m -Xmx256m -Xss256k

Then we can run 
>bin/amoeba start

One Machine Proxy
Check the configuration files for db connection information
>vi dbServers.xml
        <dbServer name=“server1”  parent=“abstractServer”]]>                <factoryConfig>                        <property name=“ipAddress”]]>ubuntu-master</property>                </factoryConfig>        </dbServer>         <!–            <dbServer name=”server2″  parent=”abstractServer”>                <factoryConfig>                        <property name=”ipAddress”>ubuntu-client1</property>                </factoryConfig>        </dbServer>        –>         <dbServer name=“multiPool”virtual=“true”]]>                <poolConfig class=“com.meidusa.amoeba.server.MultipleServerPool”]]>                        <!– Load balancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA–>                        <property name=“loadbalance”]]>1</property>                         <!– Separated by commas,such as: server1,server2,server1 –>                        <property name=“poolNames”]]>server1</property>                </poolConfig>        </dbServer>

Check the Proxy Connection Configuration
>vi amoeba.xml 
                <service name=“Amoeba Monitor Server”class=“com.meidusa.amoeba.monitor.MonitorServer”]]>                        <!– port –>                        <!–  default value: random number                        <property name=”port”>9066</property>                        –>                        <!– bind ipAddress –>                        <property name=“ipAddress”]]>0.0.0.0</property>                        <property name=“daemon”]]>true</property>                        <property name=“manager”]]>${clientConnectioneManager}</property>                        <property name=“connectionFactory”]]>                                <bean class=“com.meidusa.amoeba.monitor.net.MonitorClientConnectionFactory”></bean>                        </property>                 </service>

After star the amoeba, we can use this proxy to connect to the DB.

>mysql -h ubuntu-master -u root -P 8066 -p

Multiple Machine – Separating Writes and Reads

Grant the Privileges
>use mysql;
>grant all privileges on test.* to root@”%” identified by ‘kaishi’;
>flush privileges;

Show the SQL
>use mysql
>show variables like “%general_log%”;
+——————+———————————-+ | Variable_name    | Value                            | +——————+———————————-+ | general_log      | OFF                              | | general_log_file | /var/lib/mysql/ubuntu-master.log | +——————+———————————-+ 2 rows in set (0.00 sec)
>set global general_log = true;

>sudo tail -f /var/lib/mysql/ubuntu-master.log

Prepare the Configurations
        <dbServer name=“master1”  parent=“abstractServer”]]>                <factoryConfig>                        <property name=“ipAddress”]]>ubuntu-master</property>                </factoryConfig>        </dbServer>         <dbServer name=“slave11”  parent=“abstractServer”]]>                <factoryConfig>                        <property name=“ipAddress”]]>ubuntu-client1</property>                </factoryConfig>        </dbServer>         <dbServer name=“slavePool1”virtual=“true”]]>                <poolConfig class=“com.meidusa.amoeba.server.MultipleServerPool”]]>                        <!– Load balancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA–>                        <property name=“loadbalance”]]>1</property>                         <!– Separated by commas,such as: server1,server2,server1 –>                        <property name=“poolNames”]]>slave11</property>                </poolConfig>        </dbServer>

        <queryRouter class=“com.meidusa.amoeba.mysql.parser.MysqlQueryRouter”]]>                <property name=“ruleLoader”]]>                        <bean class=“com.meidusa.amoeba.route.TableRuleFileLoader”]]>                                <property name=“ruleFile”]]>${amoeba.home}/conf/rule.xml</property>                                <property name=“functionFile”]]>${amoeba.home}/conf/ruleFunctionMap.xml</property>                        </bean>                </property>                <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>        </queryRouter>

Execute these SQLs to Verify
>insert into branduser(id,username,age) values (2, “kiko”, 28);
>select * from branduser;

Here is the slave machines
140729 11:14:15  44 Queryselect * from branduser 140729 11:16:13    1 QueryBEGIN                    1 Queryinsert into branduser(id,username,age) values (2, “kiko”, 28)                    1 QueryCOMMIT /* implicit, from Xid_log_event */ 140729 11:16:53  44 Queryselect * from branduser

Here is the master machines
140729 11:16:13  43 Queryinsert into branduser(id,username,age) values (2, “kiko”, 28)

That works well to separate the reads and writes.

References:
Download the mysql-proxy all versions
https://downloads.skysql.com/archive/index/p/mysql-proxy/v/0.8

http://askubuntu.com/questions/477873/how-do-i-work-around-a-stack-size-specified-is-too-small-error-in-java-on-powe

http://boke.25k5.com/kan16489.html
http://www.cnblogs.com/taven/archive/2012/09/11/2680282.html
http://www.aslibra.com/blog/post/amoeba_mysql_proxy_rw_split.php
https://www.centos.bz/2012/05/amoeba-for-mysql/
http://pengranxiang.iteye.com/blog/1145342

http://sillycat.iteye.com/blog/2070163 mysql logging

欢迎大家阅读《Mysql Scalability(三)Amoeba – Proxy – Reads and Writes_mysql》,跪求各位点评,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Mysql Scalability(三)Amoeba – Proxy – Reads and Writes_mysql

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址