小編給大家分享一下Amoeba新版本MYSQL讀寫分離如何配置,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
創(chuàng)新互聯(lián)-專業(yè)網站定制、快速模板網站建設、高性價比常州網站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式常州網站制作公司更省心,省錢,快速模板網站建設找我們,業(yè)務覆蓋常州地區(qū)。費用合理售后完善,十年實體公司更值得信賴。官方簡介
Amoeba的中文意思是變型蟲
主要解決:
• 降低 數據切分帶來的復雜多數據庫結構
• 提供切分規(guī)則并降低 數據切分規(guī)則 給應用帶來的影響
• 降低db 與客戶端的連接數
• 讀寫分離
個人簡單描述
可能你還沒明白Amoebla這鬼東西主要干麻的呢!比方說PHP環(huán)境眾所周知,PHP沒有數據連接池,如果PHP環(huán)境下MYSQL訪問量大時會蹦掉,除非配置Cluster集群,而Amoeba就是在PHP程序和MYSQL之間,充當一個緩沖的作用。
準備工作
Server:192.168.1.208 #Amoeba
Server:192.168.1.11 #NDBD1(主)
Server:1921.68.1.13 #NDBD2(從)
注:11和13兩臺服務器上,事先請安裝好MYSQL單向步
另請安裝MYSQL版本必須5.1以上,因為新版的Amoeba2.10對5.1以下版本不穩(wěn)定。
結構圖
Step 1:配置Amoeba192.168.2.8讀寫分離
1:解壓安裝包
[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:進入配置目錄,瀏覽文件
[root@Management down]# cd /usr/local/amoeba/
[root@Management amoeba]# ll
total 88
drwxr-xr-x 2 root root 4096 Jul 26 11:57 benchmark
drwxr-xr-x 2 root root 4096 Feb 28 09:25 bin
-rw-r--r-- 1 root root 3983 May 18 13:43 changelogs.txt
drwxr-xr-x 2 root root 4096 Jul 26 11:57 conf
drwxr-xr-x 3 root root 4096 Jul 26 11:57 lib
-rw-r--r-- 1 root root 34520 May 18 13:43 LICENSE.txt
-rw-r--r-- 1 root root 2031 May 18 13:43 README.html
3:進入主配置文件目錄
[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
在這里我主要介紹配置 amoeba.xml、 dbServers.xml、 log4j.xml 三個主要的配置文件,其它文件沒有特殊需要默認就可以了奪
4:vi amoeba.xml 修改主配置文件
4.1)把默認端口8066改成3306
<property name="port">3066</property>
4.2)把默認連接用戶名和密碼改成自己的
<property name="user">sky</property>
<property name="password">123456</property>
4.3)把默認的客戶端線程數,請求數及服務端回應數改成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)把默認注釋掉的讀寫分離選項,把注釋去掉并readpool修改成server2
<!--
-->
<property name="writePool">server1</property>
<property name="readPool">server2</property>
5:vi dbServers.xml 增加SEVER2模塊,里面的連接用戶名密碼及地址都表示兩臺MYSQL的物理機器,192.168.1.11和192.168.1.13 另SERVER1是寫,SERVER是讀
需要手動增加SERVER2代碼如下:
<dbServer name="abstractServer" abstractive="true">
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">${defaultManager}</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>
最終改變成如下:
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE amoeba:dbServers SYSTEM "dbserver.dtd">
<amoeba:dbServers xmlns:amoeba="">
<!--
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 'multiPool' dbServer
-->
<dbServer name="abstractServer" abstractive="true">
<factoryConfig class="com.meidusa.amoeba..net.MysqlServerConnectionFactory">
<property name="manager">${defaultManager}</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>
<!-- ########################把如上的內容復制到下面,來增加SERVER2############################ -->
<dbServer name="abstractServer" abstractive="true">
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">${defaultManager}</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:修改log4j.xml 取消日志文件生成(太大了,磁盤很容易滿)
<param name="file" value="${amoeba.home}/logs/project.log"/>
改成
<param name="file" value="<![CDATA[${amoeba.home}/logs/project.log>/dev/null]]>"/>
7:性能優(yōu)化,打開bin/amoeba
DEFAULT_OPTS="-server -Xms256m -Xmx256m -Xss128k"
改成
DEFAULT_OPTS="-server -Xms512m -Xmx512m -Xmn100m -Xss1204k"
8:啟動amoeba
nohup /usr/local/amoeba/bin/amoeba start 2>&1 >/dev/null &
看完了這篇文章,相信你對“Amoeba新版本MYSQL讀寫分離如何配置”有了一定的了解,如果想了解更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
網站名稱:Amoeba新版本MYSQL讀寫分離如何配置-創(chuàng)新互聯(lián)
網頁地址:http://jinyejixie.com/article46/pichg.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供標簽優(yōu)化、軟件開發(fā)、外貿網站建設、外貿建站、商城網站、網站收錄
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)