数据编排与治理

注册中心

相对于配置中心管理配置数据,注册中心存放运行时的动态/临时状态数据,比如可用的proxy的实例,需要禁用或熔断的datasource实例。
通过注册中心,可以提供熔断数据库访问程序对数据库的访问和禁用从库的访问的编排治理能力。
在这里插入图片描述

state/instances

数据库访问对象运行实例信息,子节点是当前运行实例的标识。 运行实例标识由运行服务器的IP地址和PID构成。运行实例标识均为临时节点,当实例上线时注册,下线时自动清理。 注册中心监控这些节点的变化来治理运行中实例对数据库的访问等。

state/datasources

可以治理读写分离从库,可动态添加删除以及禁用。

配置中心

越来越多的运行时实例,使得散落的配置难于管理,配置不同步导致的问题十分严重。将配置集中于配置中心,可以更加有效进行管理。
配置中心在config下存储,存储的信息包括数据源,数据分片,读写分离、ConfigMap及Properties配置。可通过修改节点来实现对于配置的动态管理,也就是说在注册中心上修改、删除、新增相关配置,会动态推送到生产环境并立即生效。
在这里插入图片描述

如何使用

pom.xml

<!-- 数据编排治理 -->
<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>
    <version>${shardingsphere.version}</version>
</dependency>
<!-- 使用Zookeeper作为编排治理组件 -->
<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-orchestration-center-zookeeper-curator</artifactId>
    <version>${shardingsphere.version}</version>
</dependency>
<!-- 使用Nacos作为编排治理组件 -->
<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-orchestration-center-nacos</artifactId>
    <version>${shardingsphere.version}</version>
</dependency>

application.properties

# 治理实例名称
# config_center代表配置中心
# registry_center代表注册中心
# metadata_center代表元数据中心
spring.shardingsphere.orchestration.demo_ds_sharding.orchestration-type=config_center,registry_center
# 配置中心类型
spring.shardingsphere.orchestration.demo_ds_sharding.instance-type=zookeeper
# 连接注册中心服务器的列表,以Zookeeper做配置和注册中心
spring.shardingsphere.orchestration.demo_ds_sharding.server-lists=192.168.56.105:2181
# 注册中心的命名空间
spring.shardingsphere.orchestration.demo_ds_sharding.namespace=sharding-jdbc-config
# 本地配置是否覆盖注册中心配置。如果可覆盖,每次启动都以本地配置为准
spring.shardingsphere.orchestration.demo_ds_sharding.props.overwrite=true
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值