赞
踩
shardingsphere和mycat类似,均是高可用数据库的解决方案中间件。这里采用shardingsphere。
如果大家对shardingsphere不了解,先找些文章或者视频看一下,入门一下,然后需要看官方文档,你在看别人的文章或者东西的时候是一个快餐,而你看官方文档的时候才是大餐,所以请一定不要错过大餐。shardingsphere官方文档:https://shardingsphere.apache.org/document/legacy/4.x/document/cn/overview/
每天按峰值60万计算,每月1800万一年:2.16亿。 2020新增(亿):2.16 2020年累计总量亿):2.16 ====================================== 2021新增(亿):2.3760000000000003 2021年累计总量亿):4.5360000000000005 ====================================== 2022新增(亿):2.6136000000000004 2022年累计总量亿):7.149600000000001 ====================================== 2023新增(亿):2.8749600000000006 2023年累计总量亿):10.024560000000001 ====================================== 2024新增(亿):3.162456000000001 2024年累计总量亿):13.187016000000002 ====================================== 2025新增(亿):3.4787016000000013 2025年累计总量亿):16.665717600000004 ====================================== 2026新增(亿):3.8265717600000015 2026年累计总量亿):20.492289360000004 ====================================== 2027新增(亿):4.209228936000002 2027年累计总量亿):24.701518296000007 ====================================== 2028新增(亿):4.630151829600003 2028年累计总量亿):29.33167012560001 ====================================== 2029新增(亿):5.093167012560003 2029年累计总量亿):34.424837138160015 ====================================== 2030新增(亿):5.602483713816004 2030年累计总量亿):40.02732085197602 ======================================
到达2022年累计数据达到7.14亿,如何提高数据库的想能。
机构和分区的关系实例,用户纵向分区:
机构号 | 库分区号 |
---|---|
070667001 | 0 |
070667002 | 0 |
070667003 | 1 |
070667004 | 2 |
070667005 | 3 |
070667006 | 4 |
070667007 | 5 |
070667008 | 6 |
070667009 | 6 |
0706670010 | 6 |
070667011 | 6 |
柜员和分区的关系实例,用户横向分区:
机构号 | 表分区号 |
---|---|
4001 | 0 |
4002 | 0 |
4003 | 1 |
4004 | 2 |
4005 | 3 |
4006 | 4 |
4007 | 5 |
4008 | 6 |
4009 | 6 |
… … | … … |
4010 | 31 |
… … | … … |
schemaName: sharding_db dataSources: master_ds_0: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 slave_ds_0: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 master_ds_1: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 slave_ds_1: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 master_ds_2: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 slave_ds_2: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 master_ds_3: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 slave_ds_3: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 master_ds_4: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 slave_ds_4: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 master_ds_5: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 slave_ds_5: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 master_ds_6: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 slave_ds_6: url: jdbc:mysql://***.***.***.***:****/db_seq?serverTimezone=UTC&useSSL=false username: test password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 200 shardingRule: tables: tb_seq: actualDataNodes: ms_ds_${0..6}.tb_seq${0..30} databaseStrategy: inline: shardingColumn: ds_zone # 流水表中数据库的分区字段 0,1,2,3,4,5,6-和支行关联配置 algorithmExpression: ms_ds_${ds_zone} tableStrategy: inline: shardingColumn: tb_zone #表分区key值 algorithmExpression: tb_seq${ds_zone} keyGenerator: type: SNOWFLAKE #5.0之后使用LEAF column: seq_id #主键 bindingTables: - tb_seq defaultDataSourceName: master_ds_1 defaultTableStrategy: none: masterSlaveRules: ms_ds_0: masterDataSourceName: master_ds_0 slaveDataSourceNames: - slave_ds_0 loadBalanceAlgorithmType: ROUND_ROBIN ms_ds_1: masterDataSourceName: master_ds_1 slaveDataSourceNames: - slave_ds_1 loadBalanceAlgorithmType: ROUND_ROBIN ms_ds_2: masterDataSourceName: master_ds_2 slaveDataSourceNames: - slave_ds_2 loadBalanceAlgorithmType: ROUND_ROBIN ms_ds_3: masterDataSourceName: master_ds_3 slaveDataSourceNames: - slave_ds_3 loadBalanceAlgorithmType: ROUND_ROBIN ms_ds_4: masterDataSourceName: master_ds_4 slaveDataSourceNames: - slave_ds_4 loadBalanceAlgorithmType: ROUND_ROBIN ms_ds_5: masterDataSourceName: master_ds_5 slaveDataSourceNames: - slave_ds_5 loadBalanceAlgorithmType: ROUND_ROBIN ms_ds_6: masterDataSourceName: master_ds_6 slaveDataSourceNames: - slave_ds_6 loadBalanceAlgorithmType: ROUND_ROBIN
主节点如果宕机怎么办,可以使用m主+n从模式:
希望对大家理解mysql数据库分片和大批量数据导致数据库瓶颈问题解决有一定的参考意义。
每晚定时任务:对库和表的水位进行自动调整。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。