-
root@proxy:~# java -version
-
java version "1.6.0_45"
-
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
- Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
-
root@proxy:/usr/local/amoeba/conf# cat dbServers.xml
-
<?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 'multiPool' dbServer
-
-->
-
-
<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">111</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="testOnReturn">true</property>
-
<property name="testWhileIdle">true</property>
-
</poolConfig>
-
</dbServer>
-
-
<dbServer name="master1" parent="abstractServer">
-
<factoryConfig>
-
<!-- mysql ip -->
-
<property name="ipAddress">10.10.10.40</property>
-
</factoryConfig>
-
</dbServer>
-
-
<dbServer name="master2" parent="abstractServer">
-
<factoryConfig>
-
<!-- mysql ip -->
-
<property name="ipAddress">10.10.10.50</property>
-
</factoryConfig>
-
</dbServer>
-
-
<dbServer name="slave1" parent="abstractServer">
-
<factoryConfig>
-
<!-- mysql ip -->
-
<property name="ipAddress">10.10.10.41</property>
-
</factoryConfig>
-
</dbServer>
-
-
<dbServer name="slave2" parent="abstractServer">
-
<factoryConfig>
-
<!-- mysql ip -->
-
<property name="ipAddress">10.10.10.42</property>
-
</factoryConfig>
-
</dbServer>
-
####rp池配置的是salve1和slave2节点
-
<dbServer name="rp" 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">slave1,slave2</property>
-
</poolConfig>
-
</dbServer>
-
####wp池配置的是master1和master2节点
-
<dbServer name="wp" 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">master1,master2</property>
-
</poolConfig>
-
</dbServer>
-
- </amoeba:dbServers>
-
root@proxy:/usr/local/amoeba/conf# cat amoeba.xml
-
<?xml version="1.0" encoding="gbk"?>
-
-
<!DOCTYPE amoeba:configuration SYSTEM "amoeba.dtd">
-
<amoeba:configuration xmlns:amoeba="http://amoeba.meidusa.com/">
-
-
<proxy>
-
-
<!-- service class must implements com.meidusa.amoeba.service.Service -->
-
<service name="Amoeba for Mysql" class="com.meidusa.amoeba.net.ServerableConnectionManager">
-
<!-- port -->
-
<property name="port">8066</property>
-
-
<!-- bind ipAddress -->
-
<!--
-
<property name="ipAddress">127.0.0.1</property>
-
-->
-
-
<property name="manager">${clientConnectioneManager}</property>
-
-
<property name="connectionFactory">
-
<bean class="com.meidusa.amoeba.mysql.net.MysqlClientConnectionFactory">
-
<property name="sendBufferSize">128</property>
-
<property name="receiveBufferSize">64</property>
-
</bean>
-
</property>
-
-
<property name="authenticator">
-
<bean class="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator">
-
-
<property name="user">root</property>
-
-
<property name="password">root</property>
-
-
<property name="filter">
-
<bean class="com.meidusa.amoeba.server.IPAccessController">
-
<property name="ipFile">${amoeba.home}/conf/access_list.conf</property>
-
</bean>
-
</property>
-
</bean>
-
</property>
-
-
</service>
-
-
<!-- server class must implements com.meidusa.amoeba.service.Service -->
-
<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">127.0.0.1</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>
-
-
<runtime class="com.meidusa.amoeba.mysql.context.MysqlRuntimeContext">
-
<!-- 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>
-
-
<!-- per connection cache prepared statement size -->
-
<property name="statementCacheSize">500</property>
-
-
<!-- query timeout( default: 60 second , TimeUnit:second) -->
-
<property name="queryTimeout">60</property>
-
</runtime>
-
-
</proxy>
-
-
<!--
-
Each ConnectionManager will start as thread
-
manager responsible for the Connection IO read , Death Detection
-
-->
-
<connectionManagerList>
-
<connectionManager name="clientConnectioneManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">
-
<property name="subManagerClassName">com.meidusa.amoeba.net.ConnectionManager</property>
-
<!--
-
default value is avaliable Processors
-
<property name="processors">5</property>
-
-->
-
</connectionManager>
-
<connectionManager name="defaultManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">
-
<property name="subManagerClassName">com.meidusa.amoeba.net.AuthingableConnectionManager</property>
-
-
<!--
-
default value is avaliable Processors
-
<property name="processors">5</property>
-
-->
-
</connectionManager>
-
</connectionManagerList>
-
-
<!-- default using file loader -->
-
<dbServerLoader class="com.meidusa.amoeba.context.DBServerConfigFileLoader">
-
<property name="configFile">${amoeba.home}/conf/dbServers.xml</property>
-
</dbServerLoader>
-
-
<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>
-
####default池只配置了master1节点
-
<property name="sqlFunctionFile">${amoeba.home}/conf/functionMap.xml</property>
-
<property name="LRUMapSize">1500</property>
- <property name="defaultPool">master1</property>
-
-
<property name="writePool">wp</property>
-
<property name="readPool">rp</property>
-
-
<property name="needParse">true</property>
-
</queryRouter>
- </amoeba:configuration>
-
root@proxy:/usr/local/amoeba# bin/amoeba start &
-
[1] 2511
-
root@proxy:/usr/local/amoeba#
-
The stack size specified is too small, Specify at least 160k
-
Could not create the Java virtual machine.
-
- [1]+ Exit 1 bin/amoeba start
-
DEFAULT_OPTS="-server -Xms256m -Xmx256m -Xss128k"
-
更改为
- DEFAULT_OPTS="-server -Xms256m -Xmx256m -Xss256k"
-
root@proxy:~# mysql -uroot -p -h10.10.10.39 -P8066
-
Enter password:
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 307988519
-
Server version: 5.1.45-mysql-amoeba-proxy-2.2.0
-
-
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
-
-
Oracle is a registered trademark of Oracle Corporation and/or its
-
affiliates. Other names may be trademarks of their respective
-
owners.
-
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
-
java.util.NoSuchElementException: Could not create a validated object, cause: ValidateObject failed
-
[root@10.10.10.39:(none)][11:46:57pm] MySQL-> at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1191)
-
at com.meidusa.amoeba.net.poolable.GenericObjectPool.borrowObject(GenericObjectPool.java:381)
-
at com.meidusa.amoeba.mysql.handler.CommandMessageHandler.startSession(CommandMessageHandler.java:633)
-
at com.meidusa.amoeba.mysql.handler.MySqlCommandDispatcher.handleMessage(MySqlCommandDispatcher.java:123)
-
at com.meidusa.amoeba.mysql.net.MysqlClientConnection$2.run(MysqlClientConnection.java:291)
-
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
-
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
- at java.lang.Thread.run(Thread.java:662)
-
2015-08-29 16:01:03,299 INFO net.BackendConnectionFactory - open socket channel to server[10.10.10.40:3306]
-
2015-08-29 16:01:03,303 ERROR net.MysqlServerConnection - handShake with /10.10.10.40:3306 error:Access denied for user 'root'@'10.10.10.39' (using password: NO),hashCode=661272757
-
2015-08-29 16:01:03,324 INFO net.BackendConnectionFactory - open socket channel to server[10.10.10.50:3306]
-
2015-08-29 16:01:03,327 ERROR net.MysqlServerConnection - handShake with /10.10.10.50:3306 error:Access denied for user 'root'@'10.10.10.39' (using password: NO),hashCode=505588567
-
2015-08-29 16:01:03,331 INFO net.BackendConnectionFactory - open socket channel to server[10.10.10.41:3306]
-
2015-08-29 16:01:03,334 ERROR net.MysqlServerConnection - handShake with /10.10.10.41:3306 error:Access denied for user 'root'@'10.10.10.39' (using password: NO),hashCode=530654357
-
2015-08-29 16:01:03,335 INFO net.BackendConnectionFactory - open socket channel to server[10.10.10.42:3306]
- 2015-08-29 16:01:03,338 ERROR net.MysqlServerConnection - handShake with /10.10.10.42:3306 error:Access denied for user 'root'@'10.10.10.39' (using password: NO),hashCode=848649429
-
[root@localhost:mysql][11:55:29pm] MySQL-> select host,user from user;
-
+-----------+----------+
-
| host | user |
-
+-----------+----------+
-
| % | rep_user |
-
| % | root |
-
| 127.0.0.1 | root |
-
| ::1 | root |
-
| localhost | |
-
| localhost | root |
-
| ubuntu | |
-
| ubuntu | root |
-
+-----------+----------+
- 8 rows in set (0.00 sec)
-
root@proxy:~# mysql -uroot -p -h10.10.10.40
-
Enter password:
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 417
-
Server version: 5.6.19-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
-
-
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
-
-
Oracle is a registered trademark of Oracle Corporation and/or its
-
affiliates. Other names may be trademarks of their respective
-
owners.
-
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
-
[root@10.10.10.40:(none)][11:59:09pm] MySQL-> use test;
-
Reading table information for completion of table and column names
-
You can turn off this feature to get a quicker startup with -A
-
-
Database changed
-
[root@10.10.10.40:test][11:59:12pm] MySQL-> show tables;
-
+----------------+
-
| Tables_in_test |
-
+----------------+
-
| t1 |
-
+----------------+
- 1 row in set (0.00 sec)
-
<!-- mysql password
-
<property name="password">111</property>
-
-->
-
<!-- mysql password -->
- <property name="password">111</property>
-
root@proxy:~# mysql -uroot -p -h10.10.10.39 -P8066
-
Enter password:
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 1113757163
-
Server version: 5.1.45-mysql-amoeba-proxy-2.2.0 MySQL Enterprise Server - Advanced Edition (Commercial)
-
-
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
-
-
Oracle is a registered trademark of Oracle Corporation and/or its
-
affiliates. Other names may be trademarks of their respective
-
owners.
-
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
-
[root@10.10.10.39:(none)][12:06:15am] MySQL-> use test;
-
Database changed
-
[root@10.10.10.39:test][12:06:18am] MySQL->
-
[root@10.10.10.39:test][12:06:18am] MySQL-> show tables;
-
+----------------+
-
| Tables_in_test |
-
+----------------+
-
| t1 |
-
+----------------+
- 1 row in set (0.00 sec)
停止master2,slave1,slave2节点的复制
-
[root@localhost:(none)][12:27:38am] MySQL-> stop slave;
-
Query OK, 0 rows affected (0.04 sec)
-
-
[root@localhost:(none)][12:27:53am] MySQL-> show slave status \G
-
*************************** 1. row ***************************
-
Slave_IO_State:
-
Master_Host: 10.10.10.40
-
Master_User: rep_user
-
Master_Port: 3306
-
Connect_Retry: 60
-
Master_Log_File: master1-bin.000007
-
Read_Master_Log_Pos: 442
-
Relay_Log_File: slave-relay-bin.000008
-
Relay_Log_Pos: 607
-
Relay_Master_Log_File: master1-bin.000007
-
Slave_IO_Running: No
- Slave_SQL_Running: No
-
root@proxy:~# mysql -uroot -p -h10.10.10.39 -P8066
-
Enter password:
-
Welcome to the MySQL monitor. Commands end with ; or \g.
-
Your MySQL connection id is 750410715
-
Server version: 5.1.45-mysql-amoeba-proxy-2.2.0 MySQL Enterprise Server - Advanced Edition (Commercial)
-
-
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
-
-
Oracle is a registered trademark of Oracle Corporation and/or its
-
affiliates. Other names may be trademarks of their respective
-
owners.
-
-
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
-
[root@10.10.10.39:(none)][12:25:49am] MySQL-> use test;
-
Database changed
-
[root@10.10.10.39:test][12:26:51am] MySQL-> insert into t1 values (null,'aaaaa');
- Query OK, 1 row affected (0.05 sec)
-
[root@localhost:mysql][11:27:16pm] MySQL-> select * from test.t1;
-
+----+-------+
-
| id | name |
-
+----+-------+
-
| 1 | aaaaa |
-
+----+-------+
- 1 row in set (0.00 sec)
-
[root@localhost:(none)][12:28:28am] MySQL-> use test;
-
Reading table information for completion of table and column names
-
You can turn off this feature to get a quicker startup with -A
-
-
Database changed
-
[root@localhost:test][12:29:17am] MySQL-> select * from t1;
- Empty set (0.00 sec)
-
[root@10.10.10.39:test][12:30:01am] MySQL-> select * from t1;
- Empty set (0.05 sec)