Configuring a shadow database
In this section, we will discuss how to use the rule configuration of a shadow database. When using Hint
algorithms, you also need to turn on the sqlCommentParseEnabled
SQL_PARSER
-related configuration item to true
.
Java configuration items
Here is the configuration item entry – org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration
:
As an example, let's create a data source with ShadowRule
using Java code:
public DataSource getDataSource() throws SQLException {
Map<String, DataSource> dataSourceMap = createDataSourceMap();
Collection<RuleConfiguration> ruleConfigurations = createRuleConfiguration();
return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, ruleConfigurations, properties);
}
YAML configuration items
If you are using YAML to configure your shadow database feature, you can...