87

GitHub - sharding-sphere/sharding-sphere: Distributed database middleware

 5 years ago
source link: https://github.com/sharding-sphere/sharding-sphere
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Sharding-JDBC - Distributed database middleware

License

Maven Status GitHub release Download

Build Status Coverage Status Gitter OpenTracing-1.0 Badge Skywalking Tracing

Overview

Sharding-JDBC is a distributed database middleware, focus on data sharding, read-write splitting, BASE transaction and database orchestration. It provides maximum compatibilities for applications by JDBC driver or database protocols proxy.

Document

EN doc Roadmap

CN doc

Features

1. Data sharding

  • Both databases and tables sharding supported.
  • Standard aggregation functions, GROUP BY, ORDER BY, LIMIT and JOIN DQL supported.
  • Standard DML, DDL, TCL and database administrator command supported.
  • Sharding operator =, BETWEEN and IN supported.
  • Sharding algorithm customization and inline expression supported.
  • Route by hint supported.
  • Distributed sequence supported.

2. Read-write splitting

  • Multiple slaves replica supported.
  • Data consistency guarantee in same thread supported.
  • Mix read-write splitting and data sharding supported.
  • Route by hint supported.

3. BASE Transaction

  • Best efforts delivery transaction supported.
  • Try confirm cancel transaction (TBD).

4. Orchestration

  • Configuration center supported, can refresh dynamically.
  • Circuit breaker supported.
  • Open tracing supported.

Architecture

Sharding-JDBC

Use JDBC connect databases without redirect cost for java application, best performance for production.

  • ORM compatible. JPA, Hibernate, Mybatis, Spring JDBC Template or JDBC supported.
  • Connection-pool compatible. DBCP, BoneCP, Druid supported.
  • Multi SQL-based databases compatible. Any Database supported theoretically. Support MySQL, Oracle, SQLServer and PostgreSQL right now.

Sharding-JDBC Architecture

Sharding-Proxy

Database router. Deploy as a stateless server, support MySQL protocol for now.

  • Use standard MySQL protocol, application do not care about whether proxy or real MySQL.
  • Any MySQL command line and UI workbench supported in theoretically. MySQL Workbench are fully compatible right now.

Sharding-Proxy Architecture

Sharding-Sidecar(TBD)

Use sidecar to connect databases, best for Kubernetes or Mesos together.

Sharding-Sidecar Architecture

Quick Start

Sharding-JDBC

Add maven dependency

<!-- import sharding-jdbc core -->
<dependency>
    <groupId>io.shardingjdbc</groupId>
    <artifactId>sharding-jdbc-core</artifactId>
    <version>${latest.release.version}</version>
</dependency>

Configure sharding rule

Sharding-JDBC support 4 types for sharding rule configuration, they are Java, YAML, Spring namespace and Spring boot starter. Developers can choose any one for best suitable situation.

Create DataSource

Use ShardingDataSourceFactory to create ShardingDataSource, which is a standard JDBC DataSource. Then developers can use it for raw JDBC, JPA, MyBatis or Other JDBC based ORM frameworks.

DataSource dataSource = ShardingDataSourceFactory.createDataSource(dataSourceMap, shardingRuleConfig);

Sharding-Proxy

Configure sharding rule

Edit ${sharding-proxy}\conf\sharding-config.yaml. Same format with Sharding-JDBC-Driver's YAML configuration.

Start server

${sharding-proxy}\bin\start.sh ${port}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK