config-center.en.md 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
+++
title = "Config Center"
weight = 1
+++

## Motivation

- Centralized configuration: more and more running examples have made it hard to manage separate configurations and asynchronized configurations can cause serious problems. Concentrating them in the configuration center can make the management more effective.

- Dynamic configuration: distribution after configuration modification is another important capability of configuration center. It can support dynamic switch between data sources and rule configurations.

## Structure in Configuration Center

14
Under defined namespace, configuration center stores data sources, rule configurations, authentication configuration, and properties in YAML. Modifying nodes can dynamically refresh configurations.
15 16

```
17
namespace
18 19
    ├──authentication                            # Authentication configuration
    ├──props                                     # Properties configuration
20 21
    ├──schemas                                   # Schema configuration
    ├      ├──${schema_1}                        # Schema name 1
22 23
    ├      ├      ├──datasource                  # Datasource configuration
    ├      ├      ├──rule                        # Rule configuration
24 25
    ├      ├      ├──table                       # Table configuration
    ├      ├──${schema_2}                        # Schema name 2
26 27
    ├      ├      ├──datasource                  # Datasource configuration
    ├      ├      ├──rule                        # Rule configuration
28
    ├      ├      ├──table                       # Table configuration
29 30
```

31
### /authentication
32 33 34 35 36 37 38 39

Authentication configuration. Can configure username and password for ShardingSphere-Proxy.

```yaml
username: root
password: root
```

40
### /props
41

42
Properties configuration. Please refer to [Configuration Manual](/en/user-manual/shardingsphere-jdbc/configuration/) for more details.
43 44

```yaml
K
kimmking 已提交
45 46
executor-size: 20
sql-show: true
47 48
```

49
### /schemas/${schemeName}/datasource
50 51 52 53

A collection of multiple database connection pools, whose properties (e.g. DBCP, C3P0, Druid and HikariCP) are configured by users themselves.

```yaml
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
dataSources:
  ds_0: 
    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
    props:
      url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
      password: null
      maxPoolSize: 50
      maintenanceIntervalMilliseconds: 30000
      connectionTimeoutMilliseconds: 30000
      idleTimeoutMilliseconds: 60000
      minPoolSize: 1
      username: root
      maxLifetimeMilliseconds: 1800000
  ds_1: 
    dataSourceClassName: com.zaxxer.hikari.HikariDataSource
    props:
      url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
      password: null
      maxPoolSize: 50
      maintenanceIntervalMilliseconds: 30000
      connectionTimeoutMilliseconds: 30000
      idleTimeoutMilliseconds: 60000
      minPoolSize: 1
      username: root
      maxLifetimeMilliseconds: 1800000
79 80
```

81
### /schemas/${schemeName}/rule
82

83
Rule configurations, including sharding, replica query, data encryption, shadow DB configurations.
84 85 86 87 88 89

```yaml
rules:
- !SHARDING
  xxx
  
90
- !REPLICA_QUERY
91 92 93 94 95 96
  xxx
  
- !ENCRYPT
  xxx
```

97 98 99 100 101
### /schemas/${schemeName}/table

Dynamic modification of metadata content is not supported currently.

```yaml
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
tables:                                       # Tables
  t_order:                                    # table_name
    columns:                                  # Columns
      id:                                     # column_name
        caseSensitive: false
        dataType: 0
        generated: false
        name: id
        primaryKey: trues
      order_id:
        caseSensitive: false
        dataType: 0
        generated: false
        name: order_id
        primaryKey: false
    indexs:                                   # Indexes
      t_user_order_id_index:                  # index_name
        name: t_user_order_id_index
  t_order_item:
    columns:
      order_id:
        caseSensitive: false
        dataType: 0
        generated: false
        name: order_id
        primaryKey: false
  addressingDataSources:                      # Actual data source names
    - ds_0
    - ds_1
131 132
```

133 134
## Dynamic Effectiveness

135
Modification, deletion and insertion of relevant configurations in the config center will immediately take effect in the producing environment.