美文网首页
nacos基于达梦数据库实现服务部署

nacos基于达梦数据库实现服务部署

作者: 初心myp | 来源:发表于2023-02-15 13:39 被阅读0次

一、nacos替换mysql为达梦数据库

1. 下载nacos源码,源码可以从GitHub或者Gitee上下载,建议使用Gitee,GitHub由于服务器在国外,下载速度较慢。

GitHub下载地址:https://github.com/alibaba/nacos/releases?q=2.1.1&expanded=true
Gitee下载地址:https://gitee.com/mirrors/Nacos/tree/2.1.2
我用的github,如下图:

image.png
image.png

2. 将源码导入IntelliJ IDEA中,选择好maven配置和jdk版本等待项目加载完成

3. 使用Maven编译项目源码

image.png

4. 引入达梦数据库驱动,这里注意修改三个pom文件

4.1 修改父工程下的pom文件,在<dependencyManagement></dependencyManagement>标签中注释掉MySQL的驱动依赖,加入达梦数据库驱动依赖,版本我们选择8.1.1.193
            <dependency>
                <groupId>com.dameng</groupId>
                <artifactId>DmJdbcDriver18</artifactId>
                <version>8.1.1.193</version>
            </dependency>
image.png
4.2 修改naming模块下的pom文件,注释掉MySQL的驱动依赖,加入达梦数据库驱动依赖,版本自动从父工程继承
        <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>DmJdbcDriver18</artifactId>
        </dependency>
image.png
4.3 修改config模块下的pom文件,注释掉MySQL的驱动依赖,加入达梦数据库驱动依赖
        <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>DmJdbcDriver18</artifactId>
        </dependency>
image.png

5. 修改console模块下的application.properties文件,更换掉mysql的配置,表空间名,用户名,密码根据自己数据库情况替换即可。console模块是整个nacos的启动入口

spring.datasource.platform=dm

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:dm://127.0.0.1:5236/NACOS_CONFIG?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
db.user.0=NACOS_CONFIG
db.password.0=123456
image.png

6. 修改distribution模块下的application.properties文件,修改方式和console模块一样。这个配置就是打包完成后的配置文件,因此,也需要修改。同时,启动脚本也在bin目录下。

spring.datasource.platform=dm

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:dm://127.0.0.1:5236/NACOS_CONFIG?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
db.user.0=NACOS_CONFIG
db.password.0=123456
image.png

7. 修改 nacos-config模块下的com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceProperties.java文件,将mysql驱动换成达梦的驱动

private static final String JDBC_DRIVER_NAME = "dm.jdbc.driver.DmDriver";
image.png

8. 修改 com/alibaba/nacos/config/server/constant/PropertiesConstant.java

把 public static final String DM = "mysql"替换为 public static final String DM = “dm”

image.png

9. 修改com/alibaba/nacos/config/server/utils/PropertyUtil.java

setUseExternalDB(PropertiesConstant.MYSQL.equalsIgnoreCase(getString(PropertiesConstant.SPRING_DATASOURCE_PLATFORM, ""))); 改为 setUseExternalDB(PropertiesConstant.DM.equalsIgnoreCase(getString(PropertiesConstant.SPRING_DATASOURCE_PLATFORM, "")));
PS:nacos本身也是个springboot项目,启动时会根据提前配置的信息选择性的进行容器化管理。这里添加这里的目的也是为了让我们之前修改的ExternalDataSourceProperties类配置生效

image.png

10. 修改com.alibaba.nacos.core.listener.StartingApplicationListener.java

把private static final String DEFAULT_DATABASE = "msyql"改为private static final String DEFAULT_DATABASE = “dm”。如果不更改,启动日志会打印Nacos started successfully in stanalone mode. use embedded storage的错误日志,正确的日志是Nacos started successfully in stanalone mode. use external storage,会给人造成误解。embedded storage的意思是使用了嵌入式存储,其实使用了达梦数据库。

image.png

11. 编辑启动类,加入-Dnacos.standalone=true参数,意思是以单机模式启动,启动类在console/src/main/java/com/alibaba/nacos/Nacos.java

image.png

12. 创建数据库表sql

CREATE TABLE "NACOS_CONFIG"."CONFIG_INFO"
(
"ID" BIGINT IDENTITY(1384, 1) NOT NULL,
"DATA_ID" VARCHAR(255 CHAR) NOT NULL,
"GROUP_ID" VARCHAR(255 CHAR),
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32 CHAR),
"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 CHAR),
"APP_NAME" VARCHAR(128 CHAR),
"TENANT_ID" VARCHAR(128 CHAR) DEFAULT '',
"C_DESC" VARCHAR(256 CHAR),
"C_USE" VARCHAR(64 CHAR),
"EFFECT" VARCHAR(64 CHAR),
"TYPE" VARCHAR(64 CHAR),
"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 "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."CONFIG_INFO" IS 'config_info';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."CONTENT" IS 'content';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '秘钥';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."ID" IS 'id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."MD5" IS 'md5';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."SRC_IP" IS 'source ip';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."SRC_USER" IS 'source user';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO"."TENANT_ID" IS '租户字段';


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

COMMENT ON TABLE "NACOS_CONFIG"."CONFIG_INFO_AGGR" IS '增加租户字段';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_AGGR"."CONTENT" IS '内容';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_AGGR"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_AGGR"."DATUM_ID" IS 'datum_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_AGGR"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_AGGR"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_AGGR"."ID" IS 'id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_AGGR"."TENANT_ID" IS '租户字段';


CREATE TABLE "NACOS_CONFIG"."CONFIG_INFO_BETA"
(
"ID" BIGINT IDENTITY(1, 1) NOT NULL,
"DATA_ID" VARCHAR(255 CHAR) NOT NULL,
"GROUP_ID" VARCHAR(128 CHAR) NOT NULL,
"APP_NAME" VARCHAR(128 CHAR),
"CONTENT" CLOB NOT NULL,
"BETA_IPS" VARCHAR(1024 CHAR),
"MD5" VARCHAR(32 CHAR),
"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 CHAR),
"TENANT_ID" VARCHAR(128 CHAR) 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 "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."CONFIG_INFO_BETA" IS 'config_info_beta';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."BETA_IPS" IS 'betaIps';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."CONTENT" IS 'content';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."ENCRYPTED_DATA_KEY" IS '秘钥';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."ID" IS 'id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."MD5" IS 'md5';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."SRC_IP" IS 'source ip';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."SRC_USER" IS 'source user';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_BETA"."TENANT_ID" IS '租户字段';


CREATE TABLE "NACOS_CONFIG"."CONFIG_INFO_TAG"
(
"ID" BIGINT IDENTITY(1, 1) NOT NULL,
"DATA_ID" VARCHAR(255 CHAR) NOT NULL,
"GROUP_ID" VARCHAR(128 CHAR) NOT NULL,
"TENANT_ID" VARCHAR(128 CHAR) DEFAULT '',
"TAG_ID" VARCHAR(128 CHAR) NOT NULL,
"APP_NAME" VARCHAR(128 CHAR),
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32 CHAR),
"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 CHAR),
NOT CLUSTER PRIMARY KEY("ID"),
CONSTRAINT "UK_CONFIGINFOTAG_DATAGROUPTENANTTAG" UNIQUE("DATA_ID", "GROUP_ID", "TENANT_ID", "TAG_ID")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."CONFIG_INFO_TAG" IS 'config_info_tag';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."CONTENT" IS 'content';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."ID" IS 'id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."MD5" IS 'md5';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."SRC_IP" IS 'source ip';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."SRC_USER" IS 'source user';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."TAG_ID" IS 'tag_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_INFO_TAG"."TENANT_ID" IS 'tenant_id';


CREATE TABLE "NACOS_CONFIG"."CONFIG_TAGS_RELATION"
(
"ID" BIGINT NOT NULL,
"TAG_NAME" VARCHAR(128 CHAR) NOT NULL,
"TAG_TYPE" VARCHAR(64 CHAR),
"DATA_ID" VARCHAR(255 CHAR) NOT NULL,
"GROUP_ID" VARCHAR(128 CHAR) NOT NULL,
"TENANT_ID" VARCHAR(128 CHAR) 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 "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."CONFIG_TAGS_RELATION" IS 'config_tag_relation';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_TAGS_RELATION"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_TAGS_RELATION"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_TAGS_RELATION"."ID" IS 'id';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_TAGS_RELATION"."TAG_NAME" IS 'tag_name';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_TAGS_RELATION"."TAG_TYPE" IS 'tag_type';
COMMENT ON COLUMN "NACOS_CONFIG"."CONFIG_TAGS_RELATION"."TENANT_ID" IS 'tenant_id';


CREATE  INDEX "IDX_TENANT_ID" ON "NACOS_CONFIG"."CONFIG_TAGS_RELATION"("TENANT_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

CREATE TABLE "NACOS_CONFIG"."GROUP_CAPACITY"
(
"ID" BIGINT IDENTITY(1, 1) NOT NULL,
"GROUP_ID" VARCHAR(128 CHAR) 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 "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."GROUP_CAPACITY" IS '集群、各Group容量信息表';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."GROUP_ID" IS 'Group ID,空字符表示整个集群';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."ID" IS '主键ID';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大个数,,0表示使用默认值';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."MAX_SIZE" IS '单个配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."QUOTA" IS '配额,0表示使用默认值';
COMMENT ON COLUMN "NACOS_CONFIG"."GROUP_CAPACITY"."USAGE" IS '使用量';


CREATE TABLE "NACOS_CONFIG"."HIS_CONFIG_INFO"
(
"ID" DECIMAL(20,0) NOT NULL,
"NID" BIGINT IDENTITY(1387, 1) NOT NULL,
"DATA_ID" VARCHAR(255 CHAR) NOT NULL,
"GROUP_ID" VARCHAR(128 CHAR) NOT NULL,
"APP_NAME" VARCHAR(128 CHAR),
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32 CHAR),
"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 CHAR),
"OP_TYPE" CHAR(10),
"TENANT_ID" VARCHAR(128 CHAR) DEFAULT '',
"ENCRYPTED_DATA_KEY" TEXT NOT NULL,
NOT CLUSTER PRIMARY KEY("NID"),
CHECK("ID" >= 0)) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."HIS_CONFIG_INFO" IS '多租户改造';
COMMENT ON COLUMN "NACOS_CONFIG"."HIS_CONFIG_INFO"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "NACOS_CONFIG"."HIS_CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '秘钥';
COMMENT ON COLUMN "NACOS_CONFIG"."HIS_CONFIG_INFO"."TENANT_ID" IS '租户字段';


CREATE  INDEX "IDX_GMT_CREATE" ON "NACOS_CONFIG"."HIS_CONFIG_INFO"("GMT_CREATE" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;
CREATE  INDEX "IDX_DID" ON "NACOS_CONFIG"."HIS_CONFIG_INFO"("DATA_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;
CREATE  INDEX "IDX_GMT_MODIFIED" ON "NACOS_CONFIG"."HIS_CONFIG_INFO"("GMT_MODIFIED" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

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

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

CREATE TABLE "NACOS_CONFIG"."TENANT_CAPACITY"
(
"ID" BIGINT IDENTITY(1, 1) NOT NULL,
"TENANT_ID" VARCHAR(128 CHAR) 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 "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."TENANT_CAPACITY" IS '租户容量信息表';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."ID" IS '主键ID';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大个数';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."MAX_SIZE" IS '单个配置大小上限,单位为字节,0表示使用默认值';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."QUOTA" IS '配额,0表示使用默认值';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."TENANT_ID" IS 'Tenant ID';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_CAPACITY"."USAGE" IS '使用量';


CREATE TABLE "NACOS_CONFIG"."TENANT_INFO"
(
"ID" BIGINT IDENTITY(5, 1) NOT NULL,
"KP" VARCHAR(128 CHAR) NOT NULL,
"TENANT_ID" VARCHAR(128 CHAR) DEFAULT '',
"TENANT_NAME" VARCHAR(128 CHAR) DEFAULT '',
"TENANT_DESC" VARCHAR(256 CHAR),
"CREATE_SOURCE" VARCHAR(32 CHAR),
"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 "MAIN", CLUSTERBTR) ;

COMMENT ON TABLE "NACOS_CONFIG"."TENANT_INFO" IS 'tenant_info';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."CREATE_SOURCE" IS 'create_source';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."ID" IS 'id';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."KP" IS 'kp';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."TENANT_DESC" IS 'tenant_desc';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."TENANT_ID" IS 'tenant_id';
COMMENT ON COLUMN "NACOS_CONFIG"."TENANT_INFO"."TENANT_NAME" IS 'tenant_name';


CREATE  INDEX "INDEX202172823508386" ON "NACOS_CONFIG"."TENANT_INFO"("TENANT_ID" ASC) STORAGE(ON "MAIN", CLUSTERBTR) ;

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

INSERT INTO "NACOS_CONFIG"."ROLES" (username, role) VALUES ('nacos', 'ROLE_ADMIN');

-- 添加用户 nacos  密码 nacos
insert into "NACOS_CONFIG"."USERS"("USERNAME", "PASSWORD", "ENABLED") 
VALUES('nacos', '$2a$10$YQVillBlvHoHehroIVIKg.e9U4cz1mS1V00PVRSxRAWOKUQqIOax6', 1);

二、语法适配达梦数据库

研究nacos源码发现:nacos中的SQL书写规范,绝大多数功能不需要改写SQL

三、源码打包

所有的修改完成后,就可以对源码进行打包了,由于nacos打包时有着严格的编码格式校验和新增文件Lisence权限认证的问题,我们需要做以下更改:

跳过格式校验:Nacos(all) pom.xml Build plugins配置中启用了格式校验插件,在pom.xml中找到maven-pmd-plugin,maven-checkstyle-plugin相关控件配置,注释掉。
跳过认证:Nacos(all) pom.xml 配置中,找到apache-rat-plugin控件组,注释掉相关插件配置。

注释掉如下build配置:

image.png
image.png
image.png

更改完成后以管理员身份运行cmd,进入nacos源码目录位置 D:\Nacos-2.1.1\,执行mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U打包命令,打包成功后的压缩包在Nacos-2.1.1\distribution\target\nacos-server-2.1.1.zip

nacos更换达梦数据库就完成了,本文参考https://blog.csdn.net/weixin_40484820/article/details/127610640文档完成,并根据实际情况进行修改!!!

相关文章

网友评论

      本文标题:nacos基于达梦数据库实现服务部署

      本文链接:https://www.haomeiwen.com/subject/kqgykdtx.html