赞
踩
我使用的docker来进行部署,比较方便
[root@localhost ~]# cd /home/docker/shardingsphere-proxy
[root@localhost shardingsphere-proxy]# ls
conf ext-lib logs
authority:
users:
- user: root@%
password: ~!@#xm
- user: sharding
password: sharding
privilege:
type: ALL_PERMITTED
props:
sql-show: true
#schemaName用来指定->逻辑表名 schemaName: mysql_demo dataSources: write_ds: url: jdbc:mysql://127.0.0.1:3306/mysql_demo?useAffectedRows=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF8 username: root password: ~!@#xm connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 1 read_ds_0: url: jdbc:mysql://127.0.0.1:3307/mysql_demo?useAffectedRows=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF8 username: root password: ~!@#xm connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 1 rules: - !READWRITE_SPLITTING dataSources: readwrite_ds: writeDataSourceName: write_ds readDataSourceNames: - read_ds_0 loadBalancerName: random loadBalancers: random: type: RANDOM
docker run -d -e PORT=3308 -v /mydata/shardingproxy/conf:/opt/shardingsphere-proxy/conf -v /mydata/shardingproxy/ext-lib:/opt/shardingsphere-proxy/ext-lib -v /mydata/shardingproxy/logs:/opt/shardingsphere-proxy/logs --name shardingproxy apache/shardingsphere-proxy:5.4.1
<!--shardingsphere读写分离-->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
#spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mysql_demo?useAffectedRows=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF8
#spring.datasource.username=root
#spring.datasource.password=~!@#xm
spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
spring.datasource.url=jdbc:shardingsphere:classpath:config.yaml
mode: type: Standalone repository: type: JDBC dataSources: ds_0: dataSourceClassName: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/mysql_demo?useAffectedRows=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF8 username: root password: ~!@#xm druid: keep-alive: true max-active: 50 max-wait: 60000 min-evictable-idle-time-millis: 600000 min-idle: 10 test-on-borrow: false test-on-return: false test-while-idle: true time-between-eviction-runs-millis: 60000 validation-query: select 1 ds_1: dataSourceClassName: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.jdbc.Driver url: jdbc:mysql://127.0.0.1:3307/mysql_demo?useAffectedRows=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=UTF8 username: root password: ~!@#xm druid: keep-alive: true max-active: 50 max-wait: 60000 min-evictable-idle-time-millis: 600000 min-idle: 10 test-on-borrow: false test-on-return: false test-while-idle: true time-between-eviction-runs-millis: 60000 validation-query: select 1 rules: - !READWRITE_SPLITTING dataSources: readwrite_ds: writeDataSourceName: ds_0 readDataSourceNames: - ds_1 loadBalancerName: round_robin loadBalancers: round_robin: type: ROUND_ROBIN - !SINGLE tables: - "*.*" # 加载全部单表 props: sql-show: true
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。