Quick Guide to Enabling Read‑Write Splitting in Dble (v3.20.10+)
This article explains how to configure Dble's read‑write splitting feature by preparing MySQL master‑slave instances, defining dbGroup and rwSplitUser in XML configuration files, reloading the settings, and verifying that write statements go to the primary node while reads are load‑balanced across replicas.
Dble version 3.20.10 and later supports a pure read‑write splitting mode that can be used independently of its sharding features.
Step 1: Prepare MySQL Instances
Set up a MySQL master (e.g., 172.100.9.6:3307) and two slaves (e.g., 172.100.9.2:3307 and 172.100.9.3:3307) and ensure replication is working by running show slave status on each slave.
Step 2: Configure dbGroup in db.xml
Add a dbGroup definition that lists the master and slave instances. Example configuration:
<dbGroup rwSplitMode="1" name="ha_group1" delayThreshold="100">
<heartbeat>show slave status</heartbeat>
<dbInstance name="hostM1" password="******" url="172.100.9.6:3307" user="test" maxCon="1000" minCon="10" primary="true"/>
<dbInstance name="hostS1" password="******" url="172.100.9.2:3307" user="test" maxCon="1000" minCon="10" readWeight="1"/>
<dbInstance name="hostS2" password="******" url="172.100.9.3:3307" user="test" maxCon="1000" minCon="10" readWeight="1"/>
</dbGroup>Key parameters:
rwSplitMode : 0‑3 determines how read traffic is balanced among slaves and whether fallback to the master occurs.
delayThreshold : Seconds of allowed master‑slave lag; -1 disables lag checking.
readWeight : Integer weight for each slave; 0 excludes the node from reads.
Primary (write) node is identified with primary="true" ; read nodes omit this attribute or set it to false.
Step 3: Add a Read‑Write Splitting User in user.xml
<rwSplitUser name="rwSplit1" password="111111" dbGroup="ha_group1" />This user is linked to the dbGroup defined above.
Step 4: Apply the Configuration
Execute reload @@config_all on the Dble admin console. The new user rwSplit1 can now connect to Dble on port 8066.
Verification
Enable general logs on all three MySQL instances ( set global general_log = on ), then connect with rwSplit1 and run an INSERT followed by a SELECT . The INSERT should appear in the master’s log, while the SELECT should be logged on one of the slaves, confirming proper read‑write splitting.
Additional Notes
If both read‑write splitting and sharding are enabled, their dbGroup definitions must be independent.
Multiple rwSplitUser entries can reference the same dbGroup .
For details on which SQL statements are routed to master or slaves, refer to the Dble discussion thread linked in the original article.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
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.