Open yuanrui opened 10 months ago
config-sharding.yaml 配置如下
databaseName: tims_db_proxy dataSources: ds_0: url: jdbc:mysql://192.168.1.170:23301/tims_db username: ledadmin password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 1 rules: - !SHARDING tables: t_mon_traffic: # 逻辑表名 actualDataNodes: ds_0.t_mon_traffic_${240101..Integer.parseInt(new java.text.SimpleDateFormat("yyMMdd").format(new Date()))} tableStrategy: # 分表策略 standard: shardingColumn: JGSJ shardingAlgorithmName: sharding_by_day # 按天分表 # keyGenerateStrategy: # column: RECID # keyGeneratorName: snowflake t_mon_report: # 逻辑表名 actualDataNodes: ds_0.t_mon_report_${202401..Integer.parseInt(new java.text.SimpleDateFormat("yyyyMM").format(new Date()))} tableStrategy: # 分表策略 standard: shardingColumn: created_at # 分表字段 shardingAlgorithmName: sharding_by_month # 按月分表 shardingAlgorithms: sharding_by_day: type: INTERVAL props: datetime-pattern: "yyyy-MM-dd HH:mm:ss" datetime-lower: "2024-01-01 00:00:00" # datetime-upper: "2024-12-31 23:59:59" # 范围上限 sharding-suffix-pattern: "yyMMdd" datetime-interval-amount: 1 datetime-interval-unit: "DAYS" sharding_by_month: # 分片类型 type: INTERVAL props: datetime-pattern: "yyyy-MM-dd HH:mm:ss" # 分片字段格式 datetime-lower: "2024-01-01 00:00:00" # 范围下限 # datetime-upper: "2024-12-31 23:59:59" # 范围上限 sharding-suffix-pattern: "yyyyMM" # 分片名后缀,可以是MM,yyyyMMdd等。 datetime-interval-amount: 1 # 分片间隔,这里指一个月 datetime-interval-unit: "MONTHS" # 分片间隔单位 keyGenerators: snowflake: type: SNOWFLAKE # # auditors: # sharding_key_required_auditor: # type: DML_SHARDING_CONDITIONS # #- !BROADCAST # tables: # - t_address ###################################################################################################### # # If you want to connect to MySQL, you should manually copy MySQL driver to lib directory. # ###################################################################################################### #databaseName: sharding_db # #dataSources: # ds_0: # url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false # username: root # password: # connectionTimeoutMilliseconds: 30000 # idleTimeoutMilliseconds: 60000 # maxLifetimeMilliseconds: 1800000 # maxPoolSize: 50 # minPoolSize: 1 # ds_1: # url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false # username: root # password: # connectionTimeoutMilliseconds: 30000 # idleTimeoutMilliseconds: 60000 # maxLifetimeMilliseconds: 1800000 # maxPoolSize: 50 # minPoolSize: 1 # #rules: #- !SHARDING # tables: # t_order: # actualDataNodes: ds_${0..1}.t_order_${0..1} # 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} # 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_inline # defaultTableStrategy: # none: # defaultAuditStrategy: # auditorNames: # - sharding_key_required_auditor # allowHintDisable: true # # shardingAlgorithms: # database_inline: # type: INLINE # props: # algorithm-expression: ds_${user_id % 2} # t_order_inline: # type: INLINE # props: # algorithm-expression: t_order_${order_id % 2} # t_order_item_inline: # type: INLINE # props: # algorithm-expression: t_order_item_${order_id % 2} # # keyGenerators: # snowflake: # type: SNOWFLAKE # # auditors: # sharding_key_required_auditor: # type: DML_SHARDING_CONDITIONS # #- !BROADCAST # tables: # - t_address
config-sharding.yaml 配置如下