Tistepin opened a new issue, #37845:
URL: https://github.com/apache/shardingsphere/issues/37845
## Bug Report
### Which version of ShardingSphere did you use?
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc</artifactId>
<version>5.5.1</version>
</dependency>
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
### Expected behavior
ShardingSphere-JDBC
### Actual behavior
The project has been successfully launched
### Reason analyze (If you can)
The project has been Error launched
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
Add Master Oracle configuration
# 支持遊標的數據庫性能提升,開啟PSCache
spring.datasource.druid.oracle.pool-prepared-statements=true
# 設置PSCache值
spring.datasource.druid.oracle.max-pool-prepared-statement-per-connection-size=20
As long as the Master does not set this configuration, it can start
successfully.
Add this configuration to the slave database is ok
What is the problem
this is my config file
@Primary
@Bean("ShardingSphereDataSource")
public DataSource ShardingSphereDataSource(@Autowired
@Qualifier("shardingDataSources") Map<String, DataSource> shardingDataSources,
@Value("${spring.shardingsphere.logicName}") String logicName,
@Value("${spring.shardingsphere.loadBalancerName}") String loadBalancerName
) throws SQLException {
ModeConfiguration modeConfig =new ModeConfiguration("Standalone",
new StandalonePersistRepositoryConfiguration("JDBC", new Properties()));
// 配置 ShardingSphere 的读写分离数据源
// 直接使用已配置好的 Druid 数据源
ReadwriteSplittingDataSourceGroupRuleConfiguration dataSourceConfig =
new ReadwriteSplittingDataSourceGroupRuleConfiguration(
logicName, // 逻辑数据源名
"oracle",
Arrays.asList("oracle-read"),
loadBalancerName
);
// 负载均衡配置 type=ROUND_ROBIN 轮询
Map<String, AlgorithmConfiguration> loadBalanceMap = new HashMap<>();
loadBalanceMap.put(loadBalancerName, new
AlgorithmConfiguration("ROUND_ROBIN", new Properties()));
// 规则集合
ArrayList<RuleConfiguration> ruleConfigurations = new ArrayList<>();
// 读写分离规则
ReadwriteSplittingRuleConfiguration ruleConfig =
new ReadwriteSplittingRuleConfiguration(
Collections.singleton(dataSourceConfig),
loadBalanceMap
);
ruleConfigurations.add(ruleConfig);
//设置单表扫描,如果不带这个配置,项目里访问单表的时候会报错找不到数据表
//https://shardingsphere.apache.org/document/current/cn/faq/
//[单表] Table or view %s does not exist. 异常如何解决?
SingleRuleConfiguration ruleConfigSingleRuleConfiguration = new
SingleRuleConfiguration();
ruleConfigSingleRuleConfiguration.setDefaultDataSource(logicName);
HashSet<String> singleTable = new HashSet<>();
singleTable.add("*.*");
ruleConfigSingleRuleConfiguration.setTables(singleTable);
ruleConfigurations.add(ruleConfigSingleRuleConfiguration);
// 关键属性配置
Properties props = new Properties();
props.setProperty("sql-show", "true");
props.setProperty("metadata-loading-enabled", "false"); //
ShardingSphere 5.3+ 支持
props.setProperty("check-table-metadata-enabled", "false");
log.info("✅ 使用 oracle + oracle-read 数据源构建 ShardingSphere 读写分离");
return
ShardingSphereDataSourceFactory.createDataSource(modeConfig,shardingDataSources,
ruleConfigurations, props);
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]