Procházet zdrojové kódy

update sharding-proxy 5.3.2 => 5.4.0 配置文件写法升级

疯狂的狮子Li před 3 roky
rodič
revize
83743b04b0

+ 1 - 1
docker/docker-compose.yml

@@ -493,7 +493,7 @@ services:
     network_mode: "host"
 
   shardingproxy:
-    image: apache/shardingsphere-proxy:5.3.2
+    image: apache/shardingsphere-proxy:5.4.0
     container_name: shardingsphere-proxy
     command: server /data
     ports:

+ 24 - 18
docker/shardingproxy/conf/config-encrypt.yaml

@@ -16,13 +16,13 @@
 #
 
 ######################################################################################################
-# 
+#
 # Here you can configure the rules for the proxy.
 # This example is configuration of encrypt rule.
-# 
+#
 ######################################################################################################
 #
-#schemaName: encrypt_db
+#databaseName: encrypt_db
 #
 #dataSources:
 #  ds_0:
@@ -51,18 +51,21 @@
 #      type: AES
 #      props:
 #        aes-key-value: 123456abc
-#    md5_encryptor:
-#      type: MD5
+#    rc4_encryptor:
+#      type: RC4
+#      props:
+#        rc4-key-value: 123456abc
 #  tables:
 #    t_encrypt:
 #      columns:
 #        user_id:
-#          plainColumn: user_plain
-#          cipherColumn: user_cipher
-#          encryptorName: aes_encryptor
+#          cipher:
+#            name: user_cipher
+#            encryptorName: aes_encryptor
 #        order_id:
-#          cipherColumn: order_encrypt
-#          encryptorName: md5_encryptor
+#          cipher:
+#            name: order_encrypt
+#            encryptorName: rc4_encryptor
 
 ######################################################################################################
 #
@@ -70,7 +73,7 @@
 #
 ######################################################################################################
 #
-#schemaName: encrypt_db
+#databaseName: encrypt_db
 #
 #dataSources:
 #  ds_0:
@@ -99,15 +102,18 @@
 #      type: AES
 #      props:
 #        aes-key-value: 123456abc
-#    md5_encryptor:
-#      type: MD5
+#    rc4_encryptor:
+#      type: RC4
+#      props:
+#        rc4-key-value: 123456abc
 #  tables:
 #    t_encrypt:
 #      columns:
 #        user_id:
-#          plainColumn: user_plain
-#          cipherColumn: user_cipher
-#          encryptorName: aes_encryptor
+#          cipher:
+#            name: user_cipher
+#            encryptorName: aes_encryptor
 #        order_id:
-#          cipherColumn: order_cipher
-#          encryptorName: md5_encryptor
+#          cipher:
+#            name: order_encrypt
+#            encryptorName: rc4_encryptor

+ 62 - 60
docker/shardingproxy/conf/config-database-discovery.yaml → docker/shardingproxy/conf/config-mask.yaml

@@ -18,108 +18,110 @@
 ######################################################################################################
 #
 # Here you can configure the rules for the proxy.
-# This example is configuration of HA rule.
+# This example is configuration of mask rule.
 #
 ######################################################################################################
 #
-#schemaName: database_discovery_db
+#databaseName: mask_db
 #
 #dataSources:
-#  primary_ds:
-#    url: jdbc:postgresql://127.0.0.1:5432/demo_primary_ds
-#    username: postgres
-#    password: postgres
-#    connectionTimeoutMilliseconds: 3000
-#    idleTimeoutMilliseconds: 60000
-#    maxLifetimeMilliseconds: 1800000
-#    maxPoolSize: 50
-#    minPoolSize: 1
-#  replica_ds_0:
-#    url: jdbc:postgresql://127.0.0.1:5432/demo_replica_ds_0
+#  ds_0:
+#    url: jdbc:postgresql://127.0.0.1:5432/demo_ds_0
 #    username: postgres
 #    password: postgres
-#    connectionTimeoutMilliseconds: 3000
+#    connectionTimeoutMilliseconds: 30000
 #    idleTimeoutMilliseconds: 60000
 #    maxLifetimeMilliseconds: 1800000
 #    maxPoolSize: 50
 #    minPoolSize: 1
-#  replica_ds_1:
-#    url: jdbc:postgresql://127.0.0.1:5432/demo_replica_ds_1
+#  ds_1:
+#    url: jdbc:postgresql://127.0.0.1:5432/demo_ds_1
 #    username: postgres
 #    password: postgres
-#    connectionTimeoutMilliseconds: 3000
+#    connectionTimeoutMilliseconds: 30000
 #    idleTimeoutMilliseconds: 60000
 #    maxLifetimeMilliseconds: 1800000
 #    maxPoolSize: 50
 #    minPoolSize: 1
 #
 #rules:
-#- !DB_DISCOVERY
-#  dataSources:
-#    pr_ds:
-#      dataSourceNames:
-#        - ds_0
-#        - ds_1
-#        - ds_2
-#      discoveryTypeName: mgr
-#  discoveryTypes:
-#    mgr:
-#      type: MGR
+#- !MASK
+#  tables:
+#    t_user:
+#      columns:
+#        password:
+#          maskAlgorithm: md5_mask
+#        email:
+#          maskAlgorithm: mask_before_special_chars_mask
+#        telephone:
+#          maskAlgorithm: keep_first_n_last_m_mask
+#
+#  maskAlgorithms:
+#    md5_mask:
+#      type: MD5
+#    mask_before_special_chars_mask:
+#      type: MASK_BEFORE_SPECIAL_CHARS
+#      props:
+#        special-chars: '@'
+#        replace-char: '*'
+#    keep_first_n_last_m_mask:
+#      type: KEEP_FIRST_N_LAST_M
 #      props:
-#        groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-#        zkServerLists: 'localhost:2181'
-#        keepAliveCron: '0/5 * * * * ?'
+#        first-n: 3
+#        last-m: 4
+#        replace-char: '*'
 
 ######################################################################################################
 #
 # If you want to connect to MySQL, you should manually copy MySQL driver to lib directory.
 #
 ######################################################################################################
-
-#schemaName: database_discovery_db
+#
+#databaseName: mask_db
 #
 #dataSources:
 #  ds_0:
-#    url: jdbc:mysql://127.0.0.1:3306/demo_primary_ds?serverTimezone=UTC&useSSL=false
+#    url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
 #    username: root
 #    password:
-#    connectionTimeoutMilliseconds: 3000
+#    connectionTimeoutMilliseconds: 30000
 #    idleTimeoutMilliseconds: 60000
 #    maxLifetimeMilliseconds: 1800000
 #    maxPoolSize: 50
 #    minPoolSize: 1
 #  ds_1:
-#    url: jdbc:mysql://127.0.0.1:3306/demo_replica_ds_0?serverTimezone=UTC&useSSL=false
-#    username: root
-#    password:
-#    connectionTimeoutMilliseconds: 3000
-#    idleTimeoutMilliseconds: 60000
-#    maxLifetimeMilliseconds: 1800000
-#    maxPoolSize: 50
-#    minPoolSize: 1
-#  ds_2:
-#    url: jdbc:mysql://127.0.0.1:3306/demo_replica_ds_1?serverTimezone=UTC&useSSL=false
+#    url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
 #    username: root
 #    password:
-#    connectionTimeoutMilliseconds: 3000
+#    connectionTimeoutMilliseconds: 30000
 #    idleTimeoutMilliseconds: 60000
 #    maxLifetimeMilliseconds: 1800000
 #    maxPoolSize: 50
 #    minPoolSize: 1
 #
 #rules:
-#- !DB_DISCOVERY
-#  dataSources:
-#    pr_ds:
-#      dataSourceNames:
-#        - ds_0
-#        - ds_1
-#        - ds_2
-#      discoveryTypeName: mgr
-#  discoveryTypes:
-#    mgr:
-#      type: MGR
+#- !MASK
+#  tables:
+#    t_user:
+#      columns:
+#        password:
+#          maskAlgorithm: md5_mask
+#        email:
+#          maskAlgorithm: mask_before_special_chars_mask
+#        telephone:
+#          maskAlgorithm: keep_first_n_last_m_mask
+#
+#  maskAlgorithms:
+#    md5_mask:
+#      type: MD5
+#    mask_before_special_chars_mask:
+#      type: MASK_BEFORE_SPECIAL_CHARS
+#      props:
+#        special-chars: '@'
+#        replace-char: '*'
+#    keep_first_n_last_m_mask:
+#      type: KEEP_FIRST_N_LAST_M
 #      props:
-#        groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-#        zkServerLists: 'localhost:2181'
-#        keepAliveCron: '0/5 * * * * ?'
+#        first-n: 3
+#        last-m: 4
+#        replace-char: '*'

+ 15 - 7
docker/shardingproxy/conf/config-readwrite-splitting.yaml

@@ -16,13 +16,13 @@
 #
 
 ######################################################################################################
-# 
+#
 # Here you can configure the rules for the proxy.
-# This example is configuration of replica-query rule.
-# 
+# This example is configuration of readwrite-splitting rule.
+#
 ######################################################################################################
 #
-#schemaName: readwrite_splitting_db
+#databaseName: readwrite_splitting_db
 #
 #dataSources:
 #  primary_ds:
@@ -56,11 +56,15 @@
 #rules:
 #- !READWRITE_SPLITTING
 #  dataSources:
-#    pr_ds:
+#    readwrite_ds:
 #      writeDataSourceName: primary_ds
 #      readDataSourceNames:
 #        - replica_ds_0
 #        - replica_ds_1
+#      loadBalancerName: random
+#  loadBalancers:
+#    random:
+#      type: RANDOM
 
 ######################################################################################################
 #
@@ -68,7 +72,7 @@
 #
 ######################################################################################################
 
-#schemaName: readwrite_splitting_db
+#databaseName: readwrite_splitting_db
 #
 #dataSources:
 #  write_ds:
@@ -102,8 +106,12 @@
 #rules:
 #- !READWRITE_SPLITTING
 #  dataSources:
-#    pr_ds:
+#    readwrite_ds:
 #      writeDataSourceName: write_ds
 #      readDataSourceNames:
 #        - read_ds_0
 #        - read_ds_1
+#      loadBalancerName: random
+#  loadBalancers:
+#    random:
+#      type: RANDOM

+ 38 - 42
docker/shardingproxy/conf/config-shadow.yaml

@@ -16,13 +16,13 @@
 #
 
 ######################################################################################################
-# 
+#
 # Here you can configure the rules for the proxy.
 # This example is configuration of shadow rule.
-# 
+#
 ######################################################################################################
 #
-#schemaName: shadow_db
+#databaseName: shadow_db
 #
 #dataSources:
 #  ds:
@@ -46,55 +46,53 @@
 #
 #rules:
 #- !SHADOW
-#  enable: true
 #  dataSources:
 #    shadowDataSource:
-#      sourceDataSourceName: ds
+#      productionDataSourceName: ds
 #      shadowDataSourceName: shadow_ds
 #  tables:
 #    t_order:
 #      dataSourceNames:
 #        - shadowDataSource
 #      shadowAlgorithmNames:
-#        - user-id-insert-match-algorithm
-#        - user-id-select-match-algorithm
+#        - user_id_insert_match_algorithm
+#        - user_id_select_match_algorithm
 #    t_order_item:
 #      dataSourceNames:
 #        - shadowDataSource
 #      shadowAlgorithmNames:
-#        - user-id-insert-match-algorithm
-#        - user-id-update-match-algorithm
-#        - user-id-select-match-algorithm
+#        - user_id_insert_match_algorithm
+#        - user_id_update_match_algorithm
+#        - user_id_select_match_algorithm
 #    t_address:
 #      dataSourceNames:
 #        - shadowDataSource
 #      shadowAlgorithmNames:
-#        - user-id-insert-match-algorithm
-#        - user-id-select-match-algorithm
-#        - simple-note-algorithm
+#        - user_id_insert_match_algorithm
+#        - user_id_select_match_algorithm
+#        - sql_hint_algorithm
 #  shadowAlgorithms:
-#    user-id-insert-match-algorithm:
-#      type: COLUMN_REGEX_MATCH
+#    user_id_insert_match_algorithm:
+#      type: REGEX_MATCH
 #      props:
 #        operation: insert
 #        column: user_id
 #        regex: "[1]"
-#    user-id-update-match-algorithm:
-#      type: COLUMN_REGEX_MATCH
+#    user_id_update_match_algorithm:
+#      type: REGEX_MATCH
 #      props:
 #        operation: update
 #        column: user_id
 #        regex: "[1]"
-#    user-id-select-match-algorithm:
-#      type: COLUMN_REGEX_MATCH
+#    user_id_select_match_algorithm:
+#      type: REGEX_MATCH
 #      props:
 #        operation: select
 #        column: user_id
 #        regex: "[1]"
-#    simple-note-algorithm:
-#      type: SIMPLE_NOTE
+#    sql_hint_algorithm:
+#      type: SQL_HINT
 #      props:
-#        shadow: true
 #        foo: bar
 
 ######################################################################################################
@@ -103,7 +101,7 @@
 #
 ######################################################################################################
 #
-#schemaName: shadow_db
+#databaseName: shadow_db
 #
 #dataSources:
 #  ds:
@@ -127,53 +125,51 @@
 #
 #rules:
 #- !SHADOW
-#  enable: true
 #  dataSources:
 #    shadowDataSource:
-#      sourceDataSourceName: ds
+#      productionDataSourceName: ds
 #      shadowDataSourceName: shadow_ds
 #  tables:
 #    t_order:
 #      dataSourceNames:
 #        - shadowDataSource
 #      shadowAlgorithmNames:
-#        - user-id-insert-match-algorithm
-#        - user-id-select-match-algorithm
+#        - user_id_insert_match_algorithm
+#        - user_id_select_match_algorithm
 #    t_order_item:
 #      dataSourceNames:
 #        - shadowDataSource
 #      shadowAlgorithmNames:
-#        - user-id-insert-match-algorithm
-#        - user-id-update-match-algorithm
-#        - user-id-select-match-algorithm
+#        - user_id_insert_match_algorithm
+#        - user_id_update_match_algorithm
+#        - user_id_select_match_algorithm
 #    t_address:
 #      dataSourceNames:
 #        - shadowDataSource
 #      shadowAlgorithmNames:
-#        - user-id-insert-match-algorithm
-#        - user-id-select-match-algorithm
-#        - simple-note-algorithm
+#        - user_id_insert_match_algorithm
+#        - user_id_select_match_algorithm
+#        - sql_hint_algorithm
 #  shadowAlgorithms:
-#    user-id-insert-match-algorithm:
-#      type: COLUMN_REGEX_MATCH
+#    user_id_insert_match_algorithm:
+#      type: REGEX_MATCH
 #      props:
 #        operation: insert
 #        column: user_id
 #        regex: "[1]"
-#    user-id-update-match-algorithm:
-#      type: COLUMN_REGEX_MATCH
+#    user_id_update_match_algorithm:
+#      type: REGEX_MATCH
 #      props:
 #        operation: update
 #        column: user_id
 #        regex: "[1]"
-#    user-id-select-match-algorithm:
-#      type: COLUMN_REGEX_MATCH
+#    user_id_select_match_algorithm:
+#      type: REGEX_MATCH
 #      props:
 #        operation: select
 #        column: user_id
 #        regex: "[1]"
-#    simple-note-algorithm:
-#      type: SIMPLE_NOTE
+#    sql_hint_algorithm:
+#      type: SQL_HINT
 #      props:
-#        shadow: true
 #        foo: bar

+ 96 - 56
docker/shardingproxy/conf/config-sharding.yaml

@@ -1,14 +1,32 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
 ######################################################################################################
 #
-# 用于配置:数据分片规则
+# Here you can configure the rules for the proxy.
+# This example is configuration of sharding rule.
 #
 ######################################################################################################
 
-schemaName: data-center_db
+databaseName: data-center_db
 
 dataSources:
   ds_0:
-    url: jdbc:mysql://192.168.0.60:3306/data-center_0?serverTimezone=UTC&useSSL=false
+    url: jdbc:mysql://localhost:3306/data-center_0?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
     username: root
     password: root
     connectionTimeoutMilliseconds: 30000
@@ -17,7 +35,7 @@ dataSources:
     maxPoolSize: 50
     minPoolSize: 1
   ds_1:
-    url: jdbc:mysql://192.168.0.60:3306/data-center_1?serverTimezone=UTC&useSSL=false
+    url: jdbc:mysql://localhost:3306/data-center_1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
     username: root
     password: root
     connectionTimeoutMilliseconds: 30000
@@ -27,58 +45,80 @@ dataSources:
     minPoolSize: 1
 
 rules:
-  - !SHARDING
-    tables: # 数据分片规则配置
-      t_order: # 订单逻辑表名称
-        actualDataNodes: ds_${0..1}.t_order_${0..1}
-        databaseStrategy: # 配置分库策略
-          standard:
-            shardingColumn: user_id
-            shardingAlgorithmName: database_user_inline
-        tableStrategy: # 分表策略
-          standard:
-            shardingColumn: order_id
-            shardingAlgorithmName: t_order_inline
-        keyGenerateStrategy:
-          column: order_id
-          keyGeneratorName: snowflake
-      t_order_item: # 子订单逻辑表名称
-        actualDataNodes: ds_${0..1}.t_order_item_${0..1}
-        databaseStrategy: # 配置分库策略
-          standard:
-            shardingColumn: user_id
-            shardingAlgorithmName: database_user_inline
-        tableStrategy: # 分表策略
-          standard:
-            shardingColumn: order_id
-            shardingAlgorithmName: t_order_item_inline
-        keyGenerateStrategy:
-          column: order_item_id
-          keyGeneratorName: snowflake
-    bindingTables: # 绑定表规则列表
-      - t_order,t_order_item
+- !SHARDING
+ tables: # 数据分片规则配置
+   t_order: # 订单逻辑表名称
+     actualDataNodes: ds_${0..1}.t_order_${0..1}
+     databaseStrategy: # 配置分库策略
+       standard:
+         shardingColumn: user_id
+         shardingAlgorithmName: database_user_inline
+     tableStrategy: # 分表策略
+       standard:
+         shardingColumn: order_id
+         shardingAlgorithmName: t_order_inline
+     keyGenerateStrategy:
+       column: order_id
+       keyGeneratorName: snowflake
+#      auditStrategy:
+#        auditorNames:
+#          - sharding_key_required_auditor
+#        allowHintDisable: true
+   t_order_item:  # 子订单逻辑表名称
+     actualDataNodes: ds_${0..1}.t_order_item_${0..1}
+     databaseStrategy: # 配置分库策略
+       standard:
+         shardingColumn: user_id
+         shardingAlgorithmName: database_user_inline
+     tableStrategy:  # 分表策略
+       standard:
+         shardingColumn: order_id
+         shardingAlgorithmName: t_order_item_inline
+     keyGenerateStrategy:
+       column: order_item_id
+       keyGeneratorName: snowflake
+ bindingTables:  # 绑定表规则列表
+   - t_order,t_order_item
+#  defaultDatabaseStrategy:
+#    standard:
+#      shardingColumn: user_id
+#      shardingAlgorithmName: database_user_inline
+#  defaultTableStrategy:
+#    none:
+#  defaultAuditStrategy:
+#    auditorNames:
+#      - sharding_key_required_auditor
+#    allowHintDisable: true
+
+ # 分片算法配置
+ shardingAlgorithms:
+   database_user_inline:
+     type: INLINE
+     props:
+       algorithm-expression: ds_${user_id % 2}
+   t_order_inline:  # 订单表分片算法名称
+     type: INLINE
+     props:
+       algorithm-expression: t_order_${order_id % 2}
+       allow-range-query-with-inline-sharding: true
+   t_order_item_inline:  # 子订单表分片算法名称
+     type: INLINE
+     props:
+       algorithm-expression: t_order_item_${order_id % 2}
+       allow-range-query-with-inline-sharding: true
+
+ # 分布式序列算法配置
+ keyGenerators:
+   snowflake:
+     type: SNOWFLAKE
+     props:
+       worker-id: 1
 
-    # 分片算法配置
-    shardingAlgorithms:
-      database_user_inline:
-        type: INLINE
-        props:
-          algorithm-expression: ds_${user_id % 2}
-      t_order_inline: # 订单表分片算法名称
-        type: INLINE
-        props:
-          algorithm-expression: t_order_${order_id % 2}
-          allow-range-query-with-inline-sharding: true
-      t_order_item_inline: # 子订单表分片算法名称
-        type: INLINE
-        props:
-          algorithm-expression: t_order_item_${order_id % 2}
-          allow-range-query-with-inline-sharding: true
+#  auditors:
+#    sharding_key_required_auditor:
+#      type: DML_SHARDING_CONDITIONS
 
-    # 分布式序列算法配置
-    keyGenerators:
-      snowflake:
-        type: SNOWFLAKE
-        props:
-          worker-id: 1
+# - !BROADCAST
+#  tables:
+#    - t_address
 

+ 74 - 43
docker/shardingproxy/conf/server.yaml

@@ -1,20 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
 ######################################################################################################
 #
-# 用于配置:数据接入迁移&弹性伸缩、分布式治理模式、权限、代理属性.
+# If you want to configure governance, authorization and proxy properties, please refer to this file.
 #
 ######################################################################################################
 
-#scaling:
-#  blockQueueSize: 10000 # 数据传输通道队列大小
-#  workerThread: 40 # 工作线程池大小,允许同时运行的迁移任务线程数
-#  clusterAutoSwitchAlgorithm:
-#    type: IDLE
-#    props:
-#      incremental-task-idle-minute-threshold: 30
-#  dataConsistencyCheckAlgorithm:
-#    type: DEFAULT
-#
-#mode:
+# mode:
 #  type: Cluster
 #  repository:
 #    type: ZooKeeper
@@ -25,37 +32,61 @@
 #      timeToLiveSeconds: 60
 #      maxRetries: 3
 #      operationTimeoutMilliseconds: 500
-#  overwrite: false
-#
-rules:
-  - !AUTHORITY
-    users:
-      - root@%:root
-      - sharding@:sharding
-    provider:
-      type: ALL_PRIVILEGES_PERMITTED
-  - !TRANSACTION
-    defaultType: XA
-    providerType: Atomikos
+
+authority:
+ users:
+   - user: root@%
+     password: root
+   - user: sharding
+     password: sharding
+ privilege:
+   type: ALL_PERMITTED
+
+transaction:
+ defaultType: XA
+ providerType: Atomikos
+
+sqlParser:
+ sqlCommentParseEnabled: false
+ sqlStatementCache:
+   initialCapacity: 2000
+   maximumSize: 65535
+ parseTreeCache:
+   initialCapacity: 128
+   maximumSize: 1024
+
+logging:
+ loggers:
+ - loggerName: ShardingSphere-SQL
+   additivity: true
+   level: INFO
+   props:
+     enable: false
+
+sqlFederation:
+ sqlFederationEnabled: false
+ executionPlanCache:
+   initialCapacity: 2000
+   maximumSize: 65535
 
 props:
-  max-connections-size-per-query: 1
-  kernel-executor-size: 16  # Infinite by default.
-  proxy-frontend-flush-threshold: 128  # The default value is 128.
-  #  proxy-opentracing-enabled: false
-  #  proxy-hint-enabled: false
-  sql-show: true
-  #  check-table-metadata-enabled: false
-  #  show-process-list-enabled: false
-  #    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
-  #    # The default value is -1, which means set the minimum value for different JDBC drivers.
-  #  proxy-backend-query-fetch-size: -1
-  check-duplicate-table-enabled: true
-#  sql-comment-parse-enabled: false
-#  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
-#    # 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
-#    # if client connections are more than proxy-frontend-netty-executor-size, especially executing slow SQL.
-#  proxy-backend-executor-suitable: OLAP
-#  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
-#  sql-federation-enabled: false
+ system-log-level: INFO
+ max-connections-size-per-query: 1
+ kernel-executor-size: 16  # Infinite by default.
+ proxy-frontend-flush-threshold: 128  # The default value is 128.
+ # sql-show is the same as props in logger ShardingSphere-SQL, and its priority is lower than logging rule
+ sql-show: false
+ check-table-metadata-enabled: false
+   # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
+   # The default value is -1, which means set the minimum value for different JDBC drivers.
+ proxy-backend-query-fetch-size: -1
+ proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
+ proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
+ proxy-default-port: 3307 # Proxy default port.
+ proxy-netty-backlog: 1024 # Proxy netty backlog.
+ cdc-server-port: 33071 # CDC server port
+ proxy-frontend-ssl-enabled: false
+ proxy-frontend-ssl-cipher: ''
+ proxy-frontend-ssl-version: TLSv1.2,TLSv1.3
+
 

binární
docker/shardingproxy/ext-lib/mysql-connector-j-8.0.33.jar


binární
docker/shardingproxy/ext-lib/mysql-connector-java-8.0.11.jar


+ 1 - 1
ruoyi-example/ruoyi-demo/src/main/java/org/dromara/demo/controller/TestShardingController.java

@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
- * 使用方式 https://blog.csdn.net/zhaozhiqiang1981/article/details/129935075
+ * 使用方式 看官网文档扩展项目
  */
 @RequiredArgsConstructor
 @RestController

+ 2 - 0
ruoyi-example/ruoyi-demo/src/main/resources/application.yml

@@ -47,6 +47,8 @@ spring:
           username: ${datasource.system-master.username}
           password: ${datasource.system-master.password}
         sharding:
+          lazy: true
+          type: ${spring.datasource.type}
           driver-class-name: com.mysql.cj.jdbc.Driver
           # shardingproxy 服务的ip地址
           url: jdbc:mysql://127.0.0.1:3307/data-center_db?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true