当前位置:首页 > 服务端 > nacos 适配达梦、人大金仓数据库

nacos 适配达梦、人大金仓数据库

2022年08月04日 19:46:43服务端20

  1. 背景
    Nacos 提供了文件存储和mysql存储两种方式,本文记录了如何增加对 达梦数据库的支持。
  2. 实现思路
    采用的方式:修改nacos源码增加对达梦数据库的支持
一、准备工作
1. 阅读官网文档

下载nacos源码、编译,官网更详细
https://nacos.io/zh-cn/docs/quick-start.html

2. 下载源码,按官网更详细

git地址:https://github.com/alibaba/nacos.git

git clone https://github.com/alibaba/nacos.git
cd nacos/
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U  
ls -al distribution/target/

// change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin
3. 下载达梦、人大金仓数据库驱动

我下载的是:Dm、Kingbase依赖

dm: https://download.csdn.net/download/qq_24101357/20677620
kingbase: https://download.csdn.net/download/qq_24101357/20677646

二、修改nacos源码
2.1. 引入驱动依赖

引入达梦数据库驱动依赖
修改项目根目录下nacos-all的pom.xml

<!--达梦、人大金仓 版本管理-->
<dm-connector-java.version>1.8</dm-connector-java.version>
<kingbase-connector-java.version>8.2.0</kingbase-connector-java.version>
<dependency>
    <groupId>com.dameng</groupId>
    <artifactId>Dm8JdbcDriver18</artifactId>
    <version>${dm-connector-java.version}</version>
</dependency>

<dependency>
    <groupId>com.kingbase</groupId>
    <artifactId>kingbase8</artifactId>
    <version>${kingbase-connector-java.version}</version>
</dependency>
2.2. 引用数据库

在 nacos-config 模块直接引用驱动库,修改 nacos-config的pom.xml

 <!-- 达梦数据库驱动-->
<dependency>
    <groupId>com.dameng</groupId>
    <artifactId>Dm8JdbcDriver18</artifactId>
</dependency>
 <!-- 人大金仓数据库驱动-->
<dependency>
    <groupId>com.kingbase</groupId>
    <artifactId>kingbase8</artifactId>
</dependency>
2.3. 修改配置

nacos-console模块的application.properties:

### Count of DB: 这里打开,并新增 dm.jdbc.driver.DmDriver 的驱动
db.num=1
db.jdbcDriverName=dm.jdbc.driver.DmDriver

### Connect URL of DB: 打开并指定 url 连接字符串
#db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.url.0=jdbc:dm://192.168.1.22:5236/NACOS?STU&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
db.user.0=NACOS
db.password.0=xxxxxxxx

#人大金仓
#spring.datasource.platform=mysql
#db.num=1
#db.jdbcDriverName=com.kingbase8.Driver
#db.url.0=jdbc:kingbase8://127.0.0.1:54321/nacos
#db.user.0=root
#db.password.0=root

#mysql
#spring.datasource.platform=mysql
#db.jdbcDriverName=com.mysql.cj.jdbc.Driver
#db.num=1
#db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
#db.use.0r=root
#db.password.0=root
2.4. 添加属性

nacos-config模块:
com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceProperties.java
其实就改了可以通过配置文件指定数据库驱动
添加属性

 /**
     * 数据库驱动
     * 增加对达梦、人大金仓数据库的支持
     */
    private String jdbcDriverName;
    public String getJdbcDriverName() {
     
        return jdbcDriverName;
    }
    public void setJdbcDriverName(String jdbcDriverName) {
     
        this.jdbcDriverName = jdbcDriverName;
    }
2.5. 指定驱动名称

为 HikariDataSource 对象 指定驱动名称,调动 setDriverClassName 方法,见下:
修改build方法或者直接替换(下面有代码)
修改部分为红框部分
nacos 适配达梦、人大金仓数据库 _ JavaClub全栈架构师技术笔记
变更代码部分

		 //update Start
            System.out.println("#################################");
            System.out.println("jdbcDriverName=" + jdbcDriverName);
            if (StringUtils.isNotEmpty(jdbcDriverName)) {
     
                // 增加其他数据库驱动的支持
                ds.setDriverClassName(jdbcDriverName);
            } else {
     
                //默认使用mysql驱动
                ds.setDriverClassName(JDBC_DRIVER_NAME);
            }
            System.out.println("#################################");
            System.out.println("dataSources=" + dataSources);
            dataSources.add(ds);
            callback.accept(ds);
            System.out.println("dataSources=" + dataSources);
            //update End

修改后的方法

/**
     * 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);
            poolProperties.setDriverClassName(JDBC_DRIVER_NAME);
            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();
            ds.setConnectionTestQuery(TEST_QUERY);
            ds.setIdleTimeout(TimeUnit.MINUTES.toMillis(10L));
            ds.setConnectionTimeout(TimeUnit.SECONDS.toMillis(3L));
            System.out.println("#################################");
            System.out.println("jdbcDriverName=" + jdbcDriverName);
            if (StringUtils.isNotEmpty(jdbcDriverName)) {
     
                // 增加其他数据库驱动的支持
                ds.setDriverClassName(jdbcDriverName);
            } else {
     
                //默认使用mysql驱动
                ds.setDriverClassName(JDBC_DRIVER_NAME);
            }
            System.out.println("#################################");
            System.out.println("dataSources=" + dataSources);
            dataSources.add(ds);
            callback.accept(ds);
        }
        Preconditions.checkArgument(CollectionUtils.isNotEmpty(dataSources), "no datasource available");
        return dataSources;
    }
三、构建
3.1. 进入源代码目录
cd nacos-2.0.4
3.2. 执行构建
mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true  clean install -U

或者

mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U

(注:可以查看nacos文件夹,目录里面有一个BUILDING文件中说明)

nacos 适配达梦、人大金仓数据库 _ JavaClub全栈架构师技术笔记
nacos 适配达梦、人大金仓数据库 _ JavaClub全栈架构师技术笔记

3.3. 查看构建包

获得构建完成后的工程
构建后,在 进入到源代码目录 中的 文件夹:
distribution/target/nacos-server-$version 下的 nacos 文件夹 就是最终的输出物。
nacos 适配达梦、人大金仓数据库 _ JavaClub全栈架构师技术笔记
nacos-server-2.1.0-SNAPSHOT.tar.gz 是linux环境的
nacos-server-2.1.0-SNAPSHOT.zip 是windows环境的

3.4. 最后启动

启动 nacos查看启动日志

sh startup.sh -m standalone

tail -f /app/支持达梦改造后的Nacos/nacos/logs/start.out

3.5. 最后检查

看看数据库中,Nacos 已经使用 达梦数据库来存储了。

3.6. 补充

如果遇到这个异常请参考这篇博客
Too many files with unapproved license: 2 See RAT report
nacos 适配达梦、人大金仓数据库 _ JavaClub全栈架构师技术笔记

3.7. 初始化脚本

达梦数据库中初始化 Nacos 语句.sql

注意需要修改对应的用户,以下脚本默认试NACOS

/*################################################################################
#  2021-09-03 记录遗留问题:
#   (1) 达梦的 bigint 最大是20,而 mysql是64,因此:his_config_info 表的  `id` bigint(64) 只得 改为 bitint,但愿 自增列别用尽
#   (2) 达梦不支持 unsigned ,而 mysql 支持,因此:只得在 达梦放弃 unsigned
################################################################################*/


CREATE TABLE "NACOS"."CONFIG_INFO"
(
"ID" BIGINT IDENTITY(1, 1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(255),
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32),
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"SRC_USER" TEXT,
"SRC_IP" VARCHAR(50),
"APP_NAME" VARCHAR(128),
"TENANT_ID" VARCHAR(128) DEFAULT '',
"C_DESC" VARCHAR(256),
"C_USE" VARCHAR(64),
"EFFECT" VARCHAR(64),
"TYPE" VARCHAR(64),
"C_SCHEMA" TEXT,
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_CONFIGINFO_DATAGROUPTENANT" UNIQUE("DATA_ID", "GROUP_ID", "TENANT_ID")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '租户字段';


CREATE UNIQUE  INDEX "INDEX16097400477400" ON "NACOS"."CONFIG_INFO"("ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE TABLE "NACOS"."CONFIG_INFO_AGGR"
(
"ID" BIGINT IDENTITY(1, 1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(255) NOT NULL,
"DATUM_ID" VARCHAR(255) NOT NULL,
"CONTENT" CLOB NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) NOT NULL,
"APP_NAME" VARCHAR(128),
"TENANT_ID" VARCHAR(128) DEFAULT '',
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_CONFIGINFOAGGR_DATAGROUPTENANTDATUM" UNIQUE("DATA_ID", "GROUP_ID", "TENANT_ID", "DATUM_ID")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '租户字段';


CREATE UNIQUE  INDEX "INDEX16097305729100" ON "NACOS"."CONFIG_INFO_AGGR"("ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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),
"CONTENT" CLOB NOT NULL,
"BETA_IPS" VARCHAR(1024),
"MD5" VARCHAR(32),
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"SRC_USER" TEXT,
"SRC_IP" VARCHAR(50),
"TENANT_ID" VARCHAR(128) DEFAULT '',
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_CONFIGINFOBETA_DATAGROUPTENANT" UNIQUE("DATA_ID", "GROUP_ID", "TENANT_ID")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '租户字段';


CREATE UNIQUE  INDEX "INDEX16097203229000" ON "NACOS"."CONFIG_INFO_BETA"("ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '',
"TAG_ID" VARCHAR(128) NOT NULL,
"APP_NAME" VARCHAR(128),
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32),
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"SRC_USER" TEXT,
"SRC_IP" VARCHAR(50),
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_CONFIGINFOTAG_DATAGROUPTENANTTAG" UNIQUE("DATA_ID", "GROUP_ID", "TENANT_ID", "TAG_ID")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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';


CREATE UNIQUE  INDEX "INDEX16096985471400" ON "NACOS"."CONFIG_INFO_TAG"("ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE TABLE "NACOS"."CONFIG_TAGS_RELATION"
(
"ID" BIGINT NOT NULL,
"TAG_NAME" VARCHAR(128) NOT NULL,
"TAG_TYPE" VARCHAR(64),
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT '',
"NID" BIGINT IDENTITY(1, 1) NOT NULL,
NOT CLUSTER PRIMARY KEY("NID"),
CONSTRAINT "UK_CONFIGTAGRELATION_CONFIGIDTAG" UNIQUE("ID", "TAG_NAME", "TAG_TYPE")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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';


CREATE  INDEX "INDEX16096890650200" ON "NACOS"."CONFIG_TAGS_RELATION"("TENANT_ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;
CREATE UNIQUE  INDEX "INDEX16096909541100" ON "NACOS"."CONFIG_TAGS_RELATION"("NID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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,
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_GROUP_ID" UNIQUE("GROUP_ID"),
CHECK("QUOTA" >= 0)
,CHECK("USAGE" >= 0)
,CHECK("MAX_SIZE" >= 0)
,CHECK("MAX_AGGR_COUNT" >= 0)
,CHECK("MAX_AGGR_SIZE" >= 0)
,CHECK("MAX_HISTORY_COUNT" >= 0)) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '修改时间';


CREATE UNIQUE  INDEX "INDEX16096746763900" ON "NACOS"."GROUP_CAPACITY"("ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE TABLE "NACOS"."HIS_CONFIG_INFO"
(
"ID" BIGINT 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),
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32),
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NOT NULL,
"SRC_USER" TEXT,
"SRC_IP" VARCHAR(50),
"OP_TYPE" CHAR(10),
"TENANT_ID" VARCHAR(128) DEFAULT '',
NOT CLUSTER PRIMARY KEY("NID")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '租户字段';


CREATE  INDEX "IDX_GMT_CREATE" ON "NACOS"."HIS_CONFIG_INFO"("GMT_CREATE" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;
CREATE  INDEX "IDX_DID" ON "NACOS"."HIS_CONFIG_INFO"("DATA_ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;
CREATE  INDEX "IDX_GMT_MODIFIED" ON "NACOS"."HIS_CONFIG_INFO"("GMT_MODIFIED" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;
CREATE UNIQUE  INDEX "INDEX16096449256900" ON "NACOS"."HIS_CONFIG_INFO"("NID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE TABLE "NACOS"."PERMISSIONS"
(
"ROLE" VARCHAR(50) NOT NULL,
"RESOURCE" VARCHAR(255) NOT NULL,
"ACTION" VARCHAR(8) NOT NULL,
CONSTRAINT "UK_ROLE_PERMISSION" UNIQUE("ROLE", "RESOURCE", "ACTION")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE TABLE "NACOS"."ROLES"
(
"USERNAME" VARCHAR(50) NOT NULL,
"ROLE" VARCHAR(50) NOT NULL,
CONSTRAINT "IDX_USER_ROLE" UNIQUE("USERNAME", "ROLE")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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,
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_TENANT_ID" UNIQUE("TENANT_ID"),
CHECK("QUOTA" >= 0)
,CHECK("USAGE" >= 0)
,CHECK("MAX_SIZE" >= 0)
,CHECK("MAX_AGGR_COUNT" >= 0)
,CHECK("MAX_AGGR_SIZE" >= 0)
,CHECK("MAX_HISTORY_COUNT" >= 0)) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '修改时间';


CREATE UNIQUE  INDEX "INDEX16096046055000" ON "NACOS"."TENANT_CAPACITY"("ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE TABLE "NACOS"."TENANT_INFO"
(
"ID" BIGINT IDENTITY(1, 1) NOT NULL,
"KP" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT '',
"TENANT_NAME" VARCHAR(128) DEFAULT '',
"TENANT_DESC" VARCHAR(256),
"CREATE_SOURCE" VARCHAR(32),
"GMT_CREATE" BIGINT NOT NULL,
"GMT_MODIFIED" BIGINT NOT NULL,
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_TENANT_INFO_KPTENANTID" UNIQUE("KP", "TENANT_ID")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

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 '修改时间';


CREATE  INDEX "IDX_TENANT_ID" ON "NACOS"."TENANT_INFO"("TENANT_ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;
CREATE UNIQUE  INDEX "INDEX16095846853300" ON "NACOS"."TENANT_INFO"("ID" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE TABLE "NACOS"."USERS"
(
"USERNAME" VARCHAR(50) NOT NULL,
"PASSWORD" VARCHAR(500) NOT NULL,
"ENABLED" TINYINT NOT NULL,
NOT CLUSTER PRIMARY KEY("USERNAME")) STORAGE(ON "nacos_db", CLUSTERBTR) ;

CREATE UNIQUE  INDEX "PRIMARY" ON "NACOS"."USERS"("USERNAME" ASC) STORAGE(ON "nacos_db", CLUSTERBTR) ;

作者:gblfy
来源链接:https://blog.csdn.net/weixin_40816738/article/details/124022800

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。


本文链接:https://www.javaclub.cn/server/17332.html

标签: Nacos
分享给朋友:

“nacos 适配达梦、人大金仓数据库” 的相关文章

nacos启动教程

nacos启动教程

1、下载nacos压缩包 链接:https://pan.baidu.com/s/1PE6D73rIuOhnfvKVqvDwhA  提取码:oj9y 2、解压  3、修改conf里的配置文件(application.properties...

Nacos数据库配置

Nacos数据库配置

本文来说下nacos数据库配置 文章目录 Nacos控制面板,新建配置 Nacos数据库配置 初始化mysql 修改配置文件 本文小结...

windows下安装nacos

windows下安装nacos

1、下载 下载地址:https://github.com/alibaba/nacos/releases/tag/1.1.0 选择这个zip下载。 下载完毕后我们可以看看目录结构: 这里的bin目录里面有windows启动文件startup.cmd,...

nacos LINUX 启动

nacos  sh startup.sh -m standalone 作者:cai_code 来源链接:https://blog.csdn.net/gaoduicai/article/details/122742762...

Nacos介绍与使用

Nacos介绍与使用

主要作用:动态更新,隔离操作,集中管理 一 背景分析 在微服务中,首先需要面对的问题就是如何查找服务(软件即服务),其次,就是如何在不同的服务之间进行通信?如何更好更方便的管理应用中的每一个服务,如何建立各个服务之间联系的纽带,由此注册中心诞生(例如淘宝网卖...

nacos配置中心无法连接或启动报错

nacos配置中心无法连接或启动报错

如果你启动后是下面这样的,那就说明你连接上了,并且红框中最右边的name就是你在配置中心里的DataId 如果你启动后没有上面那样或者是报错,并且你的代码没问题,那最有可能就是版本不兼容,可以参考下面的版本 <parent>...

Nacos入门基础

Nacos入门基础

一、Nacos 1、基本概念 (1) Nacos 是阿里巴巴推出来的一个新开源项目,是一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助...

ubuntu安装nacos

ubuntu安装nacos

1.下载nacos,github下载地址:https://github.com/alibaba/nacos/releases 选用目前最新的版本:1.3.0,这个版本直接在页面就可以修改nacos登录密码,并且还可以创建其他的登录用户,之前用过1.0.0版本如果修改naco...

Nacos安装及启动

Nacos安装及启动

目录 Nacos是什么 为什么要选择Nacos 环境准备 获取Nacos安装包 通过官网下载安装包 通过源码编译获取安装包 启...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。