Nacos 2.2.4支持postgresql数据库
本文基源码:扩展插件包
网上资料都有,还是个人爬坑补充异常处理记录,以便后续升级改造有漏洞修复
https://github.com/alibaba/nacos/releases
<postgresql.version>42.5.1postgresql.version>
<dependency>
<groupId>org.postgresqlgroupId>
<artifactId>postgresqlartifactId>
<version>${postgresql.version}version>
dependency>
<dependency>
<groupId>org.postgresqlgroupId>
<artifactId>postgresqlartifactId>
dependency>
/plugin/datasource/src/main/resources/META-INF/services 下增加以下数据
com.alibaba.nacos.plugin.datasource.mapper.Mapper
com.alibaba.nacos.plugin.datasource.impl.postgresql.ConfigInfoAggrMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.ConfigInfoBetaMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.ConfigInfoMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.ConfigInfoTagMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.ConfigTagsRelationMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.HistoryConfigInfoMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.TenantInfoMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.TenantCapacityMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl.postgresql.GroupCapacityMapperByPostgreSql
com.alibaba.nacos.plugin.datasource.impl 模块下
public static final String POSTGRESQL = "postgresql";
ConfigInfoAggrMapperByPostgreSql
ConfigInfoBetaMapperByPostgreSql
ConfigInfoMapperByPostgreSql
ConfigInfoTagMapperByPostgreSql
ConfigTagsRelationMapperByPostgreSql
HistoryConfigInfoMapperByPostgreSql
TenantInfoMapperByPostgreSql
TenantCapacityMapperByPostgreSql
GroupCapacityMapperByPostgreSql
mvn -Prelease-nacos clean package install -Dmaven.test.skip=true
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
# mvn Failed during checkstyle execution: There are errors reported by Checkstyle
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U -Dcheckstyle.skip
如果发现异常,单独排查处理(没有则忽略):
发现maven构建还是失败,如下:
问题:Cannot access mirror (https://maven.aliyun.com/nexus/content/groups/public) in offline mode and the artifact org.springframework.boot:spring-boot-maven-plugin:pom:2.6.14 has not been downloaded from it before.
解决:idea中maven项目下载依赖cannot resolve的问题
最终结果:
个人取名:2.2.4.IKPOEM
传入私服中使用,和外部区分开来
spring.datasource.platform=postgresql
db.num=1
db.url.0=jdbc:postgresql://127.0.0.1:5432/nacos_db?currentSchema=nacos_config&reWriteBatchedInserts=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
db.user.0=postgres
db.password.0=123456
# 注意添加配置需要
db.pool.config.driverClassName=org.postgresql.Driver
jdbc:postgresql://127.0.0.1:5432/nacos_config?currentSchema=public&tcpKeepAlive=true&reWriteBatchedInserts=true
jar包位置,生成的jar包在nacos\distribution\target目录下
.\startup.cmd -m standalone
访问:http://localhost:8848/nacos nacos/nacos
console: com.alibaba.nacos.Nacos
VM options: -Dnacos.standalone=true 单击版本
情况说明:本人使用nacos-mysql脚本同步到pg库当中,部分表字段类型调整,自增调整为seq,还有时间问题调整等
添加序列:tenant_info_id_seq
等多个seq
CREATE SEQUENCE "nacos_config"."config_info_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
SELECT setval('"nacos_config"."config_info_id_seq"', 1, false);
ALTER SEQUENCE "nacos_config"."config_info_id_seq"
OWNED BY "nacos_config"."config_info"."id";
ALTER SEQUENCE "nacos_config"."config_info_id_seq" OWNER TO "root";
-- nextval('nacos_config.config_info_id_seq'::regclass)
CREATE SEQUENCE "nacos_config"."tenant_capacity_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
SELECT setval('"nacos_config"."tenant_capacity_id_seq"', 1, false);
ALTER SEQUENCE "nacos_config"."tenant_capacity_id_seq"
OWNED BY "nacos_config"."tenant_capacity"."id";
ALTER SEQUENCE "nacos_config"."tenant_capacity_id_seq" OWNER TO "root";
-- nextval('nacos_config.tenant_capacity_id_seq'::regclass)
CREATE SEQUENCE "nacos_config"."group_capacity_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
SELECT setval('"nacos_config"."group_capacity_id_seq"', 1, false);
ALTER SEQUENCE "nacos_config"."group_capacity_id_seq"
OWNED BY "nacos_config"."group_capacity"."id";
ALTER SEQUENCE "nacos_config"."group_capacity_id_seq" OWNER TO "root";
-- nextval('nacos_config.group_capacity_id_seq'::regclass)
CREATE SEQUENCE "nacos_config"."his_config_info_nid_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
SELECT setval('"nacos_config"."his_config_info_nid_seq"', 1, false);
ALTER SEQUENCE "nacos_config"."his_config_info_nid_seq"
OWNED BY "nacos_config"."his_config_info"."id";
ALTER SEQUENCE "nacos_config"."his_config_info_nid_seq" OWNER TO "root";
-- nextval('nacos_config.his_config_info_nid_seq'::regclass)
表添加nextval('nacos_config.tenant_info_id_seq'::regclass)
pg
Nacos Too many files with unapproved license:
[ERROR] Failed to execute goal org.apache.rat:apache-rat-plugin:0.12:check (default) on project nacos-datasource-plugin: Too many files with unapproved license: 1 See RAT report in: G:\nacos
原因:我添加了新的文档,代码路径 \plugin\datasource\target\rat.txt未知的Licenses,把新增的代码头上加上 Licenses 即可
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
报错原因:意思是在pom文件中缺少distributionManagement标签,或者缺少-DaltDeployementRepositoty,说的是缺少deploy的地址,maven不知道你想要deploy到哪里,在pom文件中增加如下信息,就发布成功了.
Nacos 2.2.0支持postgresql数据库
修改nacos源码编译打包
idea中maven项目下载依赖cannot resolve的问题