配置MySQL数据分片 sharding-proxy 5.0.0 config-sharding.yaml

Colin 3月前 ⋅ 73 阅读
      1 #
      2 # Licensed to the Apache Software Foundation (ASF) under one or more
      3 # contributor license agreements.  See the NOTICE file distributed with
      4 # this work for additional information regarding copyright ownership.
      5 # The ASF licenses this file to You under the Apache License, Version 2.0
      6 # (the "License"); you may not use this file except in compliance with
      7 # the License.  You may obtain a copy of the License at
      8 #
      9 #     http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 #
     17 
     18 ######################################################################################################
     19 #
     20 # If you want to configure governance, authorization and proxy properties, please refer to this file.
     21 #
     22 ######################################################################################################
     23 
     24 #scaling:
     25 #  blockQueueSize: 10000
     26 #  workerThread: 40
     27 #  clusterAutoSwitchAlgorithm:
     28 #    type: IDLE
     29 #    props:
     30 #      incremental-task-idle-minute-threshold: 30
     31 #  dataConsistencyCheckAlgorithm:
     32 #    type: DEFAULT
     33 #
     34 #mode:
     35 #  type: Cluster
     36 #  repository:
     37 #    type: ZooKeeper
     38 #    props:
     39 #      namespace: governance_ds
     40 #      server-lists: localhost:2181
     41 #      retryIntervalMilliseconds: 500
     42 #      timeToLiveSeconds: 60
     43 #      maxRetries: 3
     44 #      operationTimeoutMilliseconds: 500
     45 #  overwrite: false
     46 #
     47 #rules:
     48 #  - !AUTHORITY
     49 #    users:
     50 #      - root@%:root
     51 #      - sharding@:sharding
     52 #    provider:
     53 #      type: ALL_PRIVILEGES_PERMITTED
     54 #  - !TRANSACTION
     55 #    defaultType: XA
     56 #    providerType: Atomikos
     57 
     58 #props:
     59 #  max-connections-size-per-query: 1
     60 #  kernel-executor-size: 16  # Infinite by default.
     61 #  proxy-frontend-flush-threshold: 128  # The default value is 128.
     62 #  proxy-opentracing-enabled: false
     63 #  proxy-hint-enabled: false
     64 #  sql-show: false
     65 #  check-table-metadata-enabled: false
     66 #  show-process-list-enabled: false
     67 #    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
     68 #    # The default value is -1, which means set the minimum value for different JDBC drivers.
     69 #  proxy-backend-query-fetch-size: -1
     70 #  check-duplicate-table-enabled: false
     71 #  sql-comment-parse-enabled: false
     72 #  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
     73 #    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
     74 #    # if client connections are more than proxy-frontend-netty-executor-size, especially executing slow SQL.
     75 #  proxy-backend-executor-suitable: OLAP
     76 #  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
     77 #  sql-federation-enabled: false
     78 #
     79 #
     80 #
     81 #
     82 # Licensed to the Apache Software Foundation (ASF) under one or more
     83 # contributor license agreements.  See the NOTICE file distributed with
     84 # this work for additional information regarding copyright ownership.
     85 # The ASF licenses this file to You under the Apache License, Version 2.0
     86 # (the "License"); you may not use this file except in compliance with
     87 # the License.  You may obtain a copy of the License at
     88 #
     89 #     http://www.apache.org/licenses/LICENSE-2.0
     90 #
     91 # Unless required by applicable law or agreed to in writing, software
     92 # distributed under the License is distributed on an "AS IS" BASIS,
     93 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     94 # See the License for the specific language governing permissions and
     95 # limitations under the License.
     96 #
     97 
     98 ######################################################################################################
     99 #
    100 # Here you can configure the rules for the proxy.
    101 # This example is configuration of sharding rule.
    102 #
    103 ######################################################################################################
    104 #
    105 #schemaName: sharding_db
    106 #
    107 #dataSources:
    108 #  ds_0:
    109 #    url: jdbc:postgresql://127.0.0.1:5432/demo_ds_0
    110 #    username: postgres
    111 #    password: postgres
    112 #    connectionTimeoutMilliseconds: 30000
    113 #    idleTimeoutMilliseconds: 60000
    114 #    maxLifetimeMilliseconds: 1800000
    115 #    maxPoolSize: 50
    116 #    minPoolSize: 1
    117 #  ds_1:
    118 #    url: jdbc:postgresql://127.0.0.1:5432/demo_ds_1
    119 #    username: postgres
    120 #    password: postgres
    121 #    connectionTimeoutMilliseconds: 30000
    122 #    idleTimeoutMilliseconds: 60000
    123 #    maxLifetimeMilliseconds: 1800000
    124 #    maxPoolSize: 50
    125 #    minPoolSize: 1
    126 #
    127 #rules:
    128 #- !SHARDING
    129 #  tables:
    130 #    t_order:
    131 #      actualDataNodes: ds_${0..1}.t_order_${0..1}
    132 #      tableStrategy:
    133 #        standard:
    134 #          shardingColumn: order_id
    135 #          shardingAlgorithmName: t_order_inline
    136 #      keyGenerateStrategy:
    137 #          column: order_id
    138 #          keyGeneratorName: snowflake
    139 #    t_order_item:
    140 #      actualDataNodes: ds_${0..1}.t_order_item_${0..1}
    141 #      tableStrategy:
    142 #        standard:
    143 #          shardingColumn: order_id
    144 #          shardingAlgorithmName: t_order_item_inline
    145 #      keyGenerateStrategy:
    146 #        column: order_item_id
    147 #        keyGeneratorName: snowflake
    148 #  bindingTables:
    149 #    - t_order,t_order_item
    150 #  defaultDatabaseStrategy:
    151 #    standard:
    152 #      shardingColumn: user_id
    153 #      shardingAlgorithmName: database_inline
    154 #  defaultTableStrategy:
    155 #    none:
    156 #
    157 #  shardingAlgorithms:
    158 #    database_inline:
    159 #      type: INLINE
    160 #      props:
    161 #        algorithm-expression: ds_${user_id % 2}
    162 #    t_order_inline:
    163 #      type: INLINE
    164 #      props:
    165 #        algorithm-expression: t_order_${order_id % 2}
    166 #    t_order_item_inline:
    167 #      type: INLINE
    168 #      props:
    169 #        algorithm-expression: t_order_item_${order_id % 2}
    170 #
    171 #  keyGenerators:
    172 #    snowflake:
    173 #      type: SNOWFLAKE
    174 #      props:
    175 #        worker-id: 123
    176 
    177 ######################################################################################################
    178 #
    179 # If you want to connect to MySQL, you should manually copy MySQL driver to lib directory.
    180 #
    181 ######################################################################################################
    182 
    183 #schemaName: sharding_db
    184 #
    185 #dataSources:
    186 #  ds_0:
    187 #    url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
    188 #    username: root
    189 #    password:
    190 #    connectionTimeoutMilliseconds: 30000
    191 #    idleTimeoutMilliseconds: 60000
    192 #    maxLifetimeMilliseconds: 1800000
    193 #    maxPoolSize: 50
    194 #    minPoolSize: 1
    195 #  ds_1:
    196 #    url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
    197 #    username: root
    198 #    password:
    199 #    connectionTimeoutMilliseconds: 30000
    200 #    idleTimeoutMilliseconds: 60000
    201 #    maxLifetimeMilliseconds: 1800000
    202 #    maxPoolSize: 50
    203 #    minPoolSize: 1
    204 #
    205 #rules:
    206 #- !SHARDING
    207 #  tables:
    208 #    t_order:
    209 #      actualDataNodes: ds_${0..1}.t_order_${0..1}
    210 #      tableStrategy:
    211 #        standard:
    212 #          shardingColumn: order_id
    213 #          shardingAlgorithmName: t_order_inline
    214 #      keyGenerateStrategy:
    215 #        column: order_id
    216 #        keyGeneratorName: snowflake
    217 #    t_order_item:
    218 #      actualDataNodes: ds_${0..1}.t_order_item_${0..1}
    219 #      tableStrategy:
    220 #        standard:
    221 #          shardingColumn: order_id
    222 #          shardingAlgorithmName: t_order_item_inline
    223 #      keyGenerateStrategy:
    224 #        column: order_item_id
    225 #        keyGeneratorName: snowflake
    226 #  bindingTables:
    227 #    - t_order,t_order_item
    228 #  defaultDatabaseStrategy:
    229 #    standard:
    230 #      shardingColumn: user_id
    231 #      shardingAlgorithmName: database_inline
    232 #  defaultTableStrategy:
    233 #    none:
    234 #
    235 #  shardingAlgorithms:
    236 #    database_inline:
    237 #      type: INLINE
    238 #      props:
    239 #        algorithm-expression: ds_${user_id % 2}
    240 #    t_order_inline:
    241 #      type: INLINE
    242 #      props:
    243 #        algorithm-expression: t_order_${order_id % 2}
    244 #    t_order_item_inline:
    245 #      type: INLINE
    246 #      props:
    247 #        algorithm-expression: t_order_item_${order_id % 2}
    248 #
    249 #  keyGenerators:
    250 #    snowflake:
    251 #      type: SNOWFLAKE
    252 #      props:
    253 #        worker-id: 123


全部评论: 0

    我有话说: