获取配置的shardingsphere分库分表的数据库链接,并连接每个分库分表执行数据归档逻辑

sharding-sphere读写分离,主从配置,权重配置。 sharding怎么配置读写分离,读写分离不生效怎么办?为什么4.1可以配置读写分离,不能配置权重。5.1版本读写分离不生效 阅读详情

前言

随着分库分表的数据量越来越大,一些无用的数据,比如取消的订单需要删除以减少数据库成本(特殊场景,95%的订单都是已取消的无效订单)。但是shardingsphere自带的查询需要分片键才能出查询对应的分库分表。做数据归档删除的时候没有分片键,直接查询会查询所有的分库分表,性能较差。

shardingsphere配置信息

spring:
  shardingsphere:
    # 参数配置,显示sql
    props:
      sql.show: true
    # 配置数据源
    datasource:
      names: ds1,ds2,ds3,ds4,ds5,ds6,ds7,ds8,ds9,ds10,ds11,ds12,ds13,ds14,ds15,ds16
      ds1:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_1?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds2:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_2?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds3:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_3?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds4:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_4?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds5:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_5?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds6:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_6?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds7:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_7?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds8:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_8?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds9:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_9?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds10:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_10?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds11:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_11?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds12:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_12?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds13:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_13?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds14:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_14?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds15:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_15?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds16:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_16?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true

引入的包

        <!-- 依赖sharding 分库分表 -->
        <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
            <version>4.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>sharding-core-common</artifactId>
            <version>4.1.1</version>
        </dependency>

ShardingSphereDataSourceConfig配置类,获取分库分表的配置信息



import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.apache.shardingsphere.spring.boot.util.PropertyUtil;
import org.apache.shardingsphere.underlying.common.config.inline.InlineExpressionParser;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.StandardEnvironment;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Configuration
public class ShardingSphereDataSourceConfig  implements EnvironmentAware {
    private List<String> names;
    private Map<String, DataSourceProperties> datasource=new HashMap<>();


    public Map<String, DataSourceProperties> getDatasource() {
        return datasource;
    }

    public List<String> getNames() {
        return names;
    }

    @Override
    public void setEnvironment(Environment environment) {
        String prefix = "spring.shardingsphere.datasource.";
        names=this.getDataSourceNames(environment, prefix);
        for (String dataSourceName:
                names) {
            Map<String, Object> dataSourceProps = (Map) PropertyUtil.handle(environment, prefix + dataSourceName.trim(), Map.class);
            DataSourceProperties dataSourceProperties= JSON.parseObject(JSON.toJSONString(dataSourceProps),DataSourceProperties.class);
            datasource.put(dataSourceName,dataSourceProperties);
        }
    }
    private List<String> getDataSourceNames(Environment environment, String prefix) {
        StandardEnvironment standardEnv = (StandardEnvironment)environment;
        standardEnv.setIgnoreUnresolvableNestedPlaceholders(true);
        return null == standardEnv.getProperty(prefix + "name") ? (new InlineExpressionParser(standardEnv.getProperty(prefix + "names"))).splitAndEvaluate() : Collections.singletonList(standardEnv.getProperty(prefix + "name"));
    }
    // 内部类来封装DataSource的配置
    public static class DataSourceProperties {
        private String type;
        private String driverClassName;
        private String url;
        private String username;
        private String password;
        private DruidProperties druid;

        // Getter and Setter
        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getDriverClassName() {
            return driverClassName;
        }

        public void setDriverClassName(String driverClassName) {
            this.driverClassName = driverClassName;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public DruidProperties getDruid() {
            return druid;
        }

        public void setDruid(DruidProperties druid) {
            this.druid = druid;
        }

        // 内部类来封装Druid的配置
        public static class DruidProperties {
            private int initialSize;
            private int maxActive;
            private int minIdle;
            private int maxWait;
            private long minEvictableIdleTimeMillis;
            private boolean useGlobalDataSourceStat;
            private long timeBetweenEvictionRunsMillis;
            private String validationQuery;
            private boolean testOnBorrow;
            private boolean testOnReturn;
            private boolean testWhileIdle;

            // Getter and Setter
            public int getInitialSize() {
                return initialSize;
            }

            public void setInitialSize(int initialSize) {
                this.initialSize = initialSize;
            }

            public int getMaxActive() {
                return maxActive;
            }

            public void setMaxActive(int maxActive) {
                this.maxActive = maxActive;
            }

            public int getMinIdle() {
                return minIdle;
            }

            public void setMinIdle(int minIdle) {
                this.minIdle = minIdle;
            }

            public int getMaxWait() {
                return maxWait;
            }

            public void setMaxWait(int maxWait) {
                this.maxWait = maxWait;
            }

            public long getMinEvictableIdleTimeMillis() {
                return minEvictableIdleTimeMillis;
            }

            public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
                this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
            }

            public boolean isUseGlobalDataSourceStat() {
                return useGlobalDataSourceStat;
            }

            public void setUseGlobalDataSourceStat(boolean useGlobalDataSourceStat) {
                this.useGlobalDataSourceStat = useGlobalDataSourceStat;
            }

            public long getTimeBetweenEvictionRunsMillis() {
                return timeBetweenEvictionRunsMillis;
            }

            public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
                this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
            }

            public String getValidationQuery() {
                return validationQuery;
            }

            public void setValidationQuery(String validationQuery) {
                this.validationQuery = validationQuery;
            }

            public boolean isTestOnBorrow() {
                return testOnBorrow;
            }

            public void setTestOnBorrow(boolean testOnBorrow) {
                this.testOnBorrow = testOnBorrow;
            }

            public boolean isTestOnReturn() {
                return testOnReturn;
            }

            public void setTestOnReturn(boolean testOnReturn) {
                this.testOnReturn = testOnReturn;
            }

            public boolean isTestWhileIdle() {
                return testWhileIdle;
            }

            public void setTestWhileIdle(boolean testWhileIdle) {
                this.testWhileIdle = testWhileIdle;
            }
        }
    }
}

核心代码

@Autowired
    ShardingSphereDataSourceConfig shardingSphereDataSourceConfig;

    //每次执行每个库删除一次
    @Override
    public BaseResponse deleteHis() {
        for (String dataSourceName :
                shardingSphereDataSourceConfig.getNames()) {
            ShardingSphereDataSourceConfig.DataSourceProperties dataSourceProperties = shardingSphereDataSourceConfig.getDatasource().get(dataSourceName);
            try (Connection conn = DriverManager.getConnection(dataSourceProperties.getUrl(), dataSourceProperties.getUsername(), dataSourceProperties.getPassword());
                 Statement stmt = conn.createStatement();) {
                for (int i = 1; i < 16; i++) {
                    String sql = "SELECT order_id FROM order_info_" + i + " WHERE status =10   limit 10" ;
                    ResultSet rs = stmt.executeQuery(sql);
                    StringBuilder sb = new StringBuilder();
                    while (rs.next()) {
                        Long orderId = rs.getLong(1);
                        sb.append(",").append(orderId);
                    }
                    if (sb.length() == 0) {
                        log.info("deleteOrderInfoHis dataSourceName:{},order_info_{},no data need delete", dataSourceName, i);
                        continue;
                    }
                    String orderIds = sb.substring(1);
                    String sqlDeleteOrderInfo = "delete from order_info_" + i + " WHERE order_id in (" + orderIds + ")";
                    stmt.executeUpdate(sqlDeleteOrderInfo);
                    log.info("deleteOrderInfoHis dataSourceName:{},order_info_{},deleteOrderInfoCount:{},orderIds:{}", dataSourceName, i, deleteOrderInfoCount,  orderIds);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                log.error(ex.getMessage(), ex);
                return ResponseUtils.fail(ex.getMessage());
            } finally {

            }
        }
        return ResponseUtils.success();

    }

总结

这里重点是获取配置文件中分库分表的配置。然后调用服务的时候拿到链接配置遍历链接和分表,实现每个分库分表的查询和数据的处理。

17个高频技术模块:构建可执行、可验证的工程化文档系统 技术文档正从静态知识库演进为可运行、可验证、可协同的工程资产。其核心在于将开发者真实故障场景转化为结构化模块,通过机器执行路径组织内容,并嵌入自动化校验机制(如代码块执行、配置生效验证、截图真实性水印)。这种‘文档即代码’范式显著提升知识复用效率与团队认知对齐度,支撑新人快速上手、故障分钟级响应及跨角色协同——17coding正是这一理念的落地实践,以17个经帕累托验证的高频技术场景模块为骨架,实现技术经验的可索引、可版本化、可演进沉淀。 阅读详情

相关推荐

SQL与NoSQL选型不是二选一,而是数据契约设计决策

数据库选型本质是围绕业务数据建模的技术实践,核心在于理解数据关系、查询模式、一致性要求与扩展路径四大维度。SQL以强一致性、声明式JOIN和ACID事务见长,适合金融对账、多表关联分析等场景;NoSQL凭借灵活Schema和水平扩展能力,在高吞吐日志采集、实时推荐缓存等动态场景更具优势。真正决定技术栈的,不是性能参数或流行趋势,而是‘用户收货地址是否需校验邮编’‘订单状态变更能否接受秒级延迟’这类具体业务语义。本文聚焦从需求文档到数据契约落地的实操路径,融合数据一致性、查询模式等关键热词,提供可验证、可审计

weixin_34331102的博客 549

sharding-jdbc 学习 1

shardingsphere官方文档 先看看数据分片 =>数据分片链接 使用基于java编码的规则配置 1 获取Datasource 把截图代码cv过来 稍加改造后 dataSourceUtils 截图: datasources.properties 截图: 数据库 截图 插入6条数据试试 结果: 根...

我是个农民的博客 1023

Spring Boot集成ShardingSphere配合dynamic-datasource进行数据源切换 | Spring Cloud 49

可能存在以下场景:原项目中使用的是dynamic-datasource进行数据源管理,由于项目经历一段时间的线上运行,数据库压力越来越大,计划使用shardingsphere-jdbc进行数据分片或读写分离。

gmHappy 2万+

shardingsphere第一课-前置课程-Mysql的集群搭建以及多数据源管理

不足:dynamic数据源无法保证多个事务情况,但是我们自己也可以拓展,查看源码,他只是针对一个数据源的链接执行的提交事务或者回滚事务,我们可以拓展获取到所有的数据源事务,一起提交或者回滚,MyBatis-Plus框架的开发者就开发了这样的一个框架DynamicDataSource,可以简化多数据源访问的过程。MASTER_HOST对应ip地址,实际是master的mysql。MASTER_LOG_POS对应的游标,从哪复制主数据,看2.5。MASTER_USER配置的master上的从用户,

qq_39944028的博客 1058

【信息科学与工程学】计算机科学与自动化——第八十一篇 Java分布式软件高并发/高可用算法01

4. 消息队列(如Kafka的Topic分区,本质是范围)。3. 若是ACCEPT事件,bossGroup线程接受连接,创建SocketChannel,并将其注册到workerGroup的一个EventLoop的Selector上,关注READ事件。1. 分布式缓存分片(如Redis Cluster)。4. 分布式文件存储(如Ceph CRUSH)。6. 调用栈的模拟(如协程)。3. 服务网格(如Istio)的基础。2. 本地缓存与集中式缓存(如Redis)的一致性维护。3. 静态数据(如配置)缓存。

weixin_49199313的博客 1233

企业级Windows 10镜像封装实战:从规划到部署的完整指南

系统部署与镜像封装是企业IT运维中的核心基础技术,其原理在于通过创建预配置的系统模板,实现大规模计算机环境的快速、标准化部署。这项技术的核心价值在于将重复性手动操作转化为自动化流程,显著提升运维效率,保障环境一致性,并强化安全基线管理。在实际应用场景中,它尤其适用于新设备批量初始化、系统恢复和标准化环境构建。本文聚焦于Windows 10镜像的封装实践,深入探讨了使用Sysprep进行系统通用化处理以及通过DISM工具捕获WIM格式镜像的具体方法,为企业IT人员提供从零构建标准化系统镜像的完整路径。

weixin_33843947的博客 356

shardingsphere分库分表集成多数据源

如果有分库分表,又有切换数据源的需求可以使用多数据源dynamic-datasource与shardingsphere集成的场景方案。3、添加一个多数据测试库yz-order和表sys_order。新增yz-log数据库和oper_log_xxx四张表。入到yz-log库oper_log_delete表。入到yz-log库oper_log_post表。入到yz-log库oper_log_get表。入到yz-log库oper_log_put表。入到yz-order库sys_order表。

扭曲的影子 6708

On the convergence of FedAvg on non-iid data

On the convergence of FedAvg on non-iid data

Lyn_S的博客 7081

后端笔记09 | ShardingSphere+MyBatis-Plus分库分表代码实践

ShardingSphere分库分表基础知识和代码实践

2201_75974870的博客 1370

别再手动对照了!用Python+ArcGIS Pro一键搞定三调数据转土地三大类

本文介绍如何利用Python和ArcGIS Pro实现三调数据向土地三大类的自动化转换,大幅提升国土空间规划和土地变更调查的工作效率。通过封装分类规则为Python函数并集成到ArcGIS Pro脚本工具中,解决了传统手动操作耗时且易错的问题,适用于大规模数据处理场景。

weixin_29081101的博客 304

Three 之 three.js (webgl)绘制物体模型尺寸虚线包围框工具简单封装 DashLinesBoxTool

Three js 开发的一些知识整理,方便后期遇到类似的问题,能够及时查阅使用。本节介绍, three.js (webgl) 中绘制物体模型尺寸虚线包围框工具简单封装 DashLinesBoxTool,主要是给实物绘制线框,有点像AI 识别正方形包裹框的效果。其中,如果有不足之处,欢迎指出,或者你有更好的方法,欢迎留言。

仙魁XAN 2106

数据库分库分表终极指南:10个水平扩展完整方案

数据库分库分表是后端系统应对高并发、海量数据的核心技术,本文将系统讲解水平扩展的10种实现方案,帮助开发者彻底解决数据存储瓶颈。通过ShardingSphere等工具的实战配置,结合垂直分片与水平分片策略,让你的数据库架构具备无限扩展能力。 ## 为什么需要分库分表? 当单表数据量超过1000万行,数据库性能会急剧下降。关系型数据库的B+树索引深度增加导致IO次数飙升,高并发查询更是让数据库成

gitblog_00083的博客 331

基于经验模态分解和核主成分分析结合长短期记忆网络EMD-KPCA-LSTM的光伏功率预测算法--Matlab

基于经验模态分解和核主成分分析结合长短期记忆网络EMD-KPCA-LSTM的光伏功率预测算法--Matlab

前程算法屋的博客 626

MySQL:MySQL 语法速查 / MySQL 核心知识技能梳理 / 数据库/MySQL = 一个“超级 Excel“,存数据的地方

MySQL语法全面指南(增强版) 本文系统梳理了MySQL数据库的核心语法和高级特性,涵盖以下主要内容: 数据库操作 创建/删除数据库(含字符集设置) 数据库修改与查看命令 表操作 完整建表语法(包含约束、索引、分区表) 数据类型详解(JSON、空间数据等新特性) 表结构修改方法 数据CRUD 增强版INSERT/UPDATE语法 复杂查询技巧(窗口函数、子查询优化) 连接查询与事务控制 性能优化 索引类型与使用场景 查询优化建议(EXPLAIN分析、索引覆盖等) 锁机制与事务隔离级别 高级特性 存储过程/

snow的博客 603

华为OD机试真题 新系统 2026-08-16 Python&JS【智能家居模式调度优化】

智能家居系统中有多个自动化联动模式,每个模式 modes[i]=[start_time,end_time,power],表示它在左闭右开区间 [start_time,end_time) 内持续消耗固定功率 power。

MISAYAONE的博客 85

MATLAB基础应用精讲-【强化学习】Actor - Critic 算法(附python代码实现)

这种架构结合了策略梯度方法(Policy - Gradient Methods)和价值函数估计方法(Value Function Estimation Methods)的优点。在强化学习中,智能体(Agent)需要通过与环境(Environment)的交互来学习最优的行为策略,以获得最大的累积奖励(Cumulative Reward)。

qq_36130719的博客 363

MySQL 入门

本文全面介绍了MySQL数据库及其相关技术,内容涵盖: 数据库基础概念:包括数据库系统组成、关系型与非关系型数据库对比、MySQL核心特点等; MySQL操作管理:详细讲解了安装配置、SQL语句分类、数据类型、索引原理等核心内容; 高级特性:深入分析事务、锁机制、存储引擎、主从复制等关键特性; 扩展架构:系统介绍了读写分离、集群部署、分库分表等企业级解决方案; 开发集成:提供了JDBC连接、MyCat中间件等实践指南。 文章采用结构化组织方式,从基础到高级层层递进,包含了大量实用性强的代码示例和配置模板

weixin_51689532的博客 1243

HALCON机器视觉之结合LMI Gocator 5504进行手机折叠屏异物、折痕和胶体检测(基于C# + HALCON)

手机折叠屏是一种创新的屏幕技术,它允许屏幕在一定程度上进行折叠,从而在便携性和屏幕尺寸之间取得平衡。这种屏幕通常由多层材料组成,包括柔性显示层、保护层和胶水层等。本文将详细介绍如何使用C#编程语言,结合HALCON和LMI Gocator 5504来实现手机折叠屏的异物、折痕和胶体检测。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 9321

MySQL面试集合

当并发系统中不同线程出现循环资源依赖,涉及的线程都在等待别的线程释放资源时,就会导致这几个线程都进入无限等待的状态,称为死锁。

qq_74156239的博客 1230

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

系统架构设计师2026年5月高分论文-论高并发系统性能优化方案设计与实践

第三阶段聚焦流量削峰与弹性伸缩。最终在2024年春季高考实战中,系统平稳承载峰值15.3万次/秒请求(较2023年增长19.5%),平均响应时间稳定在320ms(P99≤890ms),资源成本反降23%(通过HPA精准扩缩容减少冗余节点)。本项目通过引入异步消息队列(Kafka)、本地缓存(Caffeine)与分布式缓存(Redis集群)、数据库读写分离及连接池优化,系统平均响应时间由1.8s降至280ms,QPS从1200提升至9600,高峰期错误率由3.7%压降至0.12%,服务可用性达99.99%。

一步一个脚印,踏实努力,向着目标前进 689

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

从超时到硬核优化:全链路性能诊断与实战调优指南

在软件工程实践中,性能优化是提升系统响应能力和用户体验的核心环节。其原理在于通过系统化的方法识别和消除瓶颈,涉及算法效率、资源管理和架构设计等多个层面。优化的技术价值在于能够显著降低延迟、提高吞吐量,并增强系统的可扩展性与稳定性。常见的应用场景包括高并发接口、大数据量处理以及实时系统等。本次探讨聚焦于立体化性能诊断,运用APM工具与Profiler进行深度剖析,并结合JVM调优与缓存策略,系统解决从数据库访问到内存管理的复合型性能问题,实现从被动修复到主动优化的思维跃迁。

weixin_30323631的博客 300

Mysql

本文总结了MySQL核心知识点,包括索引、事务、存储引擎和分库分表等关键技术要点: 索引机制:重点分析了B+Tree索引结构、索引失效场景(如函数操作、模糊查询等)、最左匹配原则以及索引创建的最佳实践。 事务特性:详细解析了ACID的实现原理,包括MVCC+Read View机制、四种隔离级别的差异,以及redo log/undo log/binlog的协同工作原理。 存储引擎对比:深入比较了InnoDB和MyISAM的核心差异,包括事务支持、锁粒度、索引结构等关键特性。 分库分表策略:系统梳理了分库分表的

qq_41893505的博客 895

程序员专业成长闭环:博客、论坛与知识沉淀的实操方法论

技术博客不是个人日记,而是将工程实践转化为可验证知识的关键环节;论坛也不是问答工具,而是检验技术认知真实性的压力测试场。理解‘问题树’结构、掌握‘三阶交付物’标准、建立‘反脆弱性’检验机制,是程序员从任务执行者跃迁为问题定义者的核心路径。本文聚焦程序员如何通过博客写作、论坛互动与系统化知识管理,构建可持续演进的专业能力体系,涵盖Spring Boot多数据源、Redis缓存穿透、K8s Pod启动优化等高频实战场景,并自然融入‘程序员’‘博客’‘论坛’‘个人知识提升’等热词,提供可立即落地的技术成长引擎。

SailingAptech的专栏 465

shardingsphere5.x整合springboot+dynamic-datasource多数据源实战

shardingsphere,分库分表,多数据源

任人人人呢的博客 1万+

ShardingSphere5.3.0配置单数据源分表

ShardingSphere5.3.0配置单数据源分表

StruggleRookie的博客 775

ShardingJdbc分库分表+连表查询(超简单)

这边建议所有的依赖版本都和我同步,因为我被版本冲突折磨了好久...

Diyu0904的博客 3362
上一篇: python爬取网页接口数据,以yearning为例
下一篇: python查询日志,并组装sql,修复缺失的数据
bxp1321
博客等级 码龄17年 146粉丝 86原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值