注册
【与达梦同行】信创Nacos适配达梦
技术分享/ 文章详情 /

【与达梦同行】信创Nacos适配达梦

风吹屁屁凉 2022/12/09 2472 150 1

什么是 Nacos?

服务(Service)是 Nacos 世界的一等公民。Nacos 支持几乎所有主流类型的“服务”的发现、配置和管理:

Kubernetes Service

gRPC & Dubbo RPC Service

Spring Cloud RESTful Service

Nacos 的关键特性包括:

服务发现和服务健康监测

Nacos 支持基于 DNS 和基于 RPC 的服务发现。服务提供者使用 原生SDK、OpenAPI、或一个独立的Agent TODO注册 Service 后,服务消费者可以使用DNS TODO 或HTTP&API查找和发现服务。

Nacos 提供对服务的实时的健康检查,阻止向不健康的主机或服务实例发送请求。Nacos 支持传输层 (PING 或 TCP)和应用层 (如 HTTP、MySQL、用户自定义)的健康检查。 对于复杂的云环境和网络拓扑环境中(如 VPC、边缘网络等)服务的健康检查,Nacos 提供了 agent 上报模式和服务端主动检测2种健康检查模式。Nacos 还提供了统一的健康检查仪表盘,帮助您根据健康状态管理服务的可用性及流量。

动态配置服务

动态配置服务可以让您以中心化、外部化和动态化的方式管理所有环境的应用配置和服务配置。

动态配置消除了配置变更时重新部署应用和服务的需要,让配置管理变得更加高效和敏捷。

配置中心化管理让实现无状态服务变得更简单,让服务按需弹性扩展变得更容易。

Nacos 提供了一个简洁易用的UI (控制台样例 Demo) 帮助您管理所有的服务和应用的配置。Nacos 还提供包括配置版本跟踪、金丝雀发布、一键回滚配置以及客户端配置更新状态跟踪在内的一系列开箱即用的配置管理特性,帮助您更安全地在生产环境中管理配置变更和降低配置变更带来的风险。

动态 DNS 服务

动态 DNS 服务支持权重路由,让您更容易地实现中间层负载均衡、更灵活的路由策略、流量控制以及数据中心内网的简单DNS解析服务。动态DNS服务还能让您更容易地实现以 DNS 协议为基础的服务发现,以帮助您消除耦合到厂商私有服务发现 API 上的风险。

Nacos 提供了一些简单的 DNS APIs TODO 帮助您管理服务的关联域名和可用的 IP:PORT 列表.

服务及其元数据管理

Nacos 能让您从微服务平台建设的视角管理数据中心的所有服务及元数据,包括管理服务的描述、生命周期、服务的静态依赖分析、服务的健康状态、服务的流量管理、路由及安全策略、服务的 SLA 以及最首要的 metrics 统计数据。

开始使用

1.github下载nacos源码:
2.jpg

2.在父pom.xmldependencies节点里添加达梦数据驱动

        <dependency>
            <groupId>com.dameng</groupId>
            <artifactId>Dm8JdbcDriver18</artifactId>
            <version>8.1.1.49</version>
        </dependency>

3.找到ExternalDataSourceProperties.java文件修改JDBC_DRIVER_NAME 常量

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

4.nacos-dm.sql数据脚本放到distribution/conf目录中一定要加入许可信息不然打包会出错

/*
 * Copyright 1999-2018 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
 *
 *    
 *
 * 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.
 */

/*
 Navicat Premium Data Transfer

 Source Server         : 192.192.192.181
 Source Server Type    : SQL Server
 Source Server Version : 13005026
 Source Host           : 192.192.192.181:1433
 Source Catalog        : nacos2.0.3
 Source Schema         : dbo

 Target Server Type    : SQL Server
 Target Server Version : 13005026
 File Encoding         : 65001

 Date: 12/01/2022 14:34:19
*/


-- ----------------------------
-- Table structure for config_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[config_info]') AND type IN ('U'))
	DROP TABLE [dbo].[config_info]
GO

CREATE TABLE [dbo].[config_info] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [data_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [group_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NULL,
  [content] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [md5] nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
  [gmt_create] datetime2(7)  NULL,
  [gmt_modified] datetime2(7)  NULL,
  [src_user] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [src_ip] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [app_name] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [c_desc] nvarchar(256) COLLATE Chinese_PRC_CI_AS  NULL,
  [c_use] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
  [effect] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
  [type] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
  [c_schema] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[config_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'data_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'data_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'content',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'content'
GO

EXEC sp_addextendedproperty
'MS_Description', N'md5',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'md5'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'gmt_modified'
GO

EXEC sp_addextendedproperty
'MS_Description', N'source user',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'src_user'
GO

EXEC sp_addextendedproperty
'MS_Description', N'source ip',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'src_ip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户字段',
'SCHEMA', N'dbo',
'TABLE', N'config_info',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'config_info',
'SCHEMA', N'dbo',
'TABLE', N'config_info'
GO


-- ----------------------------
-- Records of config_info
-- ----------------------------
SET IDENTITY_INSERT [dbo].[config_info] ON
GO

SET IDENTITY_INSERT [dbo].[config_info] OFF
GO


-- ----------------------------
-- Table structure for config_info_aggr
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[config_info_aggr]') AND type IN ('U'))
	DROP TABLE [dbo].[config_info_aggr]
GO

CREATE TABLE [dbo].[config_info_aggr] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [data_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [group_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [datum_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [content] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [gmt_modified] datetime2(7)  NULL,
  [app_name] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[config_info_aggr] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'data_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr',
'COLUMN', N'data_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'group_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr',
'COLUMN', N'group_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'datum_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr',
'COLUMN', N'datum_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'内容',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr',
'COLUMN', N'content'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr',
'COLUMN', N'gmt_modified'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户字段',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'增加租户字段',
'SCHEMA', N'dbo',
'TABLE', N'config_info_aggr'
GO


-- ----------------------------
-- Records of config_info_aggr
-- ----------------------------
SET IDENTITY_INSERT [dbo].[config_info_aggr] ON
GO

SET IDENTITY_INSERT [dbo].[config_info_aggr] OFF
GO


-- ----------------------------
-- Table structure for config_info_beta
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[config_info_beta]') AND type IN ('U'))
	DROP TABLE [dbo].[config_info_beta]
GO

CREATE TABLE [dbo].[config_info_beta] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [data_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [group_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [app_name] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [content] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [beta_ips] nvarchar(1024) COLLATE Chinese_PRC_CI_AS  NULL,
  [md5] nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
  [gmt_create] datetime2(7)  NULL,
  [gmt_modified] datetime2(7)  NULL,
  [src_user] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [src_ip] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[config_info_beta] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'data_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'data_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'group_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'group_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'app_name',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'app_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'content',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'content'
GO

EXEC sp_addextendedproperty
'MS_Description', N'betaIps',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'beta_ips'
GO

EXEC sp_addextendedproperty
'MS_Description', N'md5',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'md5'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'gmt_modified'
GO

EXEC sp_addextendedproperty
'MS_Description', N'source user',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'src_user'
GO

EXEC sp_addextendedproperty
'MS_Description', N'source ip',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'src_ip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户字段',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'config_info_beta',
'SCHEMA', N'dbo',
'TABLE', N'config_info_beta'
GO


-- ----------------------------
-- Records of config_info_beta
-- ----------------------------
SET IDENTITY_INSERT [dbo].[config_info_beta] ON
GO

SET IDENTITY_INSERT [dbo].[config_info_beta] OFF
GO


-- ----------------------------
-- Table structure for config_info_tag
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[config_info_tag]') AND type IN ('U'))
	DROP TABLE [dbo].[config_info_tag]
GO

CREATE TABLE [dbo].[config_info_tag] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [data_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [group_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [tag_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [app_name] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [content] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [md5] nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
  [gmt_create] datetime2(7)  NULL,
  [gmt_modified] datetime2(7)  NULL,
  [src_user] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [src_ip] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[config_info_tag] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'data_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'data_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'group_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'group_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tenant_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tag_id',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'tag_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'app_name',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'app_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'content',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'content'
GO

EXEC sp_addextendedproperty
'MS_Description', N'md5',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'md5'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'gmt_modified'
GO

EXEC sp_addextendedproperty
'MS_Description', N'source user',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'src_user'
GO

EXEC sp_addextendedproperty
'MS_Description', N'source ip',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag',
'COLUMN', N'src_ip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'config_info_tag',
'SCHEMA', N'dbo',
'TABLE', N'config_info_tag'
GO


-- ----------------------------
-- Records of config_info_tag
-- ----------------------------
SET IDENTITY_INSERT [dbo].[config_info_tag] ON
GO

SET IDENTITY_INSERT [dbo].[config_info_tag] OFF
GO


-- ----------------------------
-- Table structure for config_tags_relation
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[config_tags_relation]') AND type IN ('U'))
	DROP TABLE [dbo].[config_tags_relation]
GO

CREATE TABLE [dbo].[config_tags_relation] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [tag_name] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [tag_type] nvarchar(64) COLLATE Chinese_PRC_CI_AS  NULL,
  [data_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [group_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [nid] bigint  NOT NULL
)
GO

ALTER TABLE [dbo].[config_tags_relation] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'config_tags_relation',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tag_name',
'SCHEMA', N'dbo',
'TABLE', N'config_tags_relation',
'COLUMN', N'tag_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tag_type',
'SCHEMA', N'dbo',
'TABLE', N'config_tags_relation',
'COLUMN', N'tag_type'
GO

EXEC sp_addextendedproperty
'MS_Description', N'data_id',
'SCHEMA', N'dbo',
'TABLE', N'config_tags_relation',
'COLUMN', N'data_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'group_id',
'SCHEMA', N'dbo',
'TABLE', N'config_tags_relation',
'COLUMN', N'group_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tenant_id',
'SCHEMA', N'dbo',
'TABLE', N'config_tags_relation',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'config_tag_relation',
'SCHEMA', N'dbo',
'TABLE', N'config_tags_relation'
GO


-- ----------------------------
-- Records of config_tags_relation
-- ----------------------------
SET IDENTITY_INSERT [dbo].[config_tags_relation] ON
GO

SET IDENTITY_INSERT [dbo].[config_tags_relation] OFF
GO


-- ----------------------------
-- Table structure for group_capacity
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[group_capacity]') AND type IN ('U'))
	DROP TABLE [dbo].[group_capacity]
GO

CREATE TABLE [dbo].[group_capacity] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [group_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [quota] int  NOT NULL,
  [usage] int  NOT NULL,
  [max_size] int  NOT NULL,
  [max_aggr_count] int  NOT NULL,
  [max_aggr_size] int  NOT NULL,
  [max_history_count] int  NOT NULL,
  [gmt_create] datetime2(7)  NULL,
  [gmt_modified] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[group_capacity] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键ID',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'Group ID,空字符表示整个集群',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'group_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'配额,0表示使用默认值',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'quota'
GO

EXEC sp_addextendedproperty
'MS_Description', N'使用量',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'usage'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单个配置大小上限,单位为字节,0表示使用默认值',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'max_size'
GO

EXEC sp_addextendedproperty
'MS_Description', N'聚合子配置最大个数,,0表示使用默认值',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'max_aggr_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'max_aggr_size'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最大变更历史数量',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'max_history_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity',
'COLUMN', N'gmt_modified'
GO

EXEC sp_addextendedproperty
'MS_Description', N'集群、各Group容量信息表',
'SCHEMA', N'dbo',
'TABLE', N'group_capacity'
GO


-- ----------------------------
-- Records of group_capacity
-- ----------------------------
SET IDENTITY_INSERT [dbo].[group_capacity] ON
GO

SET IDENTITY_INSERT [dbo].[group_capacity] OFF
GO


-- ----------------------------
-- Table structure for his_config_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[his_config_info]') AND type IN ('U'))
	DROP TABLE [dbo].[his_config_info]
GO

CREATE TABLE [dbo].[his_config_info] (
  [id] bigint  NOT NULL,
  [nid] bigint  IDENTITY(1,1) NOT NULL,
  [data_id] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [group_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [app_name] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [content] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [md5] nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
  [gmt_create] datetime2(7)  NULL,
  [gmt_modified] datetime2(7)  NULL,
  [src_user] nvarchar(max) COLLATE Chinese_PRC_CI_AS  NULL,
  [src_ip] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [op_type] nchar(10) COLLATE Chinese_PRC_CI_AS  NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL
)
GO

ALTER TABLE [dbo].[his_config_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'app_name',
'SCHEMA', N'dbo',
'TABLE', N'his_config_info',
'COLUMN', N'app_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户字段',
'SCHEMA', N'dbo',
'TABLE', N'his_config_info',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'多租户改造',
'SCHEMA', N'dbo',
'TABLE', N'his_config_info'
GO


-- ----------------------------
-- Records of his_config_info
-- ----------------------------
SET IDENTITY_INSERT [dbo].[his_config_info] ON
GO

SET IDENTITY_INSERT [dbo].[his_config_info] OFF
GO


-- ----------------------------
-- Table structure for permissions
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[permissions]') AND type IN ('U'))
	DROP TABLE [dbo].[permissions]
GO

CREATE TABLE [dbo].[permissions] (
  [role] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [resource] nvarchar(255) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [action] nvarchar(8) COLLATE Chinese_PRC_CI_AS  NOT NULL
)
GO

ALTER TABLE [dbo].[permissions] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Records of permissions
-- ----------------------------

-- ----------------------------
-- Table structure for tenant_capacity
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[tenant_capacity]') AND type IN ('U'))
	DROP TABLE [dbo].[tenant_capacity]
GO

CREATE TABLE [dbo].[tenant_capacity] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [quota] int  NOT NULL,
  [usage] int  NOT NULL,
  [max_size] int  NOT NULL,
  [max_aggr_count] int  NOT NULL,
  [max_aggr_size] int  NOT NULL,
  [max_history_count] int  NOT NULL,
  [gmt_create] datetime2(7)  NULL,
  [gmt_modified] datetime2(7)  NULL
)
GO

ALTER TABLE [dbo].[tenant_capacity] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'主键ID',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'Tenant ID',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'配额,0表示使用默认值',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'quota'
GO

EXEC sp_addextendedproperty
'MS_Description', N'使用量',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'usage'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单个配置大小上限,单位为字节,0表示使用默认值',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'max_size'
GO

EXEC sp_addextendedproperty
'MS_Description', N'聚合子配置最大个数',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'max_aggr_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'max_aggr_size'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最大变更历史数量',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'max_history_count'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity',
'COLUMN', N'gmt_modified'
GO

EXEC sp_addextendedproperty
'MS_Description', N'租户容量信息表',
'SCHEMA', N'dbo',
'TABLE', N'tenant_capacity'
GO


-- ----------------------------
-- Records of tenant_capacity
-- ----------------------------
SET IDENTITY_INSERT [dbo].[tenant_capacity] ON
GO

SET IDENTITY_INSERT [dbo].[tenant_capacity] OFF
GO


-- ----------------------------
-- Table structure for tenant_info
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[tenant_info]') AND type IN ('U'))
	DROP TABLE [dbo].[tenant_info]
GO

CREATE TABLE [dbo].[tenant_info] (
  [id] bigint  IDENTITY(1,1) NOT NULL,
  [kp] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [tenant_id] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [tenant_name] nvarchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [tenant_desc] nvarchar(256) COLLATE Chinese_PRC_CI_AS  NULL,
  [create_source] nvarchar(32) COLLATE Chinese_PRC_CI_AS  NULL,
  [gmt_create] bigint  NULL,
  [gmt_modified] bigint  NULL
)
GO

ALTER TABLE [dbo].[tenant_info] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'id',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'kp',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'kp'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tenant_id',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'tenant_id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tenant_name',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'tenant_name'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tenant_desc',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'tenant_desc'
GO

EXEC sp_addextendedproperty
'MS_Description', N'create_source',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'create_source'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'gmt_create'
GO

EXEC sp_addextendedproperty
'MS_Description', N'修改时间',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info',
'COLUMN', N'gmt_modified'
GO

EXEC sp_addextendedproperty
'MS_Description', N'tenant_info',
'SCHEMA', N'dbo',
'TABLE', N'tenant_info'
GO


-- ----------------------------
-- Records of tenant_info
-- ----------------------------
SET IDENTITY_INSERT [dbo].[tenant_info] ON
GO

SET IDENTITY_INSERT [dbo].[tenant_info] OFF
GO


-- ----------------------------
-- Table structure for roles
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[roles]') AND type IN ('U'))
	DROP TABLE [dbo].[roles]
GO

CREATE TABLE [dbo].[roles] (
  [username] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [role] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL
)
GO

ALTER TABLE [dbo].[roles] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Records of roles
-- ----------------------------
INSERT INTO [dbo].[roles] ([username], [role]) VALUES (N'nacos', N'ROLE_ADMIN')
GO


-- ----------------------------
-- Table structure for users
-- ----------------------------
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND type IN ('U'))
	DROP TABLE [dbo].[users]
GO

CREATE TABLE [dbo].[users] (
  [username] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [password] nvarchar(500) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [enabled] tinyint  NOT NULL
)
GO

ALTER TABLE [dbo].[users] SET (LOCK_ESCALATION = TABLE)
GO


-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO [dbo].[users] ([username], [password], [enabled]) VALUES (N'nacos', N'$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', N'1')
GO


-- ----------------------------
-- Auto increment value for config_info
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[config_info]', RESEED, 102)
GO


-- ----------------------------
-- Indexes structure for table config_info
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_configinfo_datagrouptenant]
ON [dbo].[config_info] (
  [data_id] ASC,
  [group_id] ASC,
  [tenant_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table config_info
-- ----------------------------
ALTER TABLE [dbo].[config_info] ADD CONSTRAINT [PK__config_i__3213E83FACA9FB02] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for config_info_aggr
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[config_info_aggr]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table config_info_aggr
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_configinfoaggr_datagrouptenantdatum]
ON [dbo].[config_info_aggr] (
  [data_id] ASC,
  [group_id] ASC,
  [tenant_id] ASC,
  [datum_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table config_info_aggr
-- ----------------------------
ALTER TABLE [dbo].[config_info_aggr] ADD CONSTRAINT [PK__config_i__3213E83F115E7373] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for config_info_beta
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[config_info_beta]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table config_info_beta
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_configinfobeta_datagrouptenant]
ON [dbo].[config_info_beta] (
  [data_id] ASC,
  [group_id] ASC,
  [tenant_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table config_info_beta
-- ----------------------------
ALTER TABLE [dbo].[config_info_beta] ADD CONSTRAINT [PK__config_i__3213E83FA59A8BC6] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for config_info_tag
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[config_info_tag]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table config_info_tag
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_configinfotag_datagrouptenanttag]
ON [dbo].[config_info_tag] (
  [data_id] ASC,
  [group_id] ASC,
  [tenant_id] ASC,
  [tag_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table config_info_tag
-- ----------------------------
ALTER TABLE [dbo].[config_info_tag] ADD CONSTRAINT [PK__config_i__3213E83F6058987E] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for config_tags_relation
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[config_tags_relation]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table config_tags_relation
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_configtagrelation_configidtag]
ON [dbo].[config_tags_relation] (
  [id] ASC,
  [tag_name] ASC,
  [tag_type] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_tenant_id]
ON [dbo].[config_tags_relation] (
  [tenant_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table config_tags_relation
-- ----------------------------
ALTER TABLE [dbo].[config_tags_relation] ADD CONSTRAINT [PK__config_t__DF97D0F544B292B8] PRIMARY KEY CLUSTERED ([nid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for group_capacity
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[group_capacity]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table group_capacity
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_group_id]
ON [dbo].[group_capacity] (
  [group_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table group_capacity
-- ----------------------------
ALTER TABLE [dbo].[group_capacity] ADD CONSTRAINT [PK__group_ca__3213E83F815AD8E6] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for his_config_info
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[his_config_info]', RESEED, 106)
GO


-- ----------------------------
-- Indexes structure for table his_config_info
-- ----------------------------
CREATE NONCLUSTERED INDEX [idx_gmt_create]
ON [dbo].[his_config_info] (
  [gmt_create] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_gmt_modified]
ON [dbo].[his_config_info] (
  [gmt_modified] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_did]
ON [dbo].[his_config_info] (
  [data_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table his_config_info
-- ----------------------------
ALTER TABLE [dbo].[his_config_info] ADD CONSTRAINT [PK__his_conf__DF97D0F56078DD5F] PRIMARY KEY CLUSTERED ([nid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table permissions
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_role_permission]
ON [dbo].[permissions] (
  [role] ASC,
  [resource] ASC,
  [action] ASC
)
GO


-- ----------------------------
-- Auto increment value for tenant_capacity
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[tenant_capacity]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table tenant_capacity
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_tenant_id]
ON [dbo].[tenant_capacity] (
  [tenant_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table tenant_capacity
-- ----------------------------
ALTER TABLE [dbo].[tenant_capacity] ADD CONSTRAINT [PK__tenant_c__3213E83FFFE944FB] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Auto increment value for tenant_info
-- ----------------------------
DBCC CHECKIDENT ('[dbo].[tenant_info]', RESEED, 1)
GO


-- ----------------------------
-- Indexes structure for table tenant_info
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [uk_tenant_info_kptenantid]
ON [dbo].[tenant_info] (
  [kp] ASC,
  [tenant_id] ASC
)
GO

CREATE NONCLUSTERED INDEX [idx_tenant_id]
ON [dbo].[tenant_info] (
  [tenant_id] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table tenant_info
-- ----------------------------
ALTER TABLE [dbo].[tenant_info] ADD CONSTRAINT [PK__tenant_i__3213E83FC239442D] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


-- ----------------------------
-- Indexes structure for table roles
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [idx_user_role]
ON [dbo].[roles] (
  [username] ASC,
  [role] ASC
)
GO


-- ----------------------------
-- Primary Key structure for table users
-- ----------------------------
ALTER TABLE [dbo].[users] ADD CONSTRAINT [PK__users__F3DBC5730B0E5988] PRIMARY KEY CLUSTERED ([username])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
ON [PRIMARY]
GO


5.打包,文件最终会生成在distribution/target目录中

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

1.jpg

6.application.properties使用数据库存贮(spring.datasource.platform=mysql打开注释即可不要修改)

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

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

### Connect URL of DB:
db.url.0=jdbc:dm://ip:5236/NACOS?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&useSSL=false
db.user.0=NACOS
db.password.0=NACOS

7.如果使用其他数据库也是这样改,可能有的库sql需要微调到时候可以查看日志调试

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服