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

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