1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
| dataSources: ds_0: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.cj.jdbc.Driver jdbcUrl: jdbc:mysql://127.0.0.1:3306/shardingdb0?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8 username: root password: newpwd
ds_1: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.cj.jdbc.Driver jdbcUrl: jdbc:mysql://127.0.0.1:3306/shardingdb1?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8 username: root password: newpwd
rules: - !SHARDING bindingTables: - t_order,t_order_item
tables: course: actualDataNodes: ds_${0..1}.course_${1..2} databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: course_db_inline tableStrategy: standard: shardingColumn: cid shardingAlgorithmName: course_inline keyGenerateStrategy: column: cid keyGeneratorName: snowflake t_order_complex: actualDataNodes: ds_${0..1}.t_order_complex_${0..1} databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: t_order_db_inline tableStrategy: complex: shardingColumns: user_id,order_id shardingAlgorithmName: t_order-complex-algorithm keyGenerateStrategy: column: order_id keyGeneratorName: snowflake t_order_item_complex: actualDataNodes: ds_${0..1}.t_order_item_complex_${0..1} databaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: t_order_db_inline tableStrategy: complex: shardingColumns: user_id,order_id
shardingAlgorithmName: t_order_item-class-based-algorithm_spi keyGenerateStrategy: column: item_id keyGeneratorName: snowflake
t_user: actualDataNodes: ds_${0..1}.t_user_${0..1} databaseStrategy: standard: shardingColumn: id shardingAlgorithmName: t_user_db_inline tableStrategy: standard: shardingColumn: id shardingAlgorithmName: t_user_inline keyGenerateStrategy: column: id
keyGeneratorName: custom_snowflake_string
autoTables: t_order: actualDataSources: ds_${0..1} shardingStrategy: standard: shardingColumn: user_id shardingAlgorithmName: mod_2 keyGenerateStrategy: column: order_id keyGeneratorName: snowflake t_order_item: actualDataSources: ds_${0..1} shardingStrategy: standard: shardingColumn: user_id shardingAlgorithmName: mod_2 keyGenerateStrategy: column: item_id keyGeneratorName: snowflake
shardingAlgorithms: course_inline: type: INLINE props: algorithm-expression: course_${cid % 2 + 1} allow-range-query-with-inline-sharding: true course_db_inline: type: INLINE props: algorithm-expression: ds_${user_id % 2} mod_2: type: MOD props: sharding-count: 2 t_order_db_inline: type: INLINE props: algorithm-expression: ds_${user_id % 2} t_order-complex-algorithm: type: COMPLEX_INLINE props: algorithm-expression: t_order_complex_${(user_id + order_id + 1) % 2} t_order_item-class-based-algorithm: type: CLASS_BASED props: strategy: COMPLEX algorithmClassName: com.hanqf.demo.support.algorithm.OrderItemComplexAlgorithm t_order_item-class-based-algorithm_spi: type: T_ORDER_ITEM_COMPLEX t_user_db_inline: type: INLINE props: algorithm-expression: ds_${Math.abs(id.hashCode()%2)} t_user_inline: type: INLINE props: algorithm-expression: t_user_${Math.abs(id.hashCode()%4).intdiv(2)}
keyGenerators: snowflake: type: SNOWFLAKE uuid: type: UUID custom_snowflake_string: type: CUSTOM_SNOWFLAKE_STRING props: workerId: 2 datacenterId: 2
- !BROADCAST tables: - dict
- !ENCRYPT tables: t_user: columns: password: cipher: name: password encryptorName: aes_encryptor encryptors: aes_encryptor: type: AES props: aes-key-value: 123456abc digest-algorithm-name: SHA-1 md5_encryptor: type: MD5 props: salt: 123456
- !MASK tables: t_user: columns: password: maskAlgorithm: md5_mask email: maskAlgorithm: mask_before_special_chars_mask telephone: maskAlgorithm: keep_first_n_last_m_mask name: maskAlgorithm: my_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: first-n: 3 last-m: 4 replace-char: '*' my_mask: type: MY_CUSTOM_MASK props: replace-char: "#"
- !SINGLE tables: - ds_0.t_address
props: sql-show: true check-table-metadata-enabled: false
|