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

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

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

|
|||
|
|
|||
|
## 4. 移除shardingsphere中间件
|
|||
|
将mall4cloud-shardingsphere这个中间件删除,不部署
|
|||
|
|
|||
|
## 5. 注释或者删掉对应服务下`mall4cloud-common/mall4cloud-common-sharding-proxy/src/main/java/com/mall4j/cloud/common/sharding/proxy`包中的sharding配置类
|
|||
|

|
|||
|
|
|||
|
|