方便更快捷的说明问题,可以按需填写(可删除)
使用环境:
shardingshere 5.4.1
mysql 5.7.44
场景、问题:
同时创建了业务库和影子库(ds用多少实例3306,ds_shadow用的是实例3307)。config-shadow.yaml的配置如下:
databaseName: demo
dataSources:
ds:
url: jdbc:mysql://192.168.40.150:3306/ds0?serverTimezone=UTC&useSSL=false
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
shadow_ds:
url: jdbc:mysql://192.168.40.150:3307/ds1?serverTimezone=UTC&useSSL=false
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !SINGLE
tables:- “.”
- !SHADOW
dataSources:
shadowDataSource:
productionDataSourceName: ds
shadowDataSourceName: shadow_ds
shadowAlgorithms:
sql_hint_algorithm:
type: SQL_HINT
props:
foo: true
server.yaml中已经开启了qlCommentParseEnabled。
sqlParser:
sqlCommentParseEnabled: true
sqlStatementCache:
initialCapacity: 2000
maximumSize: 65535
parseTreeCache:
initialCapacity: 128
maximumSize: 1024
已进行操作:
启动shardingshere-poxy, 通过3307端口连上去,use demo,执行如下sql语句
INSERT INTO Users
(Id,Username,Password,UserDisplayName,Email,Enabled) VALUES (3,‘test3’,’{bcrypt}$2a$10$wpaFwp1jB5AWyBROGOz5UeqDhTPzOxEABoz4JCX8H5.svCQbvrQ1S’,‘test3’,‘test3@tom.com’,1)/foo: true/;
现状:
发现数据没有写入到影子库中。