ShardingSphere-JDBC implemented using sub-library sub-table - for configuration center

In the previous article I described in detail how to use ShardingSphere-JDBC library sub-table is divided, but also to achieve a simple precise classification algorithm interface library, as detailed in the following link:

Using ShardingSphere-JDBC achieve sub-library sub-table

But look at the profile, I have only two tables in the case had to do with the 60-line configuration, if I'm in a real system, then the size of the configuration file will be very impressive, this time Configuration Center the role is very important. ShardingSphere mainstream support services such as zookeeper and etcd discovery component, as the most commonly used, I used zookeeper to achieve.

The following is the configuration on zookeeper part:

# 名字随便起一个
spring.shardingsphere.orchestration.name=spring_boot_ds_sharding
# 覆盖配置中心的配置,以本地为准
spring.shardingsphere.orchestration.overwrite=true
spring.shardingsphere.orchestration.registry.type=zookeeper
# 名字随便起一个,这是我们这个集群的名称,其他的集群可以用这个也可以用自己单独的,作为资源隔离
spring.shardingsphere.orchestration.registry.namespace=shardingsphere
spring.shardingsphere.orchestration.registry.server-lists=127.0.0.1:2181

After the service starts, it will be automatically uploaded to these configurations configured to distribution center, next only need to modify the configuration center can be.

It should be noted that the official document did not speak or understand gradle maven configuration, if you speak directly related to the starter into the configuration according to the document, will start being given, because the jar package conflicts caused me to give gradle configuration , maven can refer to Review:

compile('org.apache.shardingsphere:sharding-jdbc-orchestration-spring-boot-starter:4.0.0-RC2')
{
    exclude group: 'org.apache.curator', module: 'curator-framework'
}
compile('org.apache.shardingsphere:sharding-orchestration-reg-zookeeper-curator:4.0.0-RC2')
{
    exclude group: 'org.apache.curator', module: 'curator-framework'
    exclude group: 'org.apache.curator', module: 'curator-recipes'
    exclude group: 'org.apache.curator', module: 'curator-client'
}
compile group: 'org.apache.curator', name: 'curator-framework', version: '2.10.0'
compile group: 'org.apache.curator', name: 'curator-recipes', version: '2.10.0'

We can look up configuration information uploaded on zkCli:

Configuration Center

So far we have completed the configuration work center configuration. In the subsequent coverage, I will mention other content data desensitization, etc., if there is time, I also want to be able to in-depth look at the source code inside the component.

Guess you like

Origin www.cnblogs.com/wingsless/p/11432501.html