复古 护眼 海天 深邃 暗黑 默认

元数据持久化仓库

背景信息

Apache ShardingSphere 为不同的运行模式提供了不同的元数据持久化方式,用户在配置运行模式的同时可以选择合适的方式来存储元数据。

参数解释

文件持久化

类型:File

适用模式:Standalone

可配置属性:

名称 数据类型 说明 默认值
path String 元数据存储路径 .shardingsphere

ZooKeeper 持久化

类型:ZooKeeper

适用模式:Cluster

可配置属性:

名称 数据类型 说明 默认值
retryIntervalMilliseconds int 重试间隔毫秒数 500
maxRetries int 客户端连接最大重试次数 3
timeToLiveSeconds int 临时数据失效的秒数 60
operationTimeoutMilliseconds int 客户端操作超时的毫秒数 500
digest String 登录认证密码

Etcd 持久化

类型:Etcd

适用模式:Cluster

可配置属性:

名称 数据类型 说明 默认值
timeToLiveSeconds long 临时数据失效的秒数 30
connectionTimeout long 连接超时秒数 30

操作步骤

  1. 在 server.yaml 中配置 Mode 运行模式
  2. 配置元数据持久化仓库类型

配置示例

  • 单机模式配置方式
mode:
  type: Standalone
  repository:
    type: File
    props:
       path: ~/user/.shardingsphere
  overwrite: false
  • 集群模式
mode:
  type: Cluster
  repository:
    type: zookeeper
    props:
      namespace: governance_ds
      server-lists: localhost:2181
      retryIntervalMilliseconds: 500
      timeToLiveSeconds: 60
      maxRetries: 3
      operationTimeoutMilliseconds: 500
  overwrite: false