Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] refactor config center, according the new config path key. #346

Closed
3 tasks done
dongzl opened this issue Aug 7, 2022 · 6 comments
Closed
3 tasks done
Assignees
Labels
config Config center. refactor Refactor code

Comments

@dongzl
Copy link
Contributor

dongzl commented Aug 7, 2022

What would you like to be added:

Why is this needed:

  • add rootPath config at bootstrap.xml & env;
  • add version config to bootstrap.xml;
  • fix etcd client problem, dubbogo/gost etcd unsuited;
    The new config design:

配置中心

Root

ARANA_ROOT=/arana

Tenants

# 路径 Key
${ARANA_ROOT}/v1/tenants/<tenant>
/arana/v1/tenants/arana

# 存储内容
- name: arana
  users:
    - username: root
      password: "123456"
    - username: arana
      password: "123456"

Nodes

# 路径 Key
${ARANA_ROOT}/v1/tenants/<tenant>/nodes/<node>
/arana/v1/tenants/arana/nodes/node0
/arana/v1/tenants/arana/nodes/node1

# 存储内容
- name: node0
  host: arana-mysql
  port: 3306
  username: root
  password: "123456"
  database: employees_0000
  weight: r10w10
  parameters:

Data Source Clusters

# 路径 Key
${ARANA_ROOT}/v1/tenants/<tenant>/clusters/<cluster>/groups/<group>/nodes/<node>
/arana/v1/tenants/arana/clusters/employees/groups/employees_0000/nodes/node0
/arana/v1/tenants/arana/clusters/employees/groups/employees_0000/nodes/node0_r_0

# 存储内容
- name: node0
  host: arana-mysql
  port: 3306
  username: root
  password: "123456"
  database: employees_0000
  weight: r10w10
  parameters:


# 路径 Key
${ARANA_ROOT}/v1/tenants/<tenant>/clusters/<cluster>/groups/<group>
/arana/v1/tenants/arana/clusters/employees/groups/employees_0000
/arana/v1/tenants/arana/clusters/employees/groups/employees_0001

# 存储内容
nodes:
  - node0
  - node1

Sharding Rule

# 路径 Key
${ARANA_ROOT}/v1/tenants/<tenant>/clusters/<cluster>/tables/<table>
/arana/v1/tenants/arana/clusters/employees/tables/student
/arana/v1/tenants/arana/clusters/employees/tables/order

# 存储内容
- name: student
  allow_full_scan: true
  sequence:
    type: snowflake
    option:
  db_rules:
    - column: uid
      type: scriptExpr
      expr: parseInt($value % 32 / 8)
  tbl_rules:
    - column: uid
      type: scriptExpr
      expr: $value % 32
      step: 32
  topology:
    db_pattern: employees_${0000..0003}
    tbl_pattern: student_${0000..0031}
  attributes:
    sqlMaxLimit: -1
@dongzl dongzl added refactor Refactor code config Config center. labels Aug 7, 2022
@baerwang baerwang removed their assignment Aug 8, 2022
@chuntaojun
Copy link
Contributor

ok

@chuntaojun
Copy link
Contributor

新的 config.yaml 文件内容

kind: ConfigMap
apiVersion: "1.0"
metadata:
  name: arana-config
data:
  listeners:
    - protocol_type: mysql
      server_version: 5.7.0
      socket_address:
        address: 0.0.0.0
        port: 13306

  tenants:
    tenant:
      - name: arana
        users:
          - username: arana
            password: "123456"
          - username: dksl
            password: "123456"

    clusters:
      - name: employees
        type: mysql
        sql_max_limit: -1
        tenant: arana
        parameters:
          max_allowed_packet: 256M
        groups:
          - name: employees_0000
            nodes:
              - node0
              - node0_r_0
          - name: employees_0001
            nodes:
              - node1
          - name: employees_0002
            nodes:
              - node2
          - name: employees_0003
            nodes:
              - node3
        sharding_rule:
          tables:
            - name: employees.student
              allow_full_scan: true
              sequence:
                type: snowflake
                option:
              db_rules:
                - column: uid
                  type: scriptExpr
                  expr: parseInt($value % 32 / 8)
              tbl_rules:
                - column: uid
                  type: scriptExpr
                  expr: $value % 32
                  step: 32
              topology:
                db_pattern: employees_${0000..0003}
                tbl_pattern: student_${0000..0031}
              attributes:
                sqlMaxLimit: -1
    nodes:
      - id: node0
        name: node0
        host: arana-mysql
        port: 3306
        username: root
        password: "123456"
        database: employees_0000
        weight: r10w10
        parameters:
      - id: node0_r_0
        name: node0_r_0
        host: arana-mysql
        port: 3306
        username: root
        password: "123456"
        database: employees_0000_r
        weight: r0w0
        parameters:
      - id: node1
        name: node1
        host: arana-mysql
        port: 3306
        username: root
        password: "123456"
        database: employees_0001
        weight: r10w10
        parameters:
      - id: node2
        name: node2
        host: arana-mysql
        port: 3306
        username: root
        password: "123456"
        database: employees_0002
        weight: r10w10
        parameters:
      - id: node3
        name: node3
        host: arana-mysql
        port: 3306
        username: root
        password: "123456"
        database: employees_0003
        weight: r10w10
        parameters:

@Mulavar
Copy link
Contributor

Mulavar commented Aug 13, 2022

tenants clusters nodes 是平级关系吧?这个缩进好像有问题。

@chuntaojun
Copy link
Contributor

tenants clusters nodes 是平级关系吧?这个缩进好像有问题。

已经不是平级的了,cluster、nodes 都是在某一个 tenant 下的资源

@dongzl
Copy link
Contributor Author

dongzl commented Aug 13, 2022

nodes 下面的 id, name 有不同含义吗?是不是保留一个就可以?

@chuntaojun
Copy link
Contributor

nodes 下面的 id, name 有不同含义吗?是不是保留一个就可以?

id 一般自动生成,name 是让用户更容易理解记住?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Config center. refactor Refactor code
Projects
None yet
Development

No branches or pull requests

4 participants