MySQL Advanced cluster-read-write separation amoeba

Source: Internet
Author: User


I. Introduction to the Environment
master-ip:10.0.0.201
slave-ip:10.0.0.202
amobea-ip:10.0.0.203

Ii. Installation of JDK
# Mkdir/amoeba
# TAR-XVF Jdk-7u40-linux-x64.tar.gz-c/amoeba/
# Vim/etc/profile
Java_home=/amoeba/jdk1.7.0_40
Export Java_home

Path= $JAVA _home/bin: $PATH
Export PATH

Classpath=.: $JAVA _home/lib/tools.jar: $JAVA _home/lib/dt.jar: $CLASSPATH
Export CLASSPATH

# java-version
Java Version "1.7.0_40"
Java (TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot (TM) 64-bit Server VM (build 24.0-b56, Mixed mode)

Third, installation amoeba
# Unzip amoeba-mysql-1.3.1-beta.zip-d/usr/local/amoeba/
# Chmod-r +x/usr/local/amoeba/bin/


Iv. Principal and subordinate authorization
>grant all privileges on * * to ' amobea ' @ '% ' identified by ' amoeba123 ';
>flush privileges;


V. Configuring the Amoeba File
# cd/usr/local/amoeba/conf
# Vim Amoeba.xml
Change the first area
#========================================================
<!--proxy server bound Port--
<property name= "Port" >9006</property>

<!--proxy server bound IP--

<property name= "IpAddress" >10.0.0.203</property>

<!--proxy server Net IO Read thread Size--
<property name= "Readthreadpoolsize" >20</property>

<!--proxy Server client process thread size--
<property name= "Clientsidethreadpoolsize" >30</property>

<!--MySQL server data packet process thread size--
<property name= "Serversidethreadpoolsize" >30</property>

<!--socket Send and receive buffersize (UNIT:K)--
<property name= "Netbuffersize" >128</property>

<!--enable/disable Tcp_nodelay (disable/enable Nagle ' s algorithm). -
<property name= "Tcpnodelay" >true</property>

<!--Externally authenticated user name--
<property name= "User" >root</property>

<!--Externally authenticated passwords--

<property name= "Password" >123456</property>

Change the second zone, "Configuring Master-side Login Information"
#========================================================
<dbserver name= "Server1" >

<!--Poolableobjectfactory Implementation class--
<factoryconfig class= "Com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory" >
<property name= "Manager" >defaultManager</property>

<!--real MySQL database Port--
<property name= "Port" >3306</property>

<!--real MySQL database IP--
<property name= "IpAddress" >10.0.0.201</property>
<property name= "schema" >test</property>

<!--user name to log in to MySQL--
<property name= "User" >amobea</property>

<!--password to log in to MySQL--


<property name= "Password" >amoeba123</property>


</factoryConfig>

<!--Objectpool Implementation class--
<poolconfig class= "Com.meidusa.amoeba.net.poolable.PoolableObjectPool" >
<property name= "Maxactive" >200</property>
<property name= "Maxidle" >200</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>

Change the third zone, "Configuring slave-side Login information"
#========================================================

<dbserver name= "Server2" >

<!--Poolableobjectfactory Implementation class--
<factoryconfig class= "Com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory" >
<property name= "Manager" >defaultManager</property>

<!--real MySQL database Port--
<property name= "Port" >3306</property>

<!--real MySQL database IP--
<property name= "IpAddress" >10.0.0.202</property>
<property name= "schema" >test</property>

<!--user name to log in to MySQL--
<property name= "User" >amobea</property>

<!--password to log in to MySQL--


<property name= "Password" >amoeba123</property>


</factoryConfig>

<!--Objectpool Implementation class--
<poolconfig class= "Com.meidusa.amoeba.net.poolable.PoolableObjectPool" >
<property name= "Maxactive" >200</property>
<property name= "Maxidle" >200</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>

Fourth area changed "Configure Master and slave load balancer pool"
#=======================================================
<dbserver name= "Master" virtual= "true" >
<poolconfig class= "Com.meidusa.amoeba.server.MultipleServerPool" >
<!--load Balancing parameters 1=roundrobin, 2=weightbased, 3=ha-->
<property name= "LoadBalance" >1</property>

<!--the list of poolname participating in the pool load balancer is separated by commas--
<property name= "Poolnames" >server1</property>
</poolConfig>
</dbServer>


<dbserver name= "Slave" virtual= "true" >
<poolconfig class= "Com.meidusa.amoeba.server.MultipleServerPool" >
<!--load Balancing parameters 1=roundrobin, 2=weightbased, 3=ha-->
<property name= "LoadBalance" >1</property>

<!--the list of poolname participating in the pool load balancer is separated by commas--
<property name= "Poolnames" >server1,server2</property>
</poolConfig>
</dbServer>

Changes to the fifth region, "Configuring Master and slave Read and write separation"
#=======================================================
<queryrouter class= "Com.meidusa.amoeba.mysql.parser.MysqlQueryRouter" >
<property name= "Ruleconfig" >${amoeba.home}/conf/rule.xml</property>
<property name= "Functionconfig" >${amoeba.home}/conf/functionMap.xml</property>
<property name= "Rulefunctionconfig" >${amoeba.home}/conf/ruleFunctionMap.xml</property>
<property name= "Lrumapsize" >1500</property>
<!--configuring master and slave read-write separation begin-->
<property name= "Defaultpool" >master</property>
<property name= "Writepool" >master</property>
<property name= "Readpool" >slave</property>
<!--configuring master and slave read-write separation end-->
<property name= "Needparse" >true</property>
</queryRouter>

Vi. Modify Log4j.xml to cancel log file generation (too big, the disk is easily full)
<param name= "File" value= "${amoeba.home}/logs/project.log"/>
Change into
<param name= "File" value= "<! [cdata[${amoeba.home}/logs/project.log>/dev/null]]> "/>

Vii. Modifying the Amoeba startup script
# Vim/usr/local/amoeba/bin/amoeba
#DEFAULT_OPTS = "-server-xms256m-xmx256m-xss128k" to comment out this line, adding a downward
Default_opts= "-server-xms256m-xmx256m-xss256k" adds this line

Viii. Start Amoeba Script
# nohup Bash-x/usr/local/amoeba/bin/amoeba &
# is the cat nohup.out log successful?
# Ps-ef | grep amoeba to see if the process started successfully
Root 1896 1637 1 03:28 pts/3 00:00:06/amoeba/jdk1.7.0_40/bin/java-server-xms256m-xmx256m-xss256k-damoeba.h ome=/usr/local/amoeba-dclassworlds.conf=/usr/local/amoeba/bin/amoeba.classworlds-classpath/usr/local/amoeba/ Lib/classworlds-1.0.jar Org.codehaus.classworlds.Launcher














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.