下载shardingsphere-proxy
wget https://mirrors.bfsu.edu.cn/apache/shardingsphere/5.0.0-alpha/apache-shardingsphere-5.0.0-alpha-shardingsphere-proxy-bin.tar.gz
其他版本自行官网下载
拷贝合适的驱动包到工程lib目录下
(下载地址:https://repo1.maven.org/maven2/mysql/mysql-connector-java/)
pgsql不需要引入
修改配置文件
server.yaml
authentication: #shardingsphere-proxy自身的用户设置
users:
root:
password: root
添加配置文件,并清空其他config开头的配置文件(默认情况都是注释的,不需要更改)
config-demo.yaml
schemaName: sharding_db
dataSourceCommon: #datasources通用配置
username: root
password: root
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
maintenanceIntervalMilliseconds: 30000
dataSources:
ds_0:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
直接启动即可
bin下的start.sh