日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Amoeba

發布時間:2023/12/18 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Amoeba 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.介紹

Amoeba是mysql代理,增強mysql。類似的產品還有MyCat (mysql代理)

2.資源:點擊打開鏈接c82k

3.準備:amoeba是基于java的所以必須有jdk

4.上傳amoeba

5.解壓tar包

6.配置文件


amoeba配置文件兩個

dbServers.xml? 多個數據源,多個數據庫

amoeba.xml 啟動參數,誰負責讀,誰負責寫,誰負責負載均衡

##################################dbServers.xml-start######################################

<?xml version="1.0"encoding="gbk"?>

?

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

<amoeba:dbServersxmlns:amoeba="http://amoeba.meidusa.com/">

?

??? ??? <!--

?????????? EachdbServer needs to be configured into a Pool,

?????????? Ifyou need to configure multiple dbServer with load balancing that can besimplified by the following configuration:

?????????? ?add attribute with name virtual ="true" in dbServer, but the configuration does not allow the elementwith name factoryConfig

?????????? ?such as 'multiPool' dbServer??

?????? -->

??????

??? <dbServername="abstractServer" abstractive="true"><--建立抽象server動態代理-->

?????? <factoryConfigclass="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">

?????????? <propertyname="manager">${defaultManager}</property>

?????????? <propertyname="sendBufferSize">64</property>

?????????? <propertyname="receiveBufferSize">128</property>

?????????????

?????????? <!--mysql port ,所有的主從復制的數據庫的用戶名和密碼都要用一套-->

?????????? <propertyname="port">3306</property>

??????????

?????????? <!--mysql schema默認的要去檢查schema,一般是test的數據庫默認不變 -->

?????????? <propertyname="schema">test</property>

??????????

?????????? <!--mysql user,用戶名默認都是root -->

?????????? <propertyname="user">root</property>

??????????

?????????? <!--? mysql password ,密碼是root-->

?????????? <propertyname="password">root</property>

??????????

?????? </factoryConfig>

?

?????? <poolConfigclass="com.meidusa.amoeba.net.poolable.PoolableObjectPool">

?????????? <propertyname="maxActive">500</property>

?????????? <propertyname="maxIdle">500</property>

?????????? <propertyname="minIdle">10</property>

?????????? <propertyname="minEvictableIdleTimeMillis">600000</property>

??? ?????? <propertyname="timeBetweenEvictionRunsMillis">600000</property>

?????????? <propertyname="testOnBorrow">true</property>

?????????? <propertyname="testOnReturn">true</property>

?????????? <propertyname="testWhileIdle">true</property>

?????? </poolConfig>

??? </dbServer>

?

??? <dbServername="master"? parent="abstractServer"><-默認繼承了上面的abstractServer,所以是公用一套上面的配置--->

?????? <factoryConfig>

?????????? <!--mysql ip 主的ip地址-->

?????????? <propertyname="ipAddress">192.168.170.43</property>

?????? </factoryConfig>

??? </dbServer>

???

??? <dbServername="slave"? parent="abstractServer">

?????? <factoryConfig>

?????????? <!--mysql ip -->

?????????? <propertyname="ipAddress">192.168.170.85</property>

?????? </factoryConfig>

??? </dbServer>

???

??? <dbServername="multiPool" virtual="true"><--多個池-->

?????? <poolConfigclass="com.meidusa.amoeba.server.MultipleServerPool">

?????????? <!--Load balancing strategy(負載均衡算法): 1=ROUNDROBIN輪詢 , 2=WEIGHTBASED權重 , 3=HA高可用-->

?????????? <propertyname="loadbalance">1</property>

??????????

?????????? <!--Separated by commas,such as: server1,server2,server1配置那個數據庫是負責讀數據的 -->

?????????? <propertyname="poolNames">master,slave</property>

?????? </poolConfig>

??? </dbServer>

??????

</amoeba:dbServers>

##################################dbServers.xml-end######################################

##################################amoeba.xml-end######################################

<?xml version="1.0"encoding="gbk"?>

?

<!DOCTYPE amoeba:configuration SYSTEM"amoeba.dtd">

<amoeba:configurationxmlns:amoeba="http://amoeba.meidusa.com/">

?

??? <proxy>

???

?????? <!--service class must implements com.meidusa.amoeba.service.Service -->

?????? <servicename="Amoeba for Mysql"class="com.meidusa.amoeba.net.ServerableConnectionManager">

?????????? <!--port ,amoeba的端口-->

?????????? <propertyname="port">8066</property>

??????????

?????????? <!--bind ipAddress ,綁定地址,誰可以訪問amoeba,如果要讓所有的主機都可以訪問,就不需要設置-->

?????????? <!--

?????????? <propertyname="ipAddress">127.0.0.1</property>

?????????? ?-->

??????????

?????????? <propertyname="manager">${clientConnectioneManager}</property>

??????????

?????????? <propertyname="connectionFactory">

????????????? <beanclass="com.meidusa.amoeba.mysql.net.MysqlClientConnectionFactory">

????????????????? <propertyname="sendBufferSize">128</property>

????????????????? <propertyname="receiveBufferSize">64</property>

????????????? </bean>

?????????? </property>

??????????

?????????? <propertyname="authenticator">

????????????? <beanclass="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator">

?????????????????

????????????????? <propertyname="user">root</property><-訪問amoeba的用戶名和密碼--->

?????????????????

????????????????? <propertyname="password">root</property>

?????????????????

????????????????? <propertyname="filter">

???????????????????? <beanclass="com.meidusa.amoeba.server.IPAccessController">

???????????????????????? <propertyname="ipFile">${amoeba.home}/conf/access_list.conf</property>

???????????????????? </bean>

????????????????? </property>

????????????? </bean>

?????????? </property>

??????????

?????? </service>

??????

?????? <!--server class must implements com.meidusa.amoeba.service.Service 阿米巴監控的,不需要監控默認不修改-->

?????? <servicename="Amoeba Monitor Server"class="com.meidusa.amoeba.monitor.MonitorServer">

?????????? <!--port -->

?????????? <!--? default value: random number

?????????? <propertyname="port">9066</property>

?????????? -->

?????????? <!--bind ipAddress -->

?????????? <propertyname="ipAddress">127.0.0.1</property>

?????????? <propertyname="daemon">true</property>

?????????? <propertyname="manager">${clientConnectioneManager}</property>

?????????? <propertyname="connectionFactory">

????????????? <beanclass="com.meidusa.amoeba.monitor.net.MonitorClientConnectionFactory"></bean>

?????????? </property>

??????????

?????? </service>

??????

?????? <runtimeclass="com.meidusa.amoeba.mysql.context.MysqlRuntimeContext">

?????????? <!--proxy server net IO Read thread size這些事實時運行的配置,默認不用改 -->

?????????? <propertyname="readThreadPoolSize">20</property>

??????????

?????????? <!--proxy server client process thread size -->

?????????? <propertyname="clientSideThreadPoolSize">30</property>

??????????

?????????? <!--mysql server data packet process thread size -->

?????????? <propertyname="serverSideThreadPoolSize">30</property>

??????????

?????????? <!--per connection cache prepared statement size?-->

?????????? <propertyname="statementCacheSize">500</property>

??????????

?????????? <!--query timeout( default: 60 second , TimeUnit:second) -->

?????????? <propertyname="queryTimeout">60</property>

?????? </runtime>

??????

??? </proxy>

???

??? <!--

?????? EachConnectionManager will start as thread

?????? managerresponsible for the Connection IO read , Death Detection

??? -->

??? <connectionManagerList>

?????? <connectionManagername="clientConnectioneManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">

?????????? <propertyname="subManagerClassName">com.meidusa.amoeba.net.ConnectionManager</property>

?????????? <!--

?????????? ? default value is avaliable Processors

?????????? <propertyname="processors">5</property>

?????????? ?-->

?????? </connectionManager>

?????? <connectionManagername="defaultManager"class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">

?????????? <propertyname="subManagerClassName">com.meidusa.amoeba.net.AuthingableConnectionManager</property>

??????????

?????????? <!--

?????????? ? default value is avaliable Processors

?????????? <propertyname="processors">5</property>

?????????? ?-->

?????? </connectionManager>

??? </connectionManagerList>

???

?????? <!--default using file loader 指定剛剛配置過的dbServer.xml文件,將配置文件讀入-->

??? <dbServerLoaderclass="com.meidusa.amoeba.context.DBServerConfigFileLoader">

?????? <propertyname="configFile">${amoeba.home}/conf/dbServers.xml</property>

??? </dbServerLoader>

???

??? <queryRouterclass="com.meidusa.amoeba.mysql.parser.MysqlQueryRouter">

?????? <propertyname="ruleLoader">

?????????? <beanclass="com.meidusa.amoeba.route.TableRuleFileLoader">

????????????? <propertyname="ruleFile">${amoeba.home}/conf/rule.xml</property>

????????????? <propertyname="functionFile">${amoeba.home}/conf/ruleFunctionMap.xml</property>

?????????? </bean>

?????? </property>

?????? <propertyname="sqlFunctionFile">${amoeba.home}/conf/functionMap.xml</property>

?????? <propertyname="LRUMapSize">1500</property>

?????? <propertyname="defaultPool">master</property><--默認池只有master能寫,所以要配主-->

??????

?

?????? <propertyname="writePool">master</property><--master能寫,所以要配主-->

?????? <propertyname="readPool">multiPool</property><--dbServer.xml中配置過能寫的數據庫,把他的屬性寫過來-->

?

?????? <propertyname="needParse">true</property>

??? </queryRouter>

</amoeba:configuration>


##################################amoeba.xml-end######################################

7.?打開8066端口

/sbin/iptables -I INPUT -p tcp --dport 8066 -j ACCEPT

/etc/rc.d/init.d/iptables save????? #修改生效

/etc/init.d/iptables status???????? #查看配置

8.啟動和關閉amoeba

啟動:./bin/amoeba start 或 ./bin/amoeba start &


關閉:

./bin/amoeba stop


9.啟動報錯


是因為jdk默認(128k)的棧太小了,而根據上述報錯,棧需要228k才行

默認配置Xss比較小128k,啟動時提示太小,則修改/amoeba/bin/amoeba文件,修改為256k即可。

DEFAULT_OPTS="-server -Xms256m-Xmx256m -Xss256k"

再次啟動,ok


檢查是否啟動成功


10.使用第三方軟件鏈接amoeba


使用主從復制的bug來檢查是鏈接到了主還是從,將主數據庫和從數據庫中各添加一條獨特的數據

11.如果鏈接上amoeba后發現查不出數據


根據狀態可知主從配置失敗了,需要從新配置


從錯誤可知,主鍵重了,重新配置

1)將從停了

2)到主上查看位置pos


重新執行掛接命令


啟動從服務


驗證


然后根據那個bug來看,經過amoeba鏈接的是從還是主


上圖鏈接的是主

修改的話修改的是主數據庫


總結

以上是生活随笔為你收集整理的Amoeba的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。