mode (?): # 不配置则默认单机模式
type: # 运行模式类型。可选配置:Standalone、Cluster
repository (?): # 持久化仓库配置
mode:
type: Standalone
repository:
type: # 持久化仓库类型
props: # 持久化仓库所需属性
foo_key: foo_value
bar_key: bar_value
mode:
type: Cluster
repository:
type: # 持久化仓库类型
props: # 持久化仓库所需属性
namespace: # 注册中心命名空间
server-lists: # 注册中心连接地址
foo_key: foo_value
bar_key: bar_value
ZooKeeper
注册中心。ZooKeeper
存在配置信息时,则以 ZooKeeper
中的配置为准。mode:
type: Standalone
repository:
type: JDBC
mode:
type: Cluster
repository:
type: ZooKeeper
props:
namespace: governance
server-lists: localhost:2181
retryIntervalMilliseconds: 500
timeToLiveSeconds: 60
使用持久化仓库需要额外引入对应的 Maven 依赖,推荐使用:
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-cluster-mode-repository-zookeeper</artifactId>
<version>${shardingsphere.version}</version>
</dependency>