sharding-proxy5.X 分库分表和根据时间分表
config-sharding.yaml
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 | schemaName: edu_yjx dataSources: ds_0: url: jdbc:mysql: / / 192.168 . 1.99 : 3306 / test_0?serverTimezone = UTC&useSSL = false username: root password: 123456 connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 ds_1: url: jdbc:mysql: / / 192.168 . 1.100 : 3306 / test_1?serverTimezone = UTC&useSSL = false username: root password: 123456 connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 rules: - !SHARDING tables: t_user: actualDataNodes: ds_${ 0. . 1 }.t_user_${ 0. . 31 } databaseStrategy: standard: shardingColumn: openId shardingAlgorithmName: user_database_inline tableStrategy: standard: shardingColumn: openId shardingAlgorithmName: user_table_inline t_msg: actualDataNodes: ds_${ 0. . 1 }.t_msg_${( 0. . 6 ).collect{java.time.LocalDate.now().minusDays(it). format (java.time. format .DateTimeFormatter.ofPattern( "yyyy_MM_dd" ))}} databaseStrategy: standard: shardingColumn: id shardingAlgorithmName: msg_database_inline tableStrategy: standard: shardingColumn: openId shardingAlgorithmName: msg_table_inline bindingTables: - t_user shardingAlgorithms: user_database_inline: type : INLINE props: algorithm - expression: ds_${( int )(Math. abs (openId.hashCode()) % 64 / 32 )} user_table_inline: type : INLINE props: algorithm - expression: t_user_${Math. abs (openId.hashCode()) % 32 } msg_database_inline: type : INLINE props: algorithm - expression: ds_${( id >> 24 ) % 2 } msg_table_inline: type : INLINE props: algorithm - expression: t_msg_${new Date(( id >> 24 ) + 1484754361114L ). format ( "yyyy_MM_dd" )} |
server.yaml
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 | rules: - !AUTHORITY users: - root@ % : 123456 # 启动该服务的用户密码 - sharding@: 123456 # 启动该服务的用户密码 意思就是用这个密码来登录shardingshare生成的模拟mysql provider: type : NATIVE props: max - connections - size - per - query: 1 # 一次查询请求在每个数据库实例中所能使用的最大连接数。 kernel - executor - size: 16 # 线程池大小 默认值: CPU核数 kernel - acceptor - size: 16 # 用于设置接收客户端请求的工作线程个数,默认为CPU核数*2 proxy - frontend - flush - threshold: 128 # 设置传输数据条数的 IO 刷新阈值 proxy - opentracing - enabled: false #是否开启链路追踪功能,默认为不开启 proxy - hint - enabled: false #是否启用hint算法强制路由 默认false sql - show: ture #是否打印sql 默认falsefalse # 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: false 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 |
螃蟹在剥我的壳,笔记本在写我,漫天的我落在枫叶上雪花上,而你在想我。
--章怀柔
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?