Nacos 从 2.2.0 版本开始,可通过 SPI 机制注入多数据源实现插件,并在引入对应数据源实现后,便可在 Nacos 启动时通过读取 application.properties 配置文件中 spring.datasource.platform 配置项选择加载对应多数据源插件.

pig-register nacos 支持达梦存储 - 图1

Nacos 官方默认实现 MySQL、Derby ,其他类型数据库接入需要参考下文自己扩展。

pig-register nacos 支持达梦存储 - 图2

自定义 dm8 插件

1.增加 dm8 数据库插件

依赖已上传 maven 中央仓库,请勿使用阿里云代理

  1. <!--达梦数据库插件-->
  2. <dependency>
  3. <groupId>com.pig4cloud.plugin</groupId>
  4. <artifactId>nacos-datasource-plugin-dm8</artifactId>
  5. <version>0.0.1</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>com.dameng</groupId>
  9. <artifactId>DmJdbcDriver18</artifactId>
  10. <version>8.1.1.193</version>
  11. </dependency>

2.导入 nacos dm8 数据库脚本

再达梦数据库管理工具上创建名为 nacos 的表空间,导入一下数据库脚本
数据库脚本

3.配置 nacos 数据源链接信息

  1. db:
  2. num: 1
  3. url:
  4. 0: jdbc:dm://172.27.0.5:5236/nacos
  5. user: nacos
  6. password: nacos@123
  7. pool:
  8. config:
  9. driver-class-name: dm.jdbc.driver.DmDriver

4.配置数据库平台

  1. spring:
  2. datasource:
  3. platform: dameng

pig-register nacos 支持达梦存储 - 图3

源码地址: https://github.com/pig-mesh/nacos-datasource-plugin-dm8