修改Nacos2.4.1原始碼-適配達夢資料庫&麒麟ARM系統(國產XC化)

Linux运维技术栈發表於2024-10-01

前言:應集團公司現在推廣XC化,其中基礎環境需要用麒麟ARM作業系統和達夢資料庫,而官網的nacos預設適配mysql,需要重新編譯原始碼來適配需要對接的資料庫,2.4.2試驗了一把,安裝啟動後 nacos 控制檯出現 “建立名稱空間失敗 / 資料庫語法問題”,經分析,問題出在原始碼的sql語法上,參考以下連結1。鑑於專案架構搭建時間緊急,最快的解決辦法是重新編譯 一版2.4.1 版本的原始碼包。下面將具體修改原始碼的方法和心得與大家分享下,另外鳴謝“連結2”作者的提點。

連結1: https://github.com/alibaba/nacos/issues/12625
連結2: https://blog.csdn.net/qq_26018075/article/details/141399170?spm=1001.2014.3001.5506
maven下載地址連結: https://maven.apache.org/download.cgi
達夢JDBC驅動包下載地址連結: https://eco.dameng.com/download/
jdk下載地址連結: https://www.oracle.com/java/technologies/downloads/#java17
nacos原始碼包下載連結: https://gitcode.com/gh_mirrors/na/nacos/tags/

第一步:安裝達夢驅動到maven本地倉庫
先進入存放DmJdbcDriver-1.8.jar的路徑:
cd C:\Users\ztt\Desktop\nacos-2.4.1原始碼改造-適配達夢\nacos-2.4.1原始碼改造-適配達夢
安裝驅動命令:
mvn install:install-file -Dfile=DmJdbcDriver-1.8.jar -DgroupId=dm.jdbc -DartifactId=DmJdbcDriver -Dversion=1.8 -Dpackaging=jar

待輸出:BUILD SUCCESS,說明安裝成功

第二步:新增DM(達夢)驅動
1、nacos-all的pom.xml檔案

<properties>
   <dm-jdbc.version>1.8</dm-jdbc.version>  
</properties>

<dependencies>
<dependency>  
    <groupId>dm.jdbc</groupId>  
    <artifactId>DmJdbcDriver</artifactId>  
    <version>${dm-jdbc.version}</version>  
</dependency>
</dependencies>

2、nacos-common、nacos-naming、nacos-config的pom.xml檔案

<dependencies>
<dependency>  
    <groupId>dm.jdbc</groupId>  
    <artifactId>DmJdbcDriver</artifactId>  
    <version>${dm-jdbc.version}</version>  
</dependency>
</dependencies>

第三步:修改原始碼-程式碼
1、DataSourceConstant 資料來源常量修改

class: com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant
新增 public static final String DM = “dm”;

新增:

public class DataSourceConstant {  
    public static final String MYSQL = "mysql";  
      
    public static final String DERBY = "derby";  
  
    public static final String DM = "dm";  
}

2、新增TrustedDmFunctionEnum
複製Mysql的TrustedMysqlFunctionEnum列舉到dm目錄,並修改名稱為:TrustedDmFunctionEnum。也可以展開

3、修改Mapper
連結:https://gitcode.com/gh_mirrors/ma/Mapper/overview?utm_source=highlight_word_gitcode&word=mapper&isLogin=1
目錄: com.alibaba.nacos.plugin.datasource.impl
①複製com.alibaba.nacos.plugin.datasource.impl.mysql -> com.alibaba.nacos.plugin.datasource.impl.dm
②修改mapper中的getDataSource方法,改為DataSourceConstant.DM
③修改AbstractMapperByDm中的getFunction方法com.alibaba.nacos.plugin.datasource.impl.dm.AbstractMapperByDm,使用TrustedDmFunctionEnum列舉

4、修改resoure
將datasource(nacos-datasource-plugin)工程 resources目錄下的META-INF/services/com.alibaba.nacos.plugin.datasource.mapper.Mapper修改為:DM字尾

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

5、新增DM程式介面卡
PersistenceConstant新增:public static final String DM = "dm";
目錄:class: com.alibaba.nacos.persistence.constants.PersistenceConstant`

6、新增DM分頁介面卡
目錄: com.alibaba.nacos.plugin.auth.impl.persistence.handler.support
在該目錄下新增DM介面卡類

public class DmPageHandlerAdapter implements PageHandlerAdapter {  
  
    @Override  
    public boolean supports(String dataSourceType) {  
        return PersistenceConstant.DM.equals(dataSourceType);  
    }  
  
    @Override  
    public OffsetFetchResult addOffsetAndFetchNext(String fetchSql, Object[] arg, int pageNo, int pageSize) {  
        if (!fetchSql.contains(AuthPageConstant.LIMIT)) {  
            fetchSql += " " + AuthPageConstant.LIMIT_SIZE;  
            List<Object> newArgsList = new ArrayList<>(Arrays.asList(arg));  
            newArgsList.add((pageNo - 1) * pageSize);  
            newArgsList.add(pageSize);  
  
            Object[] newArgs = newArgsList.toArray(new Object[0]);  
            return new OffsetFetchResult(fetchSql, newArgs);  
        }  
  
        return new OffsetFetchResult(fetchSql, arg);  
    }  
  
}

7、分頁適配工廠新增DM分頁介面卡
目錄: com.alibaba.nacos.plugin.auth.impl.persistence.handler.PageHandlerAdapterFactory
新增分頁介面卡:

private PageHandlerAdapterFactory() {  
    List<PageHandlerAdapter> handlerAdapters = new ArrayList<>(3);  
    Map<String, PageHandlerAdapter> handlerAdapterMap = new HashMap<>(3);  
    Consumer<PageHandlerAdapter> addHandlerAdapter = handlerAdapter -> {  
        handlerAdapters.add(handlerAdapter);  
        handlerAdapterMap.put(handlerAdapter.getClass().getName(), handlerAdapter);  
    };  
    // DmPageHandlerAdapter  
    addHandlerAdapter.accept(new DmPageHandlerAdapter());  
    // MysqlPageHandlerAdapter  
    addHandlerAdapter.accept(new MysqlPageHandlerAdapter());  
    // DerbyPageHandlerAdapter  
    addHandlerAdapter.accept(new DerbyPageHandlerAdapter());  
    // DefaultPageHandlerAdapter  
    addHandlerAdapter.accept(new DefaultPageHandlerAdapter());  
    this.handlerAdapters = Collections.unmodifiableList(handlerAdapters);  
    this.handlerAdapterMap = Collections.unmodifiableMap(handlerAdapterMap);  
}

8、修改資料來源配置類ExternalDataSourceProperties
目錄: com.alibaba.nacos.persistence.datasource.ExternalDataSourceProperties
新增屬性: private List jdbcDriverName

private List<String> jdbcDriverName = new ArrayList<>();  

public List<String> getJdbcDriverName() {  
    return jdbcDriverName;  
}  
  
public void setJdbcDriverName(List<String> jdbcDriverName) {  
    this.jdbcDriverName = jdbcDriverName;  
}

9、修改 build方法中的資料來源驅動部分
目錄: com.alibaba.nacos.persistence.datasource.ExternalDataSourceProperties#build
新增:
poolProperties.setDriverClassName(getOrDefault(jdbcDriverName,index,jdbcDriverName.get(index)).trim());

第四步:修改配置檔案
①修改工程distribution下的配置檔案application.properties路徑distribution/conf/application.properties;
②spring.sql.init.platform的值改為dm;
③新增db.jdbc-driver-name.0=dm.jdbc.driver.DmDriver;
④修改url為db.url.0=jdbc:dm://IP:5236/DB;

第五步:新增sql
將dm-scheme.sql新增到distribution的conf目錄下
sql內容:

CREATE TABLE "USERS"  
(  
 "USERNAME" VARCHAR(50) NOT NULL,  
 "PASSWORD" VARCHAR(500) NOT NULL,  
 "ENABLED" TINYINT NOT NULL  
);  
  
CREATE TABLE "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 "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 "ROLES"  
(  
 "USERNAME" VARCHAR(50) NOT NULL,  
 "ROLE" VARCHAR(50) NOT NULL  
);  
  
CREATE TABLE "PERMISSIONS"  
(  
 "ROLE" VARCHAR(50) NOT NULL,  
 "RESOURCE" VARCHAR(255) NOT NULL,  
 "ACTION" VARCHAR(8) NOT NULL  
);  
  
CREATE TABLE "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 "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 "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 "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 "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 "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 "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  
);  
  
SET IDENTITY_INSERT "CONFIG_INFO" ON;  
SET IDENTITY_INSERT "CONFIG_INFO" OFF;  
SET IDENTITY_INSERT "CONFIG_INFO_AGGR" ON;  
SET IDENTITY_INSERT "CONFIG_INFO_AGGR" OFF;  
SET IDENTITY_INSERT "CONFIG_INFO_BETA" ON;  
SET IDENTITY_INSERT "CONFIG_INFO_BETA" OFF;  
SET IDENTITY_INSERT "CONFIG_INFO_TAG" ON;  
SET IDENTITY_INSERT "CONFIG_INFO_TAG" OFF;  
SET IDENTITY_INSERT "CONFIG_TAGS_RELATION" ON;  
SET IDENTITY_INSERT "CONFIG_TAGS_RELATION" OFF;  
SET IDENTITY_INSERT "GROUP_CAPACITY" ON;  
SET IDENTITY_INSERT "GROUP_CAPACITY" OFF;  
SET IDENTITY_INSERT "HIS_CONFIG_INFO" ON;  
SET IDENTITY_INSERT "HIS_CONFIG_INFO" OFF;  
INSERT INTO "ROLES"("USERNAME","ROLE") VALUES('nacos','ROLE_ADMIN');  
  
SET IDENTITY_INSERT "TENANT_CAPACITY" ON;  
SET IDENTITY_INSERT "TENANT_CAPACITY" OFF;  
SET IDENTITY_INSERT "TENANT_INFO" ON;  
SET IDENTITY_INSERT "TENANT_INFO" OFF;  
INSERT INTO "USERS"("USERNAME","PASSWORD","ENABLED") VALUES('nacos','$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu',1);  
  
ALTER TABLE "USERS" ADD CONSTRAINT  PRIMARY KEY("USERNAME") ;  
  
ALTER TABLE "TENANT_INFO" ADD CONSTRAINT  PRIMARY KEY("ID") ;  
  
ALTER TABLE "TENANT_INFO" ADD CONSTRAINT "UK_TENANT_INFO_KPTENANTID" UNIQUE("KP","TENANT_ID") ;  
  
ALTER TABLE "TENANT_CAPACITY" ADD CONSTRAINT  PRIMARY KEY("ID") ;  
  
ALTER TABLE "TENANT_CAPACITY" ADD CONSTRAINT "UK_TENANT_ID" UNIQUE("TENANT_ID") ;  
  
ALTER TABLE "ROLES" ADD CONSTRAINT "IDX_USER_ROLE" UNIQUE("USERNAME","ROLE") ;  
  
ALTER TABLE "PERMISSIONS" ADD CONSTRAINT "UK_ROLE_PERMISSION" UNIQUE("ROLE","RESOURCE","ACTION") ;  
  
ALTER TABLE "HIS_CONFIG_INFO" ADD CONSTRAINT  PRIMARY KEY("NID") ;  
  
ALTER TABLE "GROUP_CAPACITY" ADD CONSTRAINT  PRIMARY KEY("ID") ;  
  
ALTER TABLE "GROUP_CAPACITY" ADD CONSTRAINT "UK_GROUP_ID" UNIQUE("GROUP_ID") ;  
  
ALTER TABLE "CONFIG_TAGS_RELATION" ADD CONSTRAINT  PRIMARY KEY("NID") ;  
  
ALTER TABLE "CONFIG_TAGS_RELATION" ADD CONSTRAINT "UK_CONFIGTAGRELATION_CONFIGIDTAG" UNIQUE("ID","TAG_NAME","TAG_TYPE") ;  
  
ALTER TABLE "CONFIG_INFO_TAG" ADD CONSTRAINT  PRIMARY KEY("ID") ;  
  
ALTER TABLE "CONFIG_INFO_TAG" ADD CONSTRAINT "UK_CONFIGINFOTAG_DATAGROUPTENANTTAG" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID","TAG_ID") ;  
  
ALTER TABLE "CONFIG_INFO_BETA" ADD CONSTRAINT  PRIMARY KEY("ID") ;  
  
ALTER TABLE "CONFIG_INFO_BETA" ADD CONSTRAINT "UK_CONFIGINFOBETA_DATAGROUPTENANT" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID") ;  
  
ALTER TABLE "CONFIG_INFO_AGGR" ADD CONSTRAINT  PRIMARY KEY("ID") ;  
  
ALTER TABLE "CONFIG_INFO_AGGR" ADD CONSTRAINT "UK_CONFIGINFOAGGR_DATAGROUPTENANTDATUM" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID","DATUM_ID") ;  
  
ALTER TABLE "CONFIG_INFO" ADD CONSTRAINT  PRIMARY KEY("ID") ;  
  
ALTER TABLE "CONFIG_INFO" ADD CONSTRAINT "UK_CONFIGINFO_DATAGROUPTENANT" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID") ;  
  
CREATE UNIQUE INDEX "PRIMARY"  
ON "USERS"("USERNAME");  
  
COMMENT ON COLUMN "USERS"."USERNAME" IS 'username';  
  
COMMENT ON COLUMN "USERS"."PASSWORD" IS 'password';  
  
COMMENT ON COLUMN "USERS"."ENABLED" IS 'enabled';  
  
CREATE INDEX "IDX_TENANT_ID"  
ON "TENANT_INFO"("TENANT_ID");  
  
CREATE UNIQUE INDEX "INDEX134402165964299"  
ON "TENANT_INFO"("ID");  
  
COMMENT ON TABLE "TENANT_INFO" IS 'tenant_info';  
  
COMMENT ON COLUMN "TENANT_INFO"."ID" IS 'id';  
  
COMMENT ON COLUMN "TENANT_INFO"."KP" IS 'kp';  
  
COMMENT ON COLUMN "TENANT_INFO"."TENANT_ID" IS 'tenant_id';  
  
COMMENT ON COLUMN "TENANT_INFO"."TENANT_NAME" IS 'tenant_name';  
  
COMMENT ON COLUMN "TENANT_INFO"."TENANT_DESC" IS 'tenant_desc';  
  
COMMENT ON COLUMN "TENANT_INFO"."CREATE_SOURCE" IS 'create_source';  
  
COMMENT ON COLUMN "TENANT_INFO"."GMT_CREATE" IS '建立時間';  
  
COMMENT ON COLUMN "TENANT_INFO"."GMT_MODIFIED" IS '修改時間';  
  
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("QUOTA" >= 0) ENABLE ;  
  
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_HISTORY_COUNT" >= 0) ENABLE ;  
  
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_AGGR_SIZE" >= 0) ENABLE ;  
  
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_AGGR_COUNT" >= 0) ENABLE ;  
  
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_SIZE" >= 0) ENABLE ;  
  
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("USAGE" >= 0) ENABLE ;  
  
CREATE UNIQUE INDEX "INDEX134403016796300"  
ON "TENANT_CAPACITY"("ID");  
  
COMMENT ON TABLE "TENANT_CAPACITY" IS '租戶容量資訊表';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."ID" IS '主鍵ID';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."TENANT_ID" IS 'Tenant ID';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."QUOTA" IS '配額,0表示使用預設值';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."USAGE" IS '使用量';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_SIZE" IS '單個配置大小上限,單位為位元組,0表示使用預設值';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大個數';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_AGGR_SIZE" IS '單個聚合資料的子配置大小上限,單位為位元組,0表示使用預設值';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_HISTORY_COUNT" IS '最大變更歷史數量';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."GMT_CREATE" IS '建立時間';  
  
COMMENT ON COLUMN "TENANT_CAPACITY"."GMT_MODIFIED" IS '修改時間';  
  
COMMENT ON COLUMN "ROLES"."USERNAME" IS 'username';  
  
COMMENT ON COLUMN "ROLES"."ROLE" IS 'role';  
  
COMMENT ON COLUMN "PERMISSIONS"."ROLE" IS 'role';  
  
COMMENT ON COLUMN "PERMISSIONS"."RESOURCE" IS 'resource';  
  
COMMENT ON COLUMN "PERMISSIONS"."ACTION" IS 'action';  
  
ALTER TABLE "HIS_CONFIG_INFO" ADD CHECK ("ID" >= 0) ENABLE ;  
  
CREATE INDEX "IDX_DID"  
ON "HIS_CONFIG_INFO"("DATA_ID");  
  
CREATE INDEX "IDX_GMT_MODIFIED"  
ON "HIS_CONFIG_INFO"("GMT_MODIFIED");  
  
CREATE INDEX "IDX_GMT_CREATE"  
ON "HIS_CONFIG_INFO"("GMT_CREATE");  
  
CREATE UNIQUE INDEX "INDEX134404266256800"  
ON "HIS_CONFIG_INFO"("NID");  
  
COMMENT ON TABLE "HIS_CONFIG_INFO" IS '多租戶改造';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."ID" IS 'id';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."NID" IS 'nid, 自增標識';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."DATA_ID" IS 'data_id';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."GROUP_ID" IS 'group_id';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."APP_NAME" IS 'app_name';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."CONTENT" IS 'content';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."MD5" IS 'md5';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."GMT_CREATE" IS '建立時間';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."GMT_MODIFIED" IS '修改時間';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."SRC_USER" IS 'source user';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."SRC_IP" IS 'source ip';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."OP_TYPE" IS 'operation type';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."TENANT_ID" IS '租戶欄位';  
  
COMMENT ON COLUMN "HIS_CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '金鑰';  
  
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("QUOTA" >= 0) ENABLE ;  
  
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_HISTORY_COUNT" >= 0) ENABLE ;  
  
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_AGGR_SIZE" >= 0) ENABLE ;  
  
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_AGGR_COUNT" >= 0) ENABLE ;  
  
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_SIZE" >= 0) ENABLE ;  
  
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("USAGE" >= 0) ENABLE ;  
  
CREATE UNIQUE INDEX "INDEX134405629453900"  
ON "GROUP_CAPACITY"("ID");  
  
COMMENT ON TABLE "GROUP_CAPACITY" IS '叢集、各Group容量資訊表';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."ID" IS '主鍵ID';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."GROUP_ID" IS 'Group ID,空字元表示整個叢集';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."QUOTA" IS '配額,0表示使用預設值';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."USAGE" IS '使用量';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_SIZE" IS '單個配置大小上限,單位為位元組,0表示使用預設值';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大個數,,0表示使用預設值';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_AGGR_SIZE" IS '單個聚合資料的子配置大小上限,單位為位元組,0表示使用預設值';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_HISTORY_COUNT" IS '最大變更歷史數量';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."GMT_CREATE" IS '建立時間';  
  
COMMENT ON COLUMN "GROUP_CAPACITY"."GMT_MODIFIED" IS '修改時間';  
  
CREATE INDEX "INDEX134406418558100"  
ON "CONFIG_TAGS_RELATION"("TENANT_ID");  
  
CREATE UNIQUE INDEX "INDEX134406537578900"  
ON "CONFIG_TAGS_RELATION"("NID");  
  
COMMENT ON TABLE "CONFIG_TAGS_RELATION" IS 'config_tag_relation';  
  
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."ID" IS 'id';  
  
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."TAG_NAME" IS 'tag_name';  
  
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."TAG_TYPE" IS 'tag_type';  
  
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."DATA_ID" IS 'data_id';  
  
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."GROUP_ID" IS 'group_id';  
  
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."TENANT_ID" IS 'tenant_id';  
  
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."NID" IS 'nid, 自增長標識';  
  
CREATE UNIQUE INDEX "INDEX134407033963000"  
ON "CONFIG_INFO_TAG"("ID");  
  
COMMENT ON TABLE "CONFIG_INFO_TAG" IS 'config_info_tag';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."ID" IS 'id';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."DATA_ID" IS 'data_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."GROUP_ID" IS 'group_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."TENANT_ID" IS 'tenant_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."TAG_ID" IS 'tag_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."APP_NAME" IS 'app_name';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."CONTENT" IS 'content';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."MD5" IS 'md5';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."GMT_CREATE" IS '建立時間';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."GMT_MODIFIED" IS '修改時間';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."SRC_USER" IS 'source user';  
  
COMMENT ON COLUMN "CONFIG_INFO_TAG"."SRC_IP" IS 'source ip';  
  
CREATE UNIQUE INDEX "INDEX134407798104699"  
ON "CONFIG_INFO_BETA"("ID");  
  
COMMENT ON TABLE "CONFIG_INFO_BETA" IS 'config_info_beta';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."ID" IS 'id';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."DATA_ID" IS 'data_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."GROUP_ID" IS 'group_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."APP_NAME" IS 'app_name';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."CONTENT" IS 'content';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."BETA_IPS" IS 'betaIps';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."MD5" IS 'md5';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."GMT_CREATE" IS '建立時間';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."GMT_MODIFIED" IS '修改時間';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."SRC_USER" IS 'source user';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."SRC_IP" IS 'source ip';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."TENANT_ID" IS '租戶欄位';  
  
COMMENT ON COLUMN "CONFIG_INFO_BETA"."ENCRYPTED_DATA_KEY" IS '金鑰';  
  
CREATE UNIQUE INDEX "INDEX134408619300900"  
ON "CONFIG_INFO_AGGR"("ID");  
  
COMMENT ON TABLE "CONFIG_INFO_AGGR" IS '增加租戶欄位';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."ID" IS 'id';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."DATA_ID" IS 'data_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."GROUP_ID" IS 'group_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."DATUM_ID" IS 'datum_id';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."CONTENT" IS '內容';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."GMT_MODIFIED" IS '修改時間';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."APP_NAME" IS 'app_name';  
  
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."TENANT_ID" IS '租戶欄位';  
  
CREATE UNIQUE INDEX "INDEX134409166029299"  
ON "CONFIG_INFO"("ID");  
  
COMMENT ON TABLE "CONFIG_INFO" IS 'config_info';  
  
COMMENT ON COLUMN "CONFIG_INFO"."ID" IS 'id';  
  
COMMENT ON COLUMN "CONFIG_INFO"."DATA_ID" IS 'data_id';  
  
COMMENT ON COLUMN "CONFIG_INFO"."GROUP_ID" IS 'group_id';  
  
COMMENT ON COLUMN "CONFIG_INFO"."CONTENT" IS 'content';  
  
COMMENT ON COLUMN "CONFIG_INFO"."MD5" IS 'md5';  
  
COMMENT ON COLUMN "CONFIG_INFO"."GMT_CREATE" IS '建立時間';  
  
COMMENT ON COLUMN "CONFIG_INFO"."GMT_MODIFIED" IS '修改時間';  
  
COMMENT ON COLUMN "CONFIG_INFO"."SRC_USER" IS 'source user';  
  
COMMENT ON COLUMN "CONFIG_INFO"."SRC_IP" IS 'source ip';  
  
COMMENT ON COLUMN "CONFIG_INFO"."APP_NAME" IS 'app_name';  
  
COMMENT ON COLUMN "CONFIG_INFO"."TENANT_ID" IS '租戶欄位';  
  
COMMENT ON COLUMN "CONFIG_INFO"."C_DESC" IS 'configuration description';  
  
COMMENT ON COLUMN "CONFIG_INFO"."C_USE" IS 'configuration usage';  
  
COMMENT ON COLUMN "CONFIG_INFO"."EFFECT" IS '配置生效的描述';  
  
COMMENT ON COLUMN "CONFIG_INFO"."TYPE" IS '配置的型別';  
  
COMMENT ON COLUMN "CONFIG_INFO"."C_SCHEMA" IS '配置的模式';  
  
COMMENT ON COLUMN "CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '金鑰';

第六步:編譯打包
可以將修改好的原始碼包複製到Linux-麒麟ARM系統上進行編譯打包,也可以在本機直接打包
命令:mvn -Prelease-nacos clean install -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dpmd.skip=true -Drat.skip=true -U
編譯好的包通常會出現在原始碼根目錄下的target資料夾中,一個為.tar.gz,一個為.zip檔案

最後收到集團高階架構師和領導的好評:


相關文章