开放代码社区 › sharding-sphere

sharding-sphere

基础设施与运维Java

Apache ShardingSphere - 企业级分布式数据库生态系统 构建异构数据库上层的标准与生态,赋能企业数据架构数字化转型 Apache ShardingSphere 定位为 Database Plus ,是构建在异构数据库上层的标准与生态系统。作为数据库上层的操作系统,ShardingSphere 并非创造全新的数据库,而是专注于最大化现有数据库的计算能力,提供统一的数据访问入口和增强计算能力。 Database Plus 核心理念 :通过在数据库上层构建标准化、可扩展的增强层,让异构数据库像单一数据库一样简单使用,为企业数据架构提供统一的治理能力和分布式计算能力。

AI/机器学习Web后端前端数据库部署/运维
作者:用户6868语言:Java更新:2026-10-27
仓库地址
https://gitee.com/Sharding-Sphere/sharding-sphere.git

前往原仓库

README

## [Apache ShardingSphere - 企业级分布式数据库生态系统](https://shardingsphere.apache.org/index_zh.html)

构建异构数据库上层的标准与生态,赋能企业数据架构数字化转型

**官方网站: https://shardingsphere.apache.org/**

[![GitHub release](https://img.shields.io/github/release/apache/shardingsphere.svg)](https://github.com/apache/shardingsphere/releases)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=apache_shardingsphere&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=apache_shardingsphere)

[![CI](https://github.com/apache/shardingsphere/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/shardingsphere/actions/workflows/ci.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=apache_shardingsphere&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=apache_shardingsphere)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=apache_shardingsphere&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=apache_shardingsphere)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=apache_shardingsphere&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=apache_shardingsphere)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=apache_shardingsphere&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=apache_shardingsphere)
[![codecov](https://codecov.io/gh/apache/shardingsphere/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/shardingsphere)

[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/5394/badge)](https://bestpractices.coreinfrastructure.org/projects/5394)

[![Gitter](https://badges.gitter.im/shardingsphere/shardingsphere.svg)](https://gitter.im/shardingsphere/Lobby)

[![X](https://img.shields.io/twitter/url/https/twitter.com/ShardingSphere.svg?style=social&label=Follow%20%40ShardingSphere)](https://x.com/ShardingSphere)

<table style="width:100%">
    <tr>
        <th>
            <a href="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map?activity=stars&repo_id=49876476" target="_blank" style="display: block" align="center">
                <picture>
                    <source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?activity=stars&repo_id=49876476&image_size=auto&color_scheme=dark" width="721" height="auto">
                    <img alt="Star Geographical Distribution of apache/shardingsphere" src="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?activity=stars&repo_id=49876476&image_size=auto&color_scheme=light" width="721" height="auto">
                </picture>
            </a>
        </th>
        <th>
            <a href="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map?activity=pull-request-creators&repo_id=49876476" target="_blank" style="display: block" align="center">
                <picture>
                    <source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?activity=pull-request-creators&repo_id=49876476&image_size=auto&color_scheme=dark" width="721" height="auto">
                    <img alt="Pull Request Creator Geographical Distribution of apache/shardingsphere" src="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?activity=pull-request-creators&repo_id=49876476&image_size=auto&color_scheme=light" width="721" height="auto">
                </picture>
            </a>
        </th>
        <th>
            <a href="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map?activity=issue-creators&repo_id=49876476" target="_blank" style="display: block" align="center">
                <picture>
                    <source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?activity=issue-creators&repo_id=49876476&image_size=auto&color_scheme=dark" width="721" height="auto">
                    <img alt="Issue Creator Geographical Distribution of apache/shardingsphere" src="https://next.ossinsight.io/widgets/official/analyze-repo-stars-map/thumbnail.png?activity=issue-creators&repo_id=49876476&image_size=auto&color_scheme=light" width="721" height="auto">
                </picture>
            </a>
        </th>
    </tr>
</table>

### 概述

<hr>

Apache ShardingSphere 定位为 **Database Plus**,是构建在异构数据库上层的标准与生态系统。作为数据库上层的操作系统,ShardingSphere 并非创造全新的数据库,而是专注于最大化现有数据库的计算能力,提供统一的数据访问入口和增强计算能力。

**Database Plus 核心理念**:通过在数据库上层构建标准化、可扩展的增强层,让异构数据库像单一数据库一样简单使用,为企业数据架构提供统一的治理能力和分布式计算能力。

**连接、增强、可插拔** 是 Apache ShardingSphere 的三大核心支柱:

- **连接:** 构建数据库上层标准,通过灵活适配数据库协议、SQL 方言和存储格式,快速连接应用与多模式异构数据库,提供统一的数据访问体验;

- **增强:** 作为数据库计算增强引擎,透明化提供分布式计算(数据分片、读写分离、联邦查询)、数据安全(加密、脱敏、审计)、流量控制(熔断、限流)以及可观测性(监控、追踪、分析)等企业级能力;

- **可插拔:** 采用微内核 + 三层可插拔架构,实现内核、功能组件与生态对接的完全解耦,开发者可以像搭建积木一样,灵活定制符合企业需求的独特数据架构解决方案。

**差异化优势**:
- **vs 分布式数据库**:更轻量级、保护现有投资、避免厂商锁定
- **vs 传统中间件**:功能更丰富、生态更完善、架构更灵活
- **vs 云厂商方案**:支持多云部署、避免技术绑定、自主可控

ShardingSphere 于 2020 年 4 月 16 日成为 [Apache 软件基金会](https://apache.org/index.html#projects-list) 顶级项目,已在全球范围内被 [19,000+ 项目](https://github.com/search?l=Maven+POM&q=shardingsphere+language%3A%22Maven+POM%22&type=Code)采用。

### 双接入端架构设计

<hr>

ShardingSphere 采用独特的双接入端架构设计,提供 JDBC 和 Proxy 两种既可独立部署又可混合部署的接入端,满足不同场景下的多样化需求。

#### ShardingSphere-JDBC:轻量级接入端

**定位**:轻量级 Java 框架,增强版 JDBC 驱动

**核心特性**:
- **客户端直连**:与应用程序共享资源,无中心化架构
- **高性能低损耗**:直接数据库连接,性能损耗最小
- **完全兼容**:兼容所有 ORM 框架(MyBatis、JPA、Hibernate 等)
- **零额外部署**:以 JAR 包形式提供,无需独立部署和依赖

**适用场景**:Java 高性能应用,与业务应用集成部署,追求极致性能

#### ShardingSphere-Proxy:企业级接入端

**定位**:透明化数据库代理,独立部署的服务端

**核心特性**:
- **静态入口**:独立于应用程序部署,提供稳定的数据库访问入口
- **异构语言支持**:支持任意兼容 MySQL/PostgreSQL 协议的客户端
- **DBA 友好**:数据库运维管理界面,便于运维人员操作
- **企业级特性**:支持集群部署、负载均衡、故障转移

**适用场景**:异构语言环境、数据库运维管理、需要统一访问入口的企业级应用

#### 混合架构优势

通过混合使用 ShardingSphere-J