这段时间公司在搞国产化,发现当前的nacos版本只支持MySQL和derby数据库,后来翻看官方文档以后,官方文档说2.2以后支持达梦数据库了,但是需要插件。
按照他的思路再结合其他资料,我们开始搞起来!
一、下载源码
GitHub仓库源码:nacos
我们直接用最新版,以官网的2.4.0稳定版入手。
选择2.4.0版本
下载压缩包
解压压缩包,并用IDEA打开。
二、编译代码
建议把test取消掉。
如果出现这个报错,那就找到这个报错的包,compile一下,哪个包报错,就compile哪个包就行。
解决完报错后,启动Nacos。
三、启动Nacos
启动nacos在nacos-console包下。
如果因为是集群模式报错,修改IDEA启动命令
添加-Dnacos.standalone=true命令,保存重新启动就可以了。
四、适配多数据源
官方文档是去Nacos插件仓库找插件,但是我下载下来以后,不太适配,可能是我没搞明白,我直接把源码的mysql数据库复制了一份,改了改用着也没问题。
要是想跟着官方文档来弄也可以,我把链接放到下面,这里就不按照官方文档的方法做了。
Nacos插件仓库地址:Nacos插件仓库
多数据源的代码要写到nacos-plugin/nacos-datasource-plugin项目下。
添加数据源类型,在DataSourceConstant类
增加达梦适配的Mapper
直接把mysql里的所有类复制到dm的文件夹内,然后把ByMySql替换为ByDm。
把每个类的如下代码:
@Override
public String getDataSource() {
return DataSourceConstant.MYSQL;
}
替换成:
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
修改resource/META-INF.services配置
文件位置:
src\main\resources\META-INF\services\com.alibaba.nacos.plugin.datasource.mapper.Mapper
添加如下内容:
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoAggrMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoBetaMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoTagMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigTagsRelationMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.HistoryConfigInfoMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.TenantInfoMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.TenantCapacityMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.GroupCapacityMapperByDm
添加达梦pom依赖
这个pom依赖最好是你下载的哪个版本的达梦,从达梦里面去粘贴达梦的jar包名称
在父级的pom里引入达梦依赖
<properties>
<dm.version>1.8.0</dm.version>
</properties>
<!--达梦数据库-->
<dependency>
<groupId>com.dm</groupId>
<artifactId>DmJdbcDriver</artifactId>
<version>${dm.version}</version>
</dependency>
在nacos-console 和 nacos-naming 下引用依赖
<!--达梦数据库-->
<dependency>
<groupId>com.dm</groupId>
<artifactId>DmJdbcDriver</artifactId>
</dependency>
修改ExternalDataSourceProperties类
private String jdbcDriverName;
public String getJdbcDriverName() {
return jdbcDriverName;
}
public void setJdbcDriverName(String jdbcDriverName) {
this.jdbcDriverName = jdbcDriverName;
}
if(StringUtils.isEmpty(jdbcDriverName)) {
//使用默认驱动
poolProperties.setDriverClassName(JDBC_DRIVER_NAME);
} else {
//使用自己指定数据驱动
poolProperties.setDriverClassName(jdbcDriverName);
}
最终代码
/*
* Copyright 1999-2023 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.persistence.datasource;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.Preconditions;
import com.alibaba.nacos.common.utils.StringUtils;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.core.env.Environment;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import static com.alibaba.nacos.common.utils.CollectionUtils.getOrDefault;
/**
* Properties of external DataSource.
*
* @author Nacos
*/
public class ExternalDataSourceProperties {
private static final String JDBC_DRIVER_NAME = "com.mysql.cj.jdbc.Driver";
private String jdbcDriverName;
private static final String TEST_QUERY = "SELECT 1";
private Integer num;
private List<String> url = new ArrayList<>();
private List<String> user = new ArrayList<>();
private List<String> password = new ArrayList<>();
public void setNum(Integer num) {
this.num = num;
}
public void setUrl(List<String> url) {
this.url = url;
}
public void setUser(List<String> user) {
this.user = user;
}
public void setPassword(List<String> password) {
this.password = password;
}
public String getJdbcDriverName() {
return jdbcDriverName;
}
public void setJdbcDriverName(String jdbcDriverName) {
this.jdbcDriverName = jdbcDriverName;
}
/**
* Build serveral HikariDataSource.
*
* @param environment {@link Environment}
* @param callback Callback function when constructing data source
* @return List of {@link HikariDataSource}
*/
List<HikariDataSource> build(Environment environment, Callback<HikariDataSource> callback) {
List<HikariDataSource> dataSources = new ArrayList<>();
Binder.get(environment).bind("db", Bindable.ofInstance(this));
Preconditions.checkArgument(Objects.nonNull(num), "db.num is null");
Preconditions.checkArgument(CollectionUtils.isNotEmpty(user), "db.user or db.user.[index] is null");
Preconditions.checkArgument(CollectionUtils.isNotEmpty(password), "db.password or db.password.[index] is null");
for (int index = 0; index < num; index++) {
int currentSize = index + 1;
Preconditions.checkArgument(url.size() >= currentSize, "db.url.%s is null", index);
DataSourcePoolProperties poolProperties = DataSourcePoolProperties.build(environment);
if (StringUtils.isEmpty(poolProperties.getDataSource().getDriverClassName())) {
if(StringUtils.isEmpty(jdbcDriverName)) {
//使用默认驱动
poolProperties.setDriverClassName(JDBC_DRIVER_NAME);
} else {
//使用自己指定数据驱动
poolProperties.setDriverClassName(jdbcDriverName);
}
}
poolProperties.setJdbcUrl(url.get(index).trim());
poolProperties.setUsername(getOrDefault(user, index, user.get(0)).trim());
poolProperties.setPassword(getOrDefault(password, index, password.get(0)).trim());
HikariDataSource ds = poolProperties.getDataSource();
if (StringUtils.isEmpty(ds.getConnectionTestQuery())) {
ds.setConnectionTestQuery(TEST_QUERY);
}
dataSources.add(ds);
callback.accept(ds);
}
Preconditions.checkArgument(CollectionUtils.isNotEmpty(dataSources), "no datasource available");
return dataSources;
}
interface Callback<D> {
/**
* Perform custom logic.
*
* @param datasource dataSource.
*/
void accept(D datasource);
}
}
这样就可以了,配置一下配置文件的数据源就可以了。
五、配置数据源
配置文件在nacos-console\src\main\resources\application.properties
spring.datasource.platform你的数据源是啥就写啥。
db.jdbcDriverName是咱们自己定义的,是驱动。
六、Nacos达梦数据库表
CREATE TABLE "NACOS"."USERS"
(
"USERNAME" VARCHAR(50) NOT NULL,
"PASSWORD" VARCHAR(500) NOT NULL,
"ENABLED" TINYINT NOT NULL
);
CREATE TABLE "NACOS"."TENANT_INFO"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"KP" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"TENANT_NAME" VARCHAR(128) DEFAULT ''
NULL,
"TENANT_DESC" VARCHAR(256) NULL,
"CREATE_SOURCE" VARCHAR(32) NULL,
"GMT_CREATE" BIGINT NOT NULL,
"GMT_MODIFIED" BIGINT NOT NULL
);
CREATE TABLE "NACOS"."TENANT_CAPACITY"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NOT NULL,
"QUOTA" BIGINT DEFAULT 0
NOT NULL,
"USAGE" BIGINT DEFAULT 0
NOT NULL,
"MAX_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_COUNT" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_HISTORY_COUNT" BIGINT DEFAULT 0
NOT NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL
);
CREATE TABLE "NACOS"."ROLES"
(
"USERNAME" VARCHAR(50) NOT NULL,
"ROLE" VARCHAR(50) NOT NULL
);
CREATE TABLE "NACOS"."PERMISSIONS"
(
"ROLE" VARCHAR(50) NOT NULL,
"RESOURCE" VARCHAR(255) NOT NULL,
"ACTION" VARCHAR(8) NOT NULL
);
CREATE TABLE "NACOS"."HIS_CONFIG_INFO"
(
"ID" DECIMAL(20, 0) NOT NULL,
"NID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL,
"OP_TYPE" CHAR(10) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"ENCRYPTED_DATA_KEY" TEXT NOT NULL
);
CREATE TABLE "NACOS"."GROUP_CAPACITY"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"GROUP_ID" VARCHAR(128) DEFAULT ''
NOT NULL,
"QUOTA" BIGINT DEFAULT 0
NOT NULL,
"USAGE" BIGINT DEFAULT 0
NOT NULL,
"MAX_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_COUNT" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_HISTORY_COUNT" BIGINT DEFAULT 0
NOT NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL
);
CREATE TABLE "NACOS"."CONFIG_TAGS_RELATION"
(
"ID" BIGINT NOT NULL,
"TAG_NAME" VARCHAR(128) NOT NULL,
"TAG_TYPE" VARCHAR(64) NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"NID" BIGINT IDENTITY(1,1) NOT NULL
);
CREATE TABLE "NACOS"."CONFIG_INFO_TAG"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"TAG_ID" VARCHAR(128) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL
);
CREATE TABLE "NACOS"."CONFIG_INFO_BETA"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"BETA_IPS" VARCHAR(1024) NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"ENCRYPTED_DATA_KEY" TEXT NOT NULL
);
CREATE TABLE "NACOS"."CONFIG_INFO_AGGR"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"DATUM_ID" VARCHAR(255) NOT NULL,
"CONTENT" CLOB NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL
);
CREATE TABLE "NACOS"."CONFIG_INFO"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL,
"APP_NAME" VARCHAR(128) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"C_DESC" VARCHAR(256) NULL,
"C_USE" VARCHAR(64) NULL,
"EFFECT" VARCHAR(64) NULL,
"TYPE" VARCHAR(64) NULL,
"C_SCHEMA" TEXT NULL,
"ENCRYPTED_DATA_KEY" TEXT NOT NULL
);
ALTER TABLE "NACOS"."USERS"
ADD CONSTRAINT PRIMARY KEY ("USERNAME");
ALTER TABLE "NACOS"."TENANT_INFO"
ADD CONSTRAINT PRIMARY KEY ("ID");
ALTER TABLE "NACOS"."TENANT_INFO"
ADD CONSTRAINT "UK_TENANT_INFO_KPTENANTID" UNIQUE ("KP", "TENANT_ID");
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CONSTRAINT PRIMARY KEY ("ID");
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CONSTRAINT "UK_TENANT_ID" UNIQUE ("TENANT_ID");
ALTER TABLE "NACOS"."ROLES"
ADD CONSTRAINT "IDX_USER_ROLE" UNIQUE ("USERNAME", "ROLE");
ALTER TABLE "NACOS"."PERMISSIONS"
ADD CONSTRAINT "UK_ROLE_PERMISSION" UNIQUE ("ROLE", "RESOURCE", "ACTION");
ALTER TABLE "NACOS"."HIS_CONFIG_INFO"
ADD CONSTRAINT PRIMARY KEY ("NID");
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CONSTRAINT PRIMARY KEY ("ID");
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CONSTRAINT "UK_GROUP_ID" UNIQUE ("GROUP_ID");
ALTER TABLE "NACOS"."CONFIG_TAGS_RELATION"
ADD CONSTRAINT PRIMARY KEY ("NID");
ALTER TABLE "NACOS"."CONFIG_TAGS_RELATION"
ADD CONSTRAINT "UK_CONFIGTAGRELATION_CONFIGIDTAG" UNIQUE ("ID", "TAG_NAME", "TAG_TYPE");
ALTER TABLE "NACOS"."CONFIG_INFO_TAG"
ADD CONSTRAINT PRIMARY KEY ("ID");
ALTER TABLE "NACOS"."CONFIG_INFO_TAG"
ADD CONSTRAINT "UK_CONFIGINFOTAG_DATAGROUPTENANTTAG" UNIQUE ("DATA_ID", "GROUP_ID", "TENANT_ID", "TAG_ID");
ALTER TABLE "NACOS"."CONFIG_INFO_BETA"
ADD CONSTRAINT PRIMARY KEY ("ID");
ALTER TABLE "NACOS"."CONFIG_INFO_BETA"
ADD CONSTRAINT "UK_CONFIGINFOBETA_DATAGROUPTENANT" UNIQUE ("DATA_ID", "GROUP_ID", "TENANT_ID");
ALTER TABLE "NACOS"."CONFIG_INFO_AGGR"
ADD CONSTRAINT PRIMARY KEY ("ID");
ALTER TABLE "NACOS"."CONFIG_INFO_AGGR"
ADD CONSTRAINT "UK_CONFIGINFOAGGR_DATAGROUPTENANTDATUM" UNIQUE ("DATA_ID", "GROUP_ID", "TENANT_ID", "DATUM_ID");
ALTER TABLE "NACOS"."CONFIG_INFO"
ADD CONSTRAINT PRIMARY KEY ("ID");
ALTER TABLE "NACOS"."CONFIG_INFO"
ADD CONSTRAINT "UK_CONFIGINFO_DATAGROUPTENANT" UNIQUE ("DATA_ID", "GROUP_ID", "TENANT_ID");
CREATE INDEX "IDX_TENANT_ID"
ON "NACOS"."TENANT_INFO" ("TENANT_ID");
COMMENT
ON TABLE "NACOS"."TENANT_INFO" IS 'tenant_info';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."ID" IS 'id';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."KP" IS 'kp';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."TENANT_ID" IS 'tenant_id';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."TENANT_NAME" IS 'tenant_name';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."TENANT_DESC" IS 'tenant_desc';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."CREATE_SOURCE" IS 'create_source';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."GMT_CREATE" IS '创建时间';
COMMENT
ON COLUMN "NACOS"."TENANT_INFO"."GMT_MODIFIED" IS '修改时间';
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CHECK ("QUOTA" >= 0) ENABLE;
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CHECK ("MAX_HISTORY_COUNT" >= 0) ENABLE;
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CHECK ("MAX_AGGR_SIZE" >= 0) ENABLE;
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CHECK ("MAX_AGGR_COUNT" >= 0) ENABLE;
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CHECK ("MAX_SIZE" >= 0) ENABLE;
ALTER TABLE "NACOS"."TENANT_CAPACITY"
ADD CHECK ("USAGE" >= 0) ENABLE;
COMMENT
ON TABLE "NACOS"."TENANT_CAPACITY" IS '租户容量信息表';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."ID" IS '主键ID';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."TENANT_ID" IS 'Tenant ID';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."QUOTA" IS '配额,0表示使用默认值';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."USAGE" IS '使用量';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."MAX_SIZE" IS '单个配置大小上限,单位为字节,0表示使用默认值';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大个数';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."GMT_CREATE" IS '创建时间';
COMMENT
ON COLUMN "NACOS"."TENANT_CAPACITY"."GMT_MODIFIED" IS '修改时间';
ALTER TABLE "NACOS"."HIS_CONFIG_INFO"
ADD CHECK ("ID" >= 0) ENABLE;
CREATE INDEX "IDX_GMT_MODIFIED"
ON "NACOS"."HIS_CONFIG_INFO" ("GMT_MODIFIED");
CREATE INDEX "IDX_GMT_CREATE"
ON "NACOS"."HIS_CONFIG_INFO" ("GMT_CREATE");
CREATE INDEX "IDX_DID"
ON "NACOS"."HIS_CONFIG_INFO" ("DATA_ID");
COMMENT
ON TABLE "NACOS"."HIS_CONFIG_INFO" IS '多租户改造';
COMMENT
ON COLUMN "NACOS"."HIS_CONFIG_INFO"."APP_NAME" IS 'app_name';
COMMENT
ON COLUMN "NACOS"."HIS_CONFIG_INFO"."TENANT_ID" IS '租户字段';
COMMENT
ON COLUMN "NACOS"."HIS_CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '密钥';
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CHECK ("QUOTA" >= 0) ENABLE;
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CHECK ("MAX_HISTORY_COUNT" >= 0) ENABLE;
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CHECK ("MAX_AGGR_SIZE" >= 0) ENABLE;
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CHECK ("MAX_AGGR_COUNT" >= 0) ENABLE;
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CHECK ("MAX_SIZE" >= 0) ENABLE;
ALTER TABLE "NACOS"."GROUP_CAPACITY"
ADD CHECK ("USAGE" >= 0) ENABLE;
COMMENT
ON TABLE "NACOS"."GROUP_CAPACITY" IS '集群、各Group容量信息表';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."ID" IS '主键ID';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."GROUP_ID" IS 'Group ID,空字符表示整个集群';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."QUOTA" IS '配额,0表示使用默认值';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."USAGE" IS '使用量';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."MAX_SIZE" IS '单个配置大小上限,单位为字节,0表示使用默认值';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大个数,,0表示使用默认值';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."GMT_CREATE" IS '创建时间';
COMMENT
ON COLUMN "NACOS"."GROUP_CAPACITY"."GMT_MODIFIED" IS '修改时间';
COMMENT
ON TABLE "NACOS"."CONFIG_TAGS_RELATION" IS 'config_tag_relation';
COMMENT
ON COLUMN "NACOS"."CONFIG_TAGS_RELATION"."ID" IS 'id';
COMMENT
ON COLUMN "NACOS"."CONFIG_TAGS_RELATION"."TAG_NAME" IS 'tag_name';
COMMENT
ON COLUMN "NACOS"."CONFIG_TAGS_RELATION"."TAG_TYPE" IS 'tag_type';
COMMENT
ON COLUMN "NACOS"."CONFIG_TAGS_RELATION"."DATA_ID" IS 'data_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_TAGS_RELATION"."GROUP_ID" IS 'group_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_TAGS_RELATION"."TENANT_ID" IS 'tenant_id';
COMMENT
ON TABLE "NACOS"."CONFIG_INFO_TAG" IS 'config_info_tag';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."ID" IS 'id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."DATA_ID" IS 'data_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."GROUP_ID" IS 'group_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."TENANT_ID" IS 'tenant_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."TAG_ID" IS 'tag_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."APP_NAME" IS 'app_name';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."CONTENT" IS 'content';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."MD5" IS 'md5';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."GMT_CREATE" IS '创建时间';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."GMT_MODIFIED" IS '修改时间';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."SRC_USER" IS 'source user';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_TAG"."SRC_IP" IS 'source ip';
COMMENT
ON TABLE "NACOS"."CONFIG_INFO_BETA" IS 'config_info_beta';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."ID" IS 'id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."DATA_ID" IS 'data_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."GROUP_ID" IS 'group_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."APP_NAME" IS 'app_name';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."CONTENT" IS 'content';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."BETA_IPS" IS 'betaIps';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."MD5" IS 'md5';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."GMT_CREATE" IS '创建时间';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."GMT_MODIFIED" IS '修改时间';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."SRC_USER" IS 'source user';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."SRC_IP" IS 'source ip';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."TENANT_ID" IS '租户字段';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_BETA"."ENCRYPTED_DATA_KEY" IS '密钥';
COMMENT
ON TABLE "NACOS"."CONFIG_INFO_AGGR" IS '增加租户字段';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_AGGR"."ID" IS 'id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_AGGR"."DATA_ID" IS 'data_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_AGGR"."GROUP_ID" IS 'group_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_AGGR"."DATUM_ID" IS 'datum_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_AGGR"."CONTENT" IS '内容';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_AGGR"."GMT_MODIFIED" IS '修改时间';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO_AGGR"."TENANT_ID" IS '租户字段';
COMMENT
ON TABLE "NACOS"."CONFIG_INFO" IS 'config_info';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."ID" IS 'id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."DATA_ID" IS 'data_id';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."CONTENT" IS 'content';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."MD5" IS 'md5';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."GMT_CREATE" IS '创建时间';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."GMT_MODIFIED" IS '修改时间';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."SRC_USER" IS 'source user';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."SRC_IP" IS 'source ip';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."TENANT_ID" IS '租户字段';
COMMENT
ON COLUMN "NACOS"."CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '密钥';
INSERT INTO "NACOS"."USERS"("USERNAME", "PASSWORD", "ENABLED")
VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', 1);
INSERT INTO "NACOS"."ROLES"("USERNAME", "ROLE")
VALUES ('nacos', 'ROLE_ADMIN');
七、重新启动测试
连接上数据库后,重新启动测试,成功后访问页面
八、打包源码
打开cmd,进入源码根目录
执行mvn命令:
mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Drat.skip=true -Dcheckstyle.skip=true clean install -U
打包成功后,显示:
打包后的nacos位置在\distribution\target\下。
nacos-server-2.4.0.zip解压直接用就行,配置文件记得修改,自己添加的字段记得加上,运行起来就可以了。