Nacos2.1.2改造适配达梦数据库7.0

2023-12-26 23:02:27

出于业务需求,现将Nacos改造适配达梦数据库7.0,记录本次改造过程。

一、前期准备

对于Nacos的认识,可以点击Spring Cloud Alibaba–Nacos服务注册和配置中心查看了解

达梦数据库管理系统是达梦公司推出的具有完全自主知识产权的高性能数据库管理系统(即国产数据库),如图,安装完成,登录即可。

在这里插入图片描述
SYSDBA身份登录达梦,执行以下SQL,进行数据库配置:

--创建表空间
CREATE TABLESPACE  "NACOS" DATAFILE 'NACOS.DBF' SIZE 300 autoextend on maxsize 67108863 CACHE = NORMAL;
--创建用户
CREATE USER "NACOS" IDENTIFIED BY "123456789" LIMIT PASSWORD_LOCK_TIME 1, PASSWORD_GRACE_TIME 10 DEFAULT TABLESPACE "NACOS";
--给用户授权
GRANT "RESOURCE","PUBLIC","DBA","VTI" TO "NACOS";

创建NACOS模式下的表结构

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,
"ENCRYPTED_DATA_KEY" TEXT NOT NULL,
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_CONFIGINFO_DATAGROUPTENANT" UNIQUE("DATA_ID", "GROUP_ID", "TENANT_ID")) STORAGE(ON "NACOS", 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", 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", 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", 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 '',
"ENCRYPTED_DATA_KEY" TEXT NOT NULL,
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_CONFIGINFOBETA_DATAGROUPTENANT" UNIQUE("DATA_ID", "GROUP_ID", "TENANT_ID")) STORAGE(ON "NACOS", 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", 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", 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", 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", 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", CLUSTERBTR) ;
CREATE UNIQUE  INDEX "INDEX16096909541100" ON "NACOS"."CONFIG_TAGS_RELATION"("NID" ASC) STORAGE(ON "NACOS", 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", 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", 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 '',
"ENCRYPTED_DATA_KEY" TEXT NOT NULL,
NOT CLUSTER PRIMARY KEY("NID")) STORAGE(ON "NACOS", 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", CLUSTERBTR) ;
CREATE  INDEX "IDX_DID" ON "NACOS"."HIS_CONFIG_INFO"("DATA_ID" ASC) STORAGE(ON "NACOS", CLUSTERBTR) ;
CREATE  INDEX "IDX_GMT_MODIFIED" ON "NACOS"."HIS_CONFIG_INFO"("GMT_MODIFIED" ASC) STORAGE(ON "NACOS", CLUSTERBTR) ;
CREATE UNIQUE  INDEX "INDEX16096449256900" ON "NACOS"."HIS_CONFIG_INFO"("NID" ASC) STORAGE(ON "NACOS", 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", 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", 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", 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", 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", 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", CLUSTERBTR) ;
CREATE UNIQUE  INDEX "INDEX16095846853300" ON "NACOS"."TENANT_INFO"("ID" ASC) STORAGE(ON "NACOS", 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", CLUSTERBTR) ;
 
CREATE UNIQUE  INDEX "PRIMARY" ON "NACOS"."USERS"("USERNAME" ASC) STORAGE(ON "NACOS", CLUSTERBTR) ;
 
 
INSERT INTO nacos.users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
 
INSERT INTO nacos.roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
 
commit;

二、适配流程

1、项目初始化

IDEA打开源码,该项目是maven工程,配置好maven设置,将依赖成功导入。

在这里插入图片描述

2、引入驱动

1、父工程POM文件,properties中添加达梦驱动版本号,使父子工程保持版本一致。

 <dm-connector.version>7.6.0.77</dm-connector.version>

添加依赖:

    <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>Dm7JdbcDriver17</artifactId>
            <version>${dm-connector.version}</version>
    </dependency>

2、修改nacos-config模块、nacos-naming模块的pom文件,增加dm驱动依赖。

        <!-- 
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        -->
         <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>Dm7JdbcDriver17</artifactId>
            <version>${dm-connector.version}</version>
        </dependency>

3、源码修改

3、修改nacos-console模块的application.properties,增加链接达梦数据库的配置信息

#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=dm

### Count of DB:
db.num=1
db.jdbcDriverName=dm.jdbc.driver.DmDriver
### Connect URL of DB:
db.url.0=jdbc:dm://127.0.0.1:5236?scheme=NACOS&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
db.user.0=NACOS
db.password.0=123456789

4、修改nacos-config模块下的ExternalDataSourceProperties.java

  1. 注释Mysql的使用private static final String JDBC_DRIVER_NAME = "com.mysql.cj.jdbc.Driver;。
  2. 添加驱动属性private String jdbcDriverName;增加get()、set()方法。
  3. DataSourcePoolProperties指定驱动名称poolProperties.setDriverClassName(jdbcDriverName);

在这里插入图片描述在这里插入图片描述
5、修改nacos-config模块下PropertiesConstant.java类

修改public static final String DM = "dm";

123
6、修改nacos-config模块下PropertyUtil.java类

在这里插入图片描述
7、修改nacos-core模块下StartingApplicationListener.java类

private static final String DEFAULT_DATABASE = "dm";

在这里插入图片描述
8、修改ExternalRolePersistServiceImpl的findRolesLikeRoleName方法:

@Override
    public List<String> findRolesLikeRoleName(String role) {
        String sql = "SELECT role FROM roles WHERE role LIKE '%"+role+"%'";
        List<String> users = this.jt.queryForList(sql, String.class);
        return users;
    }

9、修改ExternalUserPersistServiceImpl的findUserLikeUsername方法:

   @Override
    public List<String> findUserLikeUsername(String username) {
        String sql = "SELECT username FROM users WHERE username LIKE '%"+username+"%'";
        List<String> users = this.jt.queryForList(sql, String.class);
        return users;
    }

三、启动测试

配置启动类,添加参数-Dnacos.standalone=true,单机模式启动。

在这里插入图片描述
浏览器访问:localhost:8848/nacos/,出现登录页面,启动成功。

在这里插入图片描述

四、打包测试

修改distribution模块下的application.properties配置文件,配置DM链接信息。

在这里插入图片描述
执行以下命令打包:

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

在这里插入图片描述
打包成功后,压缩包在nacos-distribution模块下target目录中,将该包复制到非中文目录下,停止IDEA启动的项目,进入bin目录,双击startup.cmd,启动成功。

在这里插入图片描述

浏览器输入localhost:8848/nacos,出现登录页面,启动成功,增加业务配置文件,美好日子开始了。

在这里插入图片描述

文章来源:https://blog.csdn.net/u012482647/article/details/135230536
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。