How to Configure Amoeba XML Files for MySQL Proxying
This guide explains the main Amoeba configuration files, provides step‑by‑step instructions to set up dbServers.xml and amoeba.xml for proxying a MySQL instance, and details the file structures, access controls, logging, and routing rules needed for successful deployment.
Main Configuration Files
amoeba.xml : Defines how clients connect to Amoeba and basic proxy settings.
dbServers.xml : Lists the databases that Amoeba proxies, including host IP, port, username, and password for each.
rule.xml : Contains sharding rules that tell Amoeba how to split data and merge results.
functionMap.xml : Maps database functions (e.g., UNIX_TIMESTAMP(), SYSDATE()) to Amoeba’s internal handling.
ruleFunctionMap.xml : Defines custom functions used in rule.xml, such as hashing user IDs for sharding.
access_list.conf : Specifies IP addresses that are allowed or denied access.
log4j.xml : Configures logging levels and output formats using Log4j syntax.
Configuration Example
Goal: Use Amoeba to proxy a MySQL instance and verify the proxy works from a client.
Edit $AMOEBA_HOME/conf/dbServers.xml:
Locate the node <dbServer name="abstractServer" abstractive="true">.
Replace port, schema, user, and password with the MySQL connection details.
Edit $AMOEBA_HOME/conf/amoeba.xml:
Find the property node under name="authenticateProvider" and set the user and password that clients will use to connect to Amoeba.
Test the connection:
Run: mysql -uroot -p111111 -h127.0.0.1 -P8066 (8066 is Amoeba’s default port).
Successful login shows a Server version like
5.1.45-mysql-amoeba-proxy-3.0.4-BETA MySQL Community Server (GPL), confirming the proxy.
Insert a test row, exit Amoeba, then connect directly to the real MySQL to verify the data.
Configuration File Structure
dbServers.xml
The file defines multiple <dbServer> nodes. The abstract node (e.g., <dbServer name="abstractServer">) holds common settings such as shared credentials and pool parameters. Concrete servers inherit from the abstract node:
<dbServer name="server1" parent="abstractServer">
<factoryConfig>
<property name="ipAddress">127.0.0.1</property>
</factoryConfig>
</dbServer>Virtual servers can group several physical MySQL instances for read‑only load balancing:
<dbServer name="multiPool" virtual="true">
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<property name="loadbalance">1</property> <!-- 1=ROUNDROBIN -->
<property name="poolNames">server1,server2</property>
</poolConfig>
</dbServer>amoeba.xml
Amoeba presents itself as a MySQL server, so a <server> node configures client connection details. The <dbServerLoader> node tells Amoeba where to load dbServers.xml, and the <queryRouter> node defines routing rules for read/write operations.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
