ShardingSphere 4.x -Sharding-Proxy-Manual
Introduction
Sharding-Proxy is the second product of ShardingSphere. It defines itself as a transparent database proxy, providing a database server that encapsulates database binary protocol to support heterogeneous languages. Friendlier to DBA, the MySQL/PostgreSQL version provided now can use any kind of terminal (such as MySQL Command Client, MySQL Workbench, etc.) that is compatible with MySQL protocol to operate data.
- Totally transparent to applications, it can be used directly as MySQL/PostgreSQL.
- Applicable to any kind of client end that is compatible with MySQL/PostgreSQL protocol.
Comparison
The advantages of Sharding-Proxy lie in supporting heterogeneous languages and providing operational entries for DBA.
Proxy Initialization
- Download the latest version of Sharding-Proxy.
- If users use docker, they can implement
docker pull shardingsphere/sharding-proxy
to get the clone. Please refer to Docker Clone for more details. - After the decompression, revise
conf/server.yaml
and documents begin withconfig-
prefix,conf/config-xxx.yaml
for example, to configure sharding rules and read-write split rules. Please refer to Configuration Manual for the configuration method. - Please run
bin/start.sh
for Linux operating system; runbin/start.bat
for Windows operating system to start Sharding-Proxy. To configure start port and document location, please refer to Quick Start. - Use any PostgreSQL server client end to connect, such as
psql -U root -h 127.0.0.1 -p 3307
.
Use of Registry Center
If users want to use the database orchestration function of Sharding-Proxy, they need to implement instance disabling and slave database disabling functions in the registry center. Please refer to Available Registry Centers for more details.
Zookeeper
Sharding-Proxy has provided the registry center solution of Zookeeper in default. Users only need to follow Configuration Rules to set the registry center and use it.
Other Third Party Registry Center
- Delete
sharding-orchestration-reg-zookeeper-curator-${sharding-sphere.version}.jar
under the lib catalog of Sharding-Proxy. - Use SPI methods in logic coding and put the generated jar package to the lib catalog of Sharding-Proxy.
- Follow Configuration Rules to set the registry center and use it.
Distributed Transactions
Sharding-Proxy supports LOCAL, XA, BASE transactions, LOCAL transaction is default value, it is original transaction of relational database.
XA transaction
Default XA transaction manager of ShardingSphere is Atomikos. Users can customize Atomikos configuration items through adding jta.properties
in conf catelog of Sharding-Proxy. Please refer to Official Documents of Atomikos for detailed configurations.
BASE Transaction
Since we have not pack the BASE implementation jar into Sharding-Proxy, you should copy relevant jar which implement ShardingTransactionManager
SPI to conf/lib
, then switch the transaction type to BASE
.
SCTL (Sharding-Proxy control language)
SCTL supports modify and query the state of Sharing-Proxy at runtime. The current supported syntax is:
Sharding-Proxy does not support hint by default, to support it, set the props
property proxy.hint.enabled
to true in conf/server.yaml.In Sharding-Proxy. In Sharding-Proxy, the generic of HintShardingAlgorithm can only be a String type.
Notices
- Sharding-Proxy uses 3307 port in default. Users can start the script parameter as the start port number, like
bin/start.sh 3308
. - Sharding-Proxy uses
conf/server.yaml
to configure the registry center, authentication information and public properties. - Sharding-Proxy supports multi-logic data source, with each yaml configuration document named by
config-
prefix as a logic data source.