1. Overview
Sharding-Proxy is one of the core products in the Apache ShardingSphere ecosystem, using a transparent database proxy architecture.
Core Features:
- Protocol Compatibility: Supports MySQL/PostgreSQL and other mainstream database protocols
- Transparent Proxy: Mimics as a real database instance
- Independent Deployment: Runs as an independent database proxy service
- Rich Features: Provides enterprise-level features like read-write separation, distributed transactions, data encryption, etc.
2. Core Features
1. Protocol Compatibility
- Supports MySQL 5.1/5.5/5.6/5.7/8.0 versions
- Fully compatible with MySQL’s binary and text protocols
2. Client Support
- Command-line tools: mysql client
- GUI tools: MySQL Workbench, Navicat, DBeaver
- Programming language drivers: JDBC, Python MySQL Connector, PHP PDO, etc.
3. Transparent Design
- SQL parsing, routing, execution, result merging processes are completely transparent to applications
- Supports all MySQL syntax
3. Typical Use Cases
- Database Sharding Management: Horizontal sharding for existing MySQL clusters
- Multi-Tenant Systems: Implement tenant isolation through logical databases/logical tables
- Database Middleware Upgrade: Replace traditional application-layer sharding solutions
- Heterogeneous Language Support: Provide sharding capabilities for PHP, Python, Go and other non-Java languages
4. Comparison
| Feature | Sharding-Proxy | Traditional Middleware | Application-Layer Sharding |
|---|---|---|---|
| Protocol Transparency | ✓ | ✗ | ✗ |
| Multi-Language Support | ✓ | ✗ | ✗ |
| Zero Code Invasion | ✓ | ✗ | ✗ |
| O&M Complexity | Low | Medium | High |
5. Usage Guide
1. Configuration File Modification
Example configuration (server.yaml):
authentication:
users:
root:
password: root
props:
max.connections.size.per.query: 5
proxy.transaction.type: LOCAL
proxy.hint.enable: true
2. Start Service
- Linux system:
bin/start.sh - Windows system:
bin\start.bat - Default port: 3307
3. Client Connection
mysql -h 127.0.0.1 -P 3307 -u root -p
6. Notes
- Hint Function: Disabled by default, need to modify
conf/server.yaml - Port Configuration: Default port 3307, can be modified via startup parameters
- Multiple Logical Data Sources: Configuration files must be named starting with “config-”