使用cluster模式启动proxy,第二次启动的时候会报这个错误。
[INFO ] 2023-10-31 10:56:06.474 [main-EventThread] o.a.c.f.state.ConnectionStateManager - State change: CONNECTED
Exception in thread "main" org.apache.shardingsphere.sharding.exception.metadata.MissingRequiredShardingAlgorithmException: `ts-c-assitem` algorithm does not exist in database `sharding_db`.
at org.apache.shardingsphere.sharding.checker.ShardingRuleConfigurationChecker.lambda$checkShardingStrategy$6(ShardingRuleConfigurationChecker.java:106)
at org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:41)
at org.apache.shardingsphere.sharding.checker.ShardingRuleConfigurationChecker.checkShardingStrategy(ShardingRuleConfigurationChecker.java:105)
at org.apache.shardingsphere.sharding.checker.ShardingRuleConfigurationChecker.checkTableConfiguration(ShardingRuleConfigurationChecker.java:65)
at org.apache.shardingsphere.sharding.checker.ShardingRuleConfigurationChecker.check(ShardingRuleConfigurationChecker.java:51)
at org.apache.shardingsphere.sharding.checker.ShardingRuleConfigurationChecker.check(ShardingRuleConfigurationChecker.java:44)
at org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.build(DatabaseRulesBuilder.java:63)
at org.apache.shardingsphere.metadata.factory.NewInternalMetaDataFactory.create(NewInternalMetaDataFactory.java:55)
at org.apache.shardingsphere.metadata.factory.NewInternalMetaDataFactory.createDatabases(NewInternalMetaDataFactory.java:80)
at org.apache.shardingsphere.metadata.factory.NewInternalMetaDataFactory.create(NewInternalMetaDataFactory.java:69)
at org.apache.shardingsphere.mode.metadata.NewMetaDataContextsFactory.create(NewMetaDataContextsFactory.java:95)
at org.apache.shardingsphere.mode.manager.cluster.NewClusterContextManagerBuilder.build(NewClusterContextManagerBuilder.java:59)
at org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.createContextManager(BootstrapInitializer.java:68)
at org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.init(BootstrapInitializer.java:58)
at org.apache.shardingsphere.proxy.Bootstrap.main(Bootstrap.java:55)
我翻了一下我的config-sharding.yml的配置文件,里面绝对有写`ts-c-assitem`这个分表的规则的,但是根据报错信息,说不存在该分表算法,这不科学?
我只得去翻github上的issue,还真有人遇到了类似的问题,也是第二次启动的时候报错,启动不了了。
原来在proxy的配置里,shardingAlgorithmName的值里,不能带"-",可以使用下划线"_"替代,so,我把“ts-c-assitem”改为了“ts_c_assitem”,尝试多次启动后,不再报错。
真是服了,如果真的不给用-,第一次启动的时候为什么不报出错误来,实际上我去zookeeper里的meta值里,是有看到“ts-c-assitem”的,记录一下,希望能帮到大家。