Yule-Momoko commented on issue #28841:
URL:
https://github.com/apache/shardingsphere/issues/28841#issuecomment-1774377459
> @Yule-Momoko能提供一下你的分片配置和建表sql吗?
Only read and write separation is configured:
dataSources:
write-ds-1:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url:
'jdbc:mysql://writexxxx:3306/test?serverTimezone=Asia/Shanghai&autoReconnect=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true&allowMultiQueries=true'
username: xxx
password: xxx
write-ds-1-read:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url:
'jdbc:mysql://readxxx:3306/test?serverTimezone=Asia/Shanghai&autoReconnect=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=true&allowMultiQueries=true'
username: xxx
password: xxx
rules:
#读写分离配置
- !READWRITE_SPLITTING
dataSources:
# 读写分离逻辑数据源名称
ds1:
writeDataSourceName: write-ds-1
readDataSourceNames:
- write-ds-1-read
transactionalReadQueryStrategy: PRIMARY
loadBalancerName: round_robin
# 负载均衡算法配置
loadBalancers:
# 负载均衡算法名称
round_robin:
# 负载均衡算法类型
type: ROUND_ROBIN
props:
sql-show: true
table init:
CREATE TABLE `table_a` (
`ID` bigint NOT NULL,
`CD` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL
DEFAULT '' COMMENT '代码',
`NM` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT ''
COMMENT '名称',
`INNER_FLAG` tinyint(1) NOT NULL DEFAULT '0' COMMENT '',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='';
CREATE TABLE `table_b` (
`ID` bigint NOT NULL,
`A_ID` bigint NOT NULL,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
COMMENT='TABLE_B';
INSERT INTO `g_master`.`table_a` (`ID`, `CD`, `NM`, `INNER_FLAG`) VALUES
(1322001820620427265, '123', '测试', 0);
INSERT INTO `g_master`.`table_b` (`ID`, `A_ID`) VALUES (1325670582607421443,
1322001820620427265);
query sql:
SELECT a.INNER_FLAG, b.*
FROM table_a a
LEFT JOIN table_b b ON b.a_id = a.ID
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]