New version of Amoeba MYSQL read/write splitting Configuration

Source: Internet
Author: User

Official introduction
The Chinese meaning of Amoeba is a variant insect.
Main solution:
• Reduce the complex multi-database structure caused by data splitting
• Provides sharding rules and reduces the impact of data sharding rules on Applications
• Reduce the number of connections between the database and the client
• Read/write splitting

Personal brief description
Maybe you still don't understand what Amoebla is doing! For example, as we all know in the PHP environment, PHP does not have a data connection pool. If MYSQL is frequently accessed in the PHP environment, it will crash unless the Cluster is configured, And Amoeba is between the PHP program and MYSQL, acts as a buffer.

Preparations
Server: 192.168.1.208 # Amoeba
Server: 192.168.1.11 # NDBD1 (master)
Server: 1921.68.1.13 # NDBD2 (slave)
Note: Install MYSQL in one step on servers 11 and 13.

In addition, you must install MYSQL 5.1 or later because the new version of Amoeba2.10 is unstable for versions earlier than 5.1.

 

Structure chart

 

Step 1: Configure Amoeba192.168.2.8 read/write splitting
1: unzip the installation package
[Root @ Management down] # mkdir/usr/local/amoeba
[Root @ Management down] # tar-zxf amoeba-mysql-binary-2.1.0-RC5.tar.gz-C/usr/local/amoeba/
2: Go to the configuration directory and browse the file
[Root @ Management down] # cd/usr/local/amoeba/
[Root @ Management amoeba] # ll
Total 88
Drwxr-xr-x 2 root 4096 Jul 26 :57 benchmark
Drwxr-xr-x 2 root 4096 Feb 28 09:25 bin
-Rw-r -- 1 root 3983 May 18 changelogs.txt
Drwxr-xr-x 2 root 4096 Jul 26 :57 conf
Drwxr-xr-x 3 root 4096 Jul 26 11: 57
-Rw-r -- 1 root 34520 May 18 LICENSE.txt
-Rw-r -- 1 root 2031 May 18 README.html
3: Enter the main configuration file directory
[Root @ Management amoeba] # cd conf/
[Root @ Management conf] # ls
Access_list.conf amoeba. xml dbServers. xml functionMap. xml log4j. xml ruleFunctionMap. xml
Amoeba. dtd dbserver. dtd function. dtd log4j. dtd rule. dtd rule. xml
Here I will mainly introduce three major configuration files: amoeba. xml, dbServers. xml, and log4j. xml. Other files can be acquired by default without special requirements.
4: Modify the main configuration file in vi amoeba. xml
4.1) change the default port 8066 to 3306.
<Property name = "port"> 3066 </property>
4.2) change the default connection user name and password to your own
<Property name = "user"> sky </property>

<Property name = "password"> 123456 </property>
4.3) change the default client thread count, request count, and Server Response count to 200,300,300.
<Property name = "readThreadPoolSize"> 200 </property>

<! -- Proxy server client process thread size -->
<Property name = "clientSideThreadPoolSize"> 300 </property>

<! -- Mysql server data packet process thread size -->
<Property name = "serverSideThreadPoolSize"> 300 </property
4.4) Remove the comments and modify the readpool to server2.
<! --
-->
<Property name = "writePool"> server1 </property>
<Property name = "readPool"> server2 </property>


5: add the SEVER2 module in vi dbServers. xml. The connection username and password and address in the module indicate the physical machines of the two MYSQL servers. 192.168.1.11 and 192.168.1.13 indicate the physical machines of the two MYSQL servers, while the SERVER reads the data.
You need to manually add the SERVER2 Code as follows:
<DbServer name = "Maid active =" true ">

<FactoryConfig class = "com.meidusa.amoeba.mysql.net. MysqlServerConnectionFactory">

<Property name = "manager" >$ {defamanager} </property>

<Property name = "sendBufferSize"> 64 </property>

<Property name = "receiveBufferSize"> 128 </property>

<! -- Mysql port -->

<Property name = "port"> 3306 </property>

<! -- Mysql schema -->

<Property name = "schema"> test </property>

<! -- Mysql user -->

<Property name = "user"> root </property>

<! -- Mysql password

-->

<Property name = "password"> 123456 </property>

</FactoryConfig>

 

<PoolConfig class = "com.meidusa.amoeba.net. poolable. PoolableObjectPool">

<Property name = "maxActive"> 500 </property>

<Property name = "maxIdle"> 500 </property>

<Property name = "minIdle"> 10 </property>

<Property name = "minEvictableIdleTimeMillis"> 600000 </property>

<Property name = "timeBetweenEvictionRunsMillis"> 600000 </property>

<Property name = "testOnBorrow"> true </property>

<Property name = "testWhileIdle"> true </property>

</PoolConfig>

</DbServer>

 

<DbServer name = "server1" parent = "abstractServer">

<FactoryConfig>

<! -- Mysql ip -->

<Property name = "ipAddress"> 192.168.2.11 </property>

</FactoryConfig>

</DbServer>


Eventually changed to the following:
<? Xml version = "1.0" encoding = "gbk"?>

 

<! DOCTYPE amoeba: dbServers SYSTEM "dbserver. dtd">

<Amoeba: dbServers xmlns: amoeba = "http://amoeba.meidusa.com/">

 

<! --

Each dbServer needs to be configured into a Pool,

If you need to configure multiple dbServer with load balancing that can be simplified by the following configuration:

Add attribute with name virtual = "true" in dbServer, but the configuration does not allow the element with name factoryConfig

Such as 'multisize' dbServer

-->

<DbServer name = "Maid active =" true ">

<FactoryConfig class = "com.meidusa.amoeba.mysql.net. MysqlServerConnectionFactory">

<Property name = "manager" >$ {defamanager} </property>

<Property name = "sendBufferSize"> 64 </property>

<Property name = "receiveBufferSize"> 128 </property>

<! -- Mysql port -->

<Property name = "port"> 3306 </property>

<! -- Mysql schema -->

<Property name = "schema"> test </property>

<! -- Mysql user -->

<Property name = "user"> root </property>

<! -- Mysql password

-->

<Property name = "password"> 123456 </property>

</FactoryConfig>

 

<PoolConfig class = "com.meidusa.amoeba.net. poolable. PoolableObjectPool">

<Property name = "maxActive"> 500 </property>

<Property name = "maxIdle"> 500 </property>

<Property name = "minIdle"> 10 </property>

<Property name = "minEvictableIdleTimeMillis"> 600000 </property>

<Property name = "timeBetweenEvictionRunsMillis"> 600000 </property>

<Property name = "testOnBorrow"> true </property>

<Property name = "testWhileIdle"> true </property>

</PoolConfig>

</DbServer>

 

<DbServer name = "server1" parent = "abstractServer">

<FactoryConfig>

<! -- Mysql ip -->

<Property name = "ipAddress"> 192.168.2.11 </property>

</FactoryConfig>

</DbServer>

 

 

<! -- ####################### Copy the preceding content to the following table, to add SERVER2 ###############################-->

 

 

<DbServer name = "Maid active =" true ">

<FactoryConfig class = "com.meidusa.amoeba.mysql.net. MysqlServerConnectionFactory">

<Property name = "manager" >$ {defamanager} </property>

<Property name = "sendBufferSize"> 64 </property>

<Property name = "receiveBufferSize"> 128 </property>

<! -- Mysql port -->

<Property name = "port"> 3306 </property>

<! -- Mysql schema -->

<Property name = "schema"> test </property>

<! -- Mysql user -->

<Property name = "user"> root </property>

<Property name = "password"> 123456 </property>

</FactoryConfig>

 

<PoolConfig class = "com.meidusa.amoeba.net. poolable. PoolableObjectPool">

<Property name = "maxActive"> 500 </property>

<Property name = "maxIdle"> 500 </property>

<Property name = "minIdle"> 10 </property>

<Property name = "minEvictableIdleTimeMillis"> 600000 </property>

<Property name = "timeBetweenEvictionRunsMillis"> 600000 </property>

<Property name = "testOnBorrow"> true </property>

<Property name = "testWhileIdle"> true </property>

</PoolConfig>

</DbServer>

 

<DbServer name = "server2" parent = "abstractServer">

<FactoryConfig>

<! -- Mysql ip -->

<Property name = "ipAddress"> 192.168.2.13 </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>

</Amoeba: dbServers>

 

6: Modify log4j. xml to cancel log file generation (too large, and the disk is easily full)
<Param name = "file" value = "$ {amoeba. home}/logs/project. log"/>
Change
<Param name = "file" value = "<! [CDATA [$ {amoeba. home}/logs/project. log>/dev/null]> "/>
7: Performance Optimization. Open bin/amoeba.

DEFAULT_OPTS = "-server-Xms256m-Xmx256m-Xss128k"
Change
DEFAULT_OPTS = "-server-Xms512m-Xmx512m-Xmn100m-Xss1204k"
8: Start amoeba
Nohup/usr/local/amoeba/bin/amoeba start 2> & 1>/dev/null &

 


This article is from the "Intelligence" blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.