Metadata Repository

Background

Apache ShardingSphere provides different metadata persistence methods for different running modes. Users can freely choose the most appropriate way to store metadata while configuring the running mode.

Parameters

Database Repository

Type: JDBC

Mode: Standalone

Attributes:

NameTypeDescriptionDefault Value
providerStringType for metadata persist, the optional value is H2, MySQLH2
jdbc_urlStringJDBC URLjdbc:h2:mem:config;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
usernameStringusernamesa
passwordStringpassword

ZooKeeper Repository

Type: ZooKeeper

Mode: Cluster

Attributes:

NameTypeDescriptionDefault Value
retryIntervalMillisecondsintMilliseconds of retry interval500
maxRetriesintMax retries of client connection3
timeToLiveSecondsintSeconds of ephemeral data live60
operationTimeoutMillisecondsintMilliseconds of operation timeout500
digestStringPassword of login

Etcd Repository

Type: Etcd

Mode: Cluster

Attributes:

NameTypeDescriptionDefault Value
timeToLiveSecondslongSeconds of ephemeral data live30
connectionTimeoutlongSeconds of connection timeout30

Consul Repository

Due to the limitation of the Maven module of com.ecwid.consul:consul-api:1.4.5, users cannot connect to the Consul Agent through the gRPC port.

The serverLists property of the Consul implementation is by design and can only be connected to a single Consul Agent via an HTTP endpoint. serverLists uses relaxed URL matching principles.

  1. When serverLists is empty, it will be resolved to the Consul Agent instance of http://127.0.0.1:8500.
  2. When serverLists is hostName, it will be resolved to the Consul Agent instance of http://hostName:8500.
  3. When serverLists is hostName:port, it will be resolved to the Consul Agent instance of http://hostName:port.
  4. When serverLists is http://hostName:port, it will be resolved to the Consul Agent instance of http://hostName:port.
  5. When serverLists is https://hostName:port, it will be resolved to the Consul Agent instance of https://hostName:port.

Type: Consul

Mode: Cluster

Attributes:

NameTypeDescriptionDefault Value
timeToLiveSecondsStringSeconds of ephemeral instance live30s
blockQueryTimeToSecondslongSeconds of query timeout60

Procedure

  1. Configure running mode in server.yaml.
  2. Configure metadata persistence warehouse type.

Sample

  • Standalone mode configuration method.
  1. mode:
  2. type: Standalone
  3. repository:
  4. type: JDBC
  5. props:
  6. provider: H2
  7. jdbc_url: jdbc:h2:mem:config;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
  8. username: test
  9. password: Test@123
  • Cluster mode.
  1. mode:
  2. type: Cluster
  3. repository:
  4. type: zookeeper
  5. props:
  6. namespace: governance_ds
  7. server-lists: localhost:2181
  8. retryIntervalMilliseconds: 500
  9. timeToLiveSeconds: 60
  10. maxRetries: 3
  11. operationTimeoutMilliseconds: 500