├── .github
└── workflows
│ ├── github-release.yml
│ └── maven.yml
├── .gitignore
├── .springjavaformatconfig
├── README.md
├── pom.xml
└── src
└── main
├── java
└── com
│ └── pig4cloud
│ └── plugin
│ ├── constants
│ └── DataSourceConstant.java
│ └── impl
│ └── dm
│ ├── ConfigInfoBetaMapperByDm.java
│ ├── ConfigInfoGrayMapperByDm.java
│ ├── ConfigInfoMapperByDm.java
│ ├── ConfigInfoTagMapperByDm.java
│ ├── ConfigTagsRelationMapperByDm.java
│ ├── DmAbstractMapper.java
│ ├── GroupCapacityMapperByDm.java
│ ├── HistoryConfigInfoMapperByDm.java
│ ├── TenantCapacityMapperByDm.java
│ └── TenantInfoMapperByDm.java
└── resources
└── META-INF
└── services
└── com.alibaba.nacos.plugin.datasource.mapper.Mapper
/.github/workflows/github-release.yml:
--------------------------------------------------------------------------------
1 | name: publish github release
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | releaseversion:
7 | description: 'Release version'
8 | required: true
9 | default: '0.4.0'
10 |
11 |
12 | jobs:
13 | publish-github-release:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/checkout@v4
17 |
18 | - name: Create GitHub Release
19 | id: create_release
20 | uses: actions/create-release@v1
21 | env:
22 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
23 | with:
24 | tag_name: ${{ github.event.inputs.releaseversion }}
25 | release_name: ${{ github.event.inputs.releaseversion }}
26 | body: |
27 | ### Things that changed in this release
28 | ${{ steps.changelog.outputs.changelog }}
29 | draft: false
30 | prerelease: ${{ contains(github.event.inputs.releaseversion, '-') }}
31 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: nacos-datasource-plugin-pg
5 |
6 | on:
7 | push:
8 | branches: [ master,dev ]
9 | pull_request:
10 | branches: [ master,dev ]
11 |
12 | jobs:
13 | build:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/checkout@v2
17 | - name: Set up JDK 8
18 | uses: actions/setup-java@v2
19 | with:
20 | java-version: '8'
21 | distribution: 'adopt'
22 |
23 | - name: mvn clean install
24 | run: mvn clean install
25 |
26 | - name: mvn spring-javaformat:validate
27 | run: mvn spring-javaformat:validate
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/.springjavaformatconfig:
--------------------------------------------------------------------------------
1 | java-baseline=8
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Nacos 达梦数据库插件
2 |
3 | [](https://maven.badges.herokuapp.com/maven-central/com.pig4cloud.plugin/nacos-datasource-plugin-dm8)
4 | [](https://opensource.org/licenses/Apache-2.0)
5 |
6 | ## 项目介绍
7 |
8 | 本插件为 Nacos(2.2.0 版本及以上)提供达梦数据库(DM8)的数据源支持。通过 SPI 机制实现,您只需在 `application.properties` 配置文件中修改 `spring.datasource.platform` 属性即可启用达梦数据库。
9 |
10 | 
11 |
12 | > Nacos 官方默认支持 MySQL 和 Derby 数据库,本插件扩展了对达梦数据库的支持。
13 |
14 | ## 版本兼容性
15 |
16 | | Nacos 版本 | 插件版本 |
17 | |--------------|---------|
18 | | 2.2.0 - 2.3.0 | 0.0.2 |
19 | | 2.3.1 - 2.3.2 | 0.0.3 |
20 | | 2.4.0 - 2.4.3 | 0.0.4 |
21 | | 2.5.0+ | 0.0.5 |
22 |
23 | ## 快速开始
24 |
25 | ### 1. 添加依赖
26 |
27 | 在项目的 `pom.xml` 中添加以下依赖(注意:依赖已上传至 Maven 中央仓库,请勿使用阿里云代理):
28 |
29 | ```xml
30 |
31 |
32 | com.pig4cloud.plugin
33 | nacos-datasource-plugin-dm8
34 | ${plugin.version}
35 |
36 |
37 |
38 |
39 | com.dameng
40 | DmJdbcDriver18
41 | 8.1.1.193
42 |
43 | ```
44 |
45 | ### 2. 数据库迁移
46 |
47 | 从 MySQL 迁移到达梦数据库有以下两种推荐方案:
48 |
49 | #### 方案一:使用 SQLark 迁移工具
50 | SQLark 提供全流程的异构数据库迁移服务,通过自动化语法解析,提前识别可能存在的改造工作,生成最佳迁移策略。
51 |
52 | 
53 |
54 | 详细迁移指南请访问 [SQLark 文档](https://www.sqlark.com/docs/zh/v1/data-migration/overview.html)
55 |
56 | #### 方案二:使用达梦 DTS 迁移工具
57 | 达梦 DTS 工具支持将 Nacos 的 MySQL 数据库无缝迁移至达梦数据库。
58 |
59 | 
60 |
61 | ### 3. 配置数据源
62 |
63 | 在 Nacos 配置文件中添加以下配置:
64 |
65 | ```yaml
66 | db:
67 | num: 1
68 | url:
69 | 0: jdbc:dm://127.0.0.1:5236?schema=PIGXX_CONFIG
70 | user: SYSDBA
71 | password: SYSDBA
72 | pool:
73 | config:
74 | driver-class-name: dm.jdbc.driver.DmDriver
75 | ```
76 |
77 | ### 4. 启用达梦数据库
78 |
79 | 在应用配置中设置数据库平台为达梦:
80 |
81 | ```yaml
82 | spring:
83 | datasource:
84 | platform: dameng
85 | ```
86 |
87 | ## 参与贡献
88 |
89 | 我们欢迎所有形式的贡献,如果您有任何改进建议或功能扩展,请提交 Pull Request。
90 |
91 | ## 开源协议
92 |
93 | 本项目采用 Apache License 2.0 开源协议 - 详情请参见 [LICENSE](LICENSE) 文件。
94 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | org.springframework.boot
5 | spring-boot-starter-parent
6 | 2.7.18
7 |
8 |
9 |
10 |
11 | 4.0.0
12 | com.pig4cloud.plugin
13 | nacos-datasource-plugin-dm8
14 | 0.0.5
15 | nacos-datasource-plugin-dm8
16 | nacos-datasource-plugin-dm8
17 | https://pig4cloud.com
18 |
19 |
20 |
21 | The ApacheSoftware License, Version 2.0
22 | http://www.apache.org/licenses/LICENSE-2.0.txt
23 | repo
24 |
25 |
26 |
27 |
28 | 2.5.0
29 | 0.0.32
30 | 3.8.1
31 | 1.8
32 | 1.8
33 | 2.2.5
34 | 1.21
35 |
36 |
37 |
38 |
39 | lengleng
40 | wangiegie@gmail.com
41 |
42 |
43 |
44 |
45 | master
46 | https://gitee.wang/lengleng/pig
47 | https://pigx.top
48 | https://gitee.wang/lengleng/pig.git
49 |
50 |
51 |
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-starter
56 |
57 |
58 |
59 | org.projectlombok
60 | lombok
61 | true
62 |
63 |
64 |
65 | com.alibaba.nacos
66 | nacos-datasource-plugin
67 | ${nacos.version}
68 |
69 |
70 |
71 | com.alibaba.nacos
72 | nacos-common
73 | ${nacos.version}
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | io.spring.javaformat
82 | spring-javaformat-maven-plugin
83 | ${spring.checkstyle.plugin}
84 |
85 |
86 |
87 | org.apache.maven.plugins
88 | maven-compiler-plugin
89 | ${maven.compiler.version}
90 |
91 | ${maven.compiler.target}
92 | ${maven.compiler.source}
93 | UTF-8
94 | true
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | snapshot
103 |
104 |
105 |
106 |
107 | org.apache.maven.plugins
108 | maven-source-plugin
109 | 2.2.1
110 |
111 |
112 | package
113 |
114 | jar-no-fork
115 |
116 |
117 |
118 |
119 |
120 |
121 | org.apache.maven.plugins
122 | maven-javadoc-plugin
123 | 3.3.2
124 |
125 | private
126 | true
127 | UTF-8
128 | UTF-8
129 | UTF-8
130 | none
131 | false
132 |
133 |
134 |
135 | package
136 |
137 | jar
138 |
139 |
140 |
141 |
142 |
143 |
144 | org.apache.maven.plugins
145 | maven-gpg-plugin
146 | 3.0.1
147 |
148 |
149 | sign-artifacts
150 | verify
151 |
152 | sign
153 |
154 |
155 |
156 |
157 |
158 | --pinentry-mode
159 | loopback
160 |
161 |
162 |
163 |
164 | org.sonatype.plugins
165 | nexus-staging-maven-plugin
166 | 1.6.13
167 | true
168 |
169 | sonatype
170 | https://oss.sonatype.org/
171 | true
172 |
173 |
174 |
175 |
176 |
177 |
178 | sonatype
179 |
180 | https://oss.sonatype.org/content/repositories/snapshots/
181 |
182 |
183 |
184 |
185 |
186 | release
187 |
188 |
189 |
190 |
191 | org.apache.maven.plugins
192 | maven-source-plugin
193 | 2.2.1
194 |
195 |
196 | package
197 |
198 | jar-no-fork
199 |
200 |
201 |
202 |
203 |
204 |
205 | org.apache.maven.plugins
206 | maven-javadoc-plugin
207 | 3.3.2
208 |
209 | private
210 | true
211 | UTF-8
212 | UTF-8
213 | UTF-8
214 | none
215 | false
216 |
217 |
218 |
219 | package
220 |
221 | jar
222 |
223 |
224 |
225 |
226 |
227 |
228 | org.apache.maven.plugins
229 | maven-gpg-plugin
230 | 3.0.1
231 |
232 |
233 | sign-artifacts
234 | verify
235 |
236 | sign
237 |
238 |
239 |
240 |
241 |
242 | --pinentry-mode
243 | loopback
244 |
245 |
246 |
247 |
248 | org.sonatype.plugins
249 | nexus-staging-maven-plugin
250 | 1.6.13
251 | true
252 |
253 | sonatype
254 | https://oss.sonatype.org/
255 | true
256 |
257 |
258 |
259 |
260 |
261 |
262 | sonatype
263 |
264 | https://oss.sonatype.org/service/local/staging/deploy/maven2/
265 |
266 |
267 |
268 |
269 |
270 |
271 |
--------------------------------------------------------------------------------
/src/main/java/com/pig4cloud/plugin/constants/DataSourceConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 1999-2022 Alibaba Group Holding Ltd.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.pig4cloud.plugin.constants;
18 |
19 | /**
20 | * The data source name.
21 | *
22 | * @author hyx
23 | **/
24 | public class DataSourceConstant {
25 |
26 | public static final String MYSQL = "mysql";
27 |
28 | public static final String DERBY = "derby";
29 |
30 | public static final String POSTGRESQL = "postgresql";
31 |
32 | public static final String ORACLE = "oracle";
33 |
34 | public static final String DM = "dameng";
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/pig4cloud/plugin/impl/dm/ConfigInfoBetaMapperByDm.java:
--------------------------------------------------------------------------------
1 | package com.pig4cloud.plugin.impl.dm;
2 |
3 | import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoBetaMapper;
4 | import com.alibaba.nacos.plugin.datasource.model.MapperContext;
5 | import com.alibaba.nacos.plugin.datasource.model.MapperResult;
6 | import com.pig4cloud.plugin.constants.DataSourceConstant;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | public class ConfigInfoBetaMapperByDm extends DmAbstractMapper implements ConfigInfoBetaMapper {
12 |
13 | @Override
14 | public MapperResult findAllConfigInfoBetaForDumpAllFetchRows(MapperContext context) {
15 | int startRow = context.getStartRow();
16 | int pageSize = context.getPageSize();
17 | String sql = " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips,encrypted_data_key "
18 | + " FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT " + startRow + "," + pageSize + " )"
19 | + " g, config_info_beta t WHERE g.id = t.id ";
20 | List