Sign inSign up

shardingsphere/sharding-proxy

By shardingsphere

Updated over 6 years ago

Distributed database middleware

Image
11

100K+

shardingsphere/sharding-proxy repository overview

NOTE: The 4.x and above version have been transferred to apache/sharding-proxy

Sharding-Sphere is an open-sourced distributed database middleware solution suite, which is composite by Sharding-JDBC, Sharding-Proxy, and Sharding-Sidecar. Those 3 projects provide consistent features which include data sharding, read-write splitting, orchestration and B.A.S.E transaction. They can suitable for various scenarios.

Sharding-Proxy is a database proxy. Deploy as a stateless server, support MySQL protocol for now.

Use standard MySQL protocol, the application does not care about whether proxy or real MySQL.

Any MySQL command line and UI workbench supported in theoretically. MySQL Workbench is fully compatible right now.

Pull Official Docker Clone

docker pull apache/sharding-proxy

Build Docker Clone Manually (Optional)

git clone https://github.com/apache/incubator-shardingsphere
mvn clean install
cd sharding-distribution/sharding-proxy-distribution
mvn clean package docker:build

Configure Sharding-Proxy

Create server.yaml and config-xxx.yaml to configure sharding rules and server rule in /${your_work_dir}/conf/. Please refer to Configuration Manual. Please refer to Example.

Run Docker

docker run -d -v /${your_work_dir}/conf:/opt/sharding-proxy/conf -e PORT=3308 -p13308:3308 apache/sharding-proxy:latest

Notice

  • You can define port 3308 and 13308 by yourself. 3308 refers to docker port; 13308 refers to the host port.
  • You have to volume conf dir to /opt/sharding-proxy/conf.
docker run -d -v /${your_work_dir}/conf:/opt/sharding-proxy/conf -e JVM_OPTS="-Djava.awt.headless=true" -e PORT=3308 -p13308:3308 apache/sharding-proxy:latest

Notice

  • You can define JVM related parameters to environment variable JVM_OPTS.
docker run -d -v /${your_work_dir}/conf:/opt/sharding-proxy/conf -v /${your_work_dir}/ext-lib:/opt/sharding-proxy/ext-lib -p13308:3308 apache/sharding-proxy:latest

Notice

  • If you want to import external jar packages, whose directory is supposed to volume to /opt/sharding-proxy/ext-lib.

Access Sharding-Proxy

It is in the same way as connecting to PostgreSQL.

psql -U ${your_user_name} -h ${your_host} -p 13308

FAQ

Question 1: there is I/O exception (java.io.IOException) when process request to {}->unix://localhost:80: Connection is refused.

Answer: before building a clone, please make sure the docker daemon thread is running.

Question 2: there is an error report of being unable to connect to the database.

Answer: please make sure designated PostgreSQL IP in /${your_work_dir}/conf/config-xxx.yaml configuration is accessible to Docker container.

Question 3:How to start ShardingProxy whose backend databases are MySQL.

Answer:Volume the directory where mysql-connector.jar stores to /opt/sharding-proxy/ext-lib.

Question 4:How to import user-defined sharding strategy?

Answer: Volume the directory where sharding-strategy.jar stores to /opt/sharding-proxy/ext-lib.

Tag summary

Content type

Image

Digest

Size

295.7 MB

Last updated

over 6 years ago

docker pull shardingsphere/sharding-proxy