1.进入https://www.apache.org/dyn/closer.cgi?path=incubator/shardingsphere/4.0.0-RC3/apache-shardingsphere-incubating-4.0.0-RC3-sharding-proxy-bin.tar.gz下载压缩包
2.解压缩
Linux下可直接使用tar -zxvf解压。
windows环境,请使用tar zxvf解压,不要使用压缩工具,否则可能出现bin文件夹中的.jar由于名称太长而被截断,如下图所示。

导致启动start.bat/start.sh失败。如下图所示

3.目录结构

- bin里面包含start/stop脚本
- conf包含配置文件,其中server
- lib包含系统及其依赖的jar包(缺少数据库驱动jar)
- 运行bin里面的start.sh/start.bat后会生成logs,里面包含运行日志
4.修改conf下的配置文件(其中server.yaml必须修改)
- server.yaml中包含orchestration(注册中心配置),authentication(连接proxy时使用的用户名&密码及其访问权限),props(proxy基本配置)
orchestration:
name: orchestration_ds
overwrite: true
registry:
type: zookeeper
serverLists: localhost:2181
namespace: orchestration
authentication:
users:
root:
password: root
sharding:
password: 123
authorizedSchemas: sharding_db
props:
max.connections.size.per.query: 1
acceptor.size: 16 # The default value is available processors count * 2.
executor.size: 16 # Infinite by default.
proxy.frontend.flush.threshold: 128 # The default value is 128.
# LOCAL: Proxy will run with LOCAL transaction.
# XA: Proxy will run with XA transaction.
# BASE: Proxy will run with B.A.S.E transaction.
proxy.transaction.type: LOCAL
proxy.opentracing.enabled: false
proxy.hint.enabled: false
query.with.cipher.column: true
sql.show: false
- config-proxy.yaml包含schemaName(proxy对外提供的库名),dataSources(数据源配置),shardingRule(路由配置),这里我已单库单表为例,使用分库分表可自行更改配置文件
schemaName: default_db
dataSources:
FenqileDB:
url: jdbc:mysql://127.0.0.1:3306/synchronization_db?serverTimezone=UTC&useSSL=false
username: root
password: 123
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
shardingRule:
tables:
t_default:
actualDataNodes: default_db.t_synchronization
5.向lib中加入数据库驱动
我使用的是mysql数据库,故加入mysql驱动jar,如下图所示

6.运行
运行start.sh脚本,进入logs查看日志

ACTIVE表示启动成功