2025-03-20 17:43:07 +08:00
|
|
|
|
# tmerclub去除分库分表
|
2025-03-19 15:04:57 +08:00
|
|
|
|
|
|
|
|
|
`目前order`、`payment`服务使用sharding-jdbc进行分库分表,如果需要将其恢复改为单库单表,需要做如下操作:
|
|
|
|
|
|
|
|
|
|
1. 原分表的表结构改为单表结构
|
|
|
|
|
|
|
|
|
|
2. nacos中的`xxx.yml`(相关服务的配置文件) 中的多个数据库配置删除,复制一份单库的配置来替换即可
|
|
|
|
|
|
|
|
|
|
3. 更改canal配置
|
|
|
|
|
|
|
|
|
|
4. 移除shardingsphere中间件
|
|
|
|
|
|
2025-03-20 17:43:07 +08:00
|
|
|
|
5. 注释或者删掉对应服务下`tmerclub-common/tmerclub-common-sharding-proxy/src/main/java/com/mall4j/cloud/common/sharding/proxy`包中的sharding配置类
|
2025-03-19 15:04:57 +08:00
|
|
|
|
|
|
|
|
|
## 1. 原分表的表结构改为单表结构
|
|
|
|
|
|
|
|
|
|
连接shardingsphere中的数据库,将对应的分表结构和数据复制到总库中
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
## 2. 将nacos中的`xxx.yml`(相关服务的配置文件) 中的数据库连接换成目前mysql的连接地址,如下图所示:
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 3. 更改canal配置
|
|
|
|
|
|
|
|
|
|
修改服务器部署 `canal/conf/example` 目录下的[instance.properties](../开发环境搭建/中间件docker-compse一键安装/canal/conf/example/instance.properties)
|
|
|
|
|
|
2025-03-20 17:43:07 +08:00
|
|
|
|
将所有`tmerclub_xxx_[0-9]+.xxx_[0-9]+:*` 格式的多库多表数据库配置改为单库单表 `tmerclub_order.order:*`
|
2025-03-19 15:04:57 +08:00
|
|
|
|
|
2025-03-20 17:43:07 +08:00
|
|
|
|
例:将 `tmerclub_order_[0-9]+.order_[0-9]+:*` 改为 `tmerclub_order.order:*`, 其他数据库的同理
|
2025-03-19 15:04:57 +08:00
|
|
|
|
|
|
|
|
|
修改完成后,重启canal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
## 4. 移除shardingsphere中间件
|
2025-03-20 17:43:07 +08:00
|
|
|
|
将tmerclub-shardingsphere这个中间件删除,不部署
|
2025-03-19 15:04:57 +08:00
|
|
|
|
|
2025-03-20 17:43:07 +08:00
|
|
|
|
## 5. 注释或者删掉对应服务下`tmerclub-common/tmerclub-common-sharding-proxy/src/main/java/com/mall4j/cloud/common/sharding/proxy`包中的sharding配置类
|
2025-03-19 15:04:57 +08:00
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|