DBLE Rule.xml Configuration Guide and PatternRange Sharding Example
This article introduces the DBLE middleware project, lists its main configuration files, explains the purpose and structure of rule.xml, and provides a detailed PatternRange sharding example with code snippets, mapping files, and routing logic to help users configure database sharding effectively.
DBLE Project Introduction – The DBLE open‑source middleware can be explored at https://opensource.actionsky.com and its source code at https://github.com/actiontech/dble . Download releases from the GitHub releases page and join the community chat (ID: 669663113) for support.
Main Configuration Files
File
Description
server.xml
Defines DBLE server parameters such as performance, scheduled tasks, ports, and user settings; this article focuses on user access configuration.
schema.xml
Specifies table and schema definitions, dataNode relationships, and the sharding method for each table.
rule.xml
Contains the actual sharding algorithm configurations used by DBLE.
rule.xml Configuration Parsing – rule.xml is the most frequently used file when configuring sharding algorithms. A mind‑map is provided for a quick overview, but detailed semantics should be consulted in the official documentation.
rule.xml Example
Sharding can be classified into continuous and discrete types. Continuous sharding places a range of data on a single DataNode, while discrete sharding distributes data across nodes using hash or modulo methods.
Aspect
Continuous Sharding
Discrete Sharding
Advantages
Limited concurrency, low migration cost
Higher concurrency, better range‑query performance
Disadvantages
Potential data hotspots, limited concurrency
Complex data expansion, requires full redistribution
Examples
date, numberrange
hash, stringhash, patternrange
Note: If a hash or patternrange sharding interval is wide enough, it can behave like continuous sharding.
PatternRange Algorithm Example
Assume a table task_log with 10 million rows that needs to be split across three DataNodes (dn1, dn2, dn3) because single‑table queries are slow.
schema.xml entry :
<table name="task_log" dataNode="dn1,dn2,dn3" rule="three_node_range" />rule.xml entry :
<?xml version="1.0"?>
<!DOCTYPE dble:rule SYSTEM "rule.dtd">
<dble:rule xmlns:dble="http://dble.cloud/">
<tableRule name="three_node_range">
<rule>
<columns>id</columns>
<algorithm>three_node_range</algorithm>
</rule>
</tableRule>
<function name="three_node_range" class="PatternRange">
<property name="mapFile">partition.txt</property>
<property name="patternValue">1024</property>
<property name="defaultNode">0</property>
</function>
</dble:rule>The partition.txt map file defines the node assignment:
# cat partition.txt
0-255=0
256-511=1
512-1024=2During routing, the middleware computes M = id % patternValue. If M falls in 0‑255, the row goes to dn1; 256‑511 to dn2; 512‑1024 to dn3; otherwise it defaults to the node specified by defaultNode (dn1 in this example).
Summary – rule.xml defines the sharding algorithms actually used by DBLE. Understanding the various sharding configurations and their suitable scenarios enables users to select and configure appropriate rules, which is the first step when trying DBLE’s database‑sharding middleware.
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.
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.
