hanbo-jdbc是一个springbootStarter,适用于mysql5.7+的群组复制(单主模式)
基于connector/J的mysqlx、replication等协议实现的客户端自动选主以及负载均衡。 源码请移步
打包
cd proDir && mvn clean install
添加maven依赖:
<dependency>
<groupId>com.lmx</groupId>
<artifactId>hanbo-starter</artifactId>
<version>0.0.2-snapshot</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
springboot配置:
application.properties
cj.replicationUrl=jdbc:mysql:replication://address=(type=master)(host=192.168.32.128)(port=24802),address=(type=slave)(host=192.168.32.128)(port=24801),address=(type=slave)(host=192.168.32.128)(port=24803)/test?useSSL=false&autoReconnect=true
cj.userName=root
cj.passWord=root
cj.driverClass=com.mysql.cj.jdbc.Driver
cj.maxWait=10000
cj.maxConn=64
cj.failoverUrl=jdbc:mysql://192.168.32.128:24801,192.168.32.128:24802,192.168.32.128:24803/test?characterEncoding=UTF-8&useSSL=false