• SpringCloud Alibaba微服务实战一 - 基础环境准备


    SpringCloud Alibaba微服务实战一 - 基础环境准备

    Spring Cloud Alibaba

    Spring Cloud Alibaba 致力于提供微服务开发的一站式解决方案。此项目包含开发分布式应用微服务的必需组件,方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开发分布式应用服务。

    依托 Spring Cloud Alibaba,您只需要添加一些注解和少量配置,就可以将 Spring Cloud 应用接入阿里微服务解决方案,通过阿里中间件来迅速搭建分布式应用系统。

    Spring Cloud Netflix

    目前市场上主流的 第一套微服务架构解决方案:Spring Boot + Spring Cloud Netflix

    Spring Cloud 为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智能路由,微代理,控制总线)。分布式系统的协调导致了样板模式, 使用 Spring Cloud 开发人员可以快速地支持实现这些模式的服务和应用程序。他们将在任何分布式环境中运行良好,包括开发人员自己的笔记本电脑,裸机数据中心,以及 Cloud Foundry 等托管平台。

    目前业界对 Spring Cloud 使用最广的就是 Spring Cloud Netflix 了

    项目已经进入维护模式

    【官方新闻】Spring Cloud Greenwich.RC1 available now

    2018 年 12 月 12 日,Netflix 宣布 Spring Cloud Netflix 系列技术栈进入维护模式(不再添加新特性)

    最近,Netflix 宣布 Hystrix 正在进入维护模式。自 2016 年以来,Ribbon 已处于类似状态。虽然 Hystrix 和 Ribbon 现已处于维护模式,但它们仍然在 Netflix 大规模部署。

    Hystrix Dashboard 和 Turbine 已被 Atlas 取代。这些项目的最后一次提交分别是 2 年前和 4 年前。Zuul1 和 Archaius1 都被后来不兼容的版本所取代。

    以下 Spring Cloud Netflix 模块和相应的 Starter 将进入维护模式:

    • spring-cloud-netflix-archaius
    • spring-cloud-netflix-hystrix-contract
    • spring-cloud-netflix-hystrix-dashboard
    • spring-cloud-netflix-hystrix-stream
    • spring-cloud-netflix-hystrix
    • spring-cloud-netflix-ribbon
    • spring-cloud-netflix-turbine-stream
    • spring-cloud-netflix-turbine
    • spring-cloud-netflix-zuul

    什么是维护模式

    将模块置于维护模式,意味着 Spring Cloud 团队将不会再向模块添加新功能。我们将修复 block 级别的 bug 以及安全问题,我们也会考虑并审查社区的小型 pull request

    替代品

    我们建议对这些模块提供的功能进行以下替换:

    CURRENTREPLACEMENT
    HystrixResilience4j
    Hystrix Dashboard / TurbineMicrometer + Monitoring System
    RibbonSpring Cloud Loadbalancer
    Zuul 1Spring Cloud Gateway
    Archaius 1Spring Boot external config + Spring Cloud Config

    2018 年 10 月 31 日的凌晨,这个伟大的日子里,Spring Cloud Alibaba 正式入驻了 Spring Cloud 官方孵化器,并在 Maven 中央库发布了第一个版本。

    Spring Cloud for Alibaba 0.2.0 released

    The Spring Cloud Alibaba project, consisting of Alibaba’s open-source components and several Alibaba Cloud products, aims to implement and expose well known Spring Framework patterns and abstractions to bring the benefits of Spring Boot and Spring Cloud to Java developers using Alibaba products.

    Spring Cloud for Alibaba,它是由一些阿里巴巴的开源组件和云产品组成的。这个项目的目的是为了让大家所熟知的 Spring 框架,其优秀的设计模式和抽象理念,以给使用阿里巴巴产品的 Java 开发者带来使用 Spring Boot 和 Spring Cloud 的更多便利。

    github地址

    主要功能

    • 服务限流降级:默认支持 WebServlet、WebFlux、OpenFeign、RestTemplate、Spring Cloud Gateway、Zuul、Dubbo 和 RocketMQ 限流降级功能的接入,可以在运行时通过控制台实时修改限流降级规则,还支持查看限流降级 Metrics 监控。
    • 服务注册与发现:适配 Spring Cloud 服务注册与发现标准,默认集成了 Ribbon 的支持。
    • 分布式配置管理:支持分布式系统中的外部化配置,配置更改时自动刷新。
    • 消息驱动能力:基于 Spring Cloud Stream 为微服务应用构建消息驱动能力。
    • 分布式事务:使用 @GlobalTransactional 注解, 高效并且对业务零侵入地解决分布式事务问题。
    • 阿里云对象存储:阿里云提供的海量、安全、低成本、高可靠的云存储服务。支持在任何应用、任何时间、任何地点存储和访问任意类型的数据。
    • 分布式任务调度:提供秒级、精准、高可靠、高可用的定时(基于 Cron 表达式)任务调度服务。同时提供分布式的任务执行模型,如网格任务。网格任务支持海量子任务均匀分配到所有 Worker(schedulerx-client)上执行。
    • 阿里云短信服务:覆盖全球的短信服务,友好、高效、智能的互联化通讯能力,帮助企业迅速搭建客户触达通道。

    组件

    Sentinel:把流量作为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。

    Nacos:一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。

    RocketMQ:一款开源的分布式消息系统,基于高可用分布式集群技术,提供低延时的、高可靠的消息发布与订阅服务。

    Dubbo:Apache Dubbo™ 是一款高性能 Java RPC 框架。

    Seata:阿里巴巴开源产品,一个易于使用的高性能微服务分布式事务解决方案。

    Alibaba Cloud OSS: 阿里云对象存储服务(Object Storage Service,简称 OSS),是阿里云提供的海量、安全、低成本、高可靠的云存储服务。您可以在任何应用、任何时间、任何地点存储和访问任意类型的数据。

    Alibaba Cloud SchedulerX: 阿里中间件团队开发的一款分布式任务调度产品,提供秒级、精准、高可靠、高可用的定时(基于 Cron 表达式)任务调度服务。

    Alibaba Cloud SMS: 覆盖全球的短信服务,友好、高效、智能的互联化通讯能力,帮助企业迅速搭建客户触达通道。

    版本管理规范

    项目的版本号格式为 x.x.x 的形式,其中 x 的数值类型为数字,从 0 开始取值,且不限于 0~9 这个范围。项目处于孵化器阶段时,第一位版本号固定使用 0,即版本号为 0.x.x 的格式。

    由于 Spring Boot 1 和 Spring Boot 2 在 Actuator 模块的接口和注解有很大的变更,且spring-cloud-commons 从 1.x.x 版本升级到 2.0.0 版本也有较大的变更,因此我们采取跟 SpringBoot 版本号一致的版本:

    • 1.5.x 版本适用于 Spring Boot 1.5.x
    • 2.0.x 版本适用于 Spring Boot 2.0.x
    • 2.1.x 版本适用于 Spring Boot 2.1.x
    • 2.2.x 版本适用于 Spring Boot 2.2.x
    • 2021.x 版本适用于 Spring Boot 2.4.x

    特别注意:

    Spring Cloud Alibaba 项目都是基于 Spring Cloud,而 Spring Cloud 项目又是基于 Spring Boot 进行开发,所以三者之间的版本关系特别重要,一旦选错版本,项目就没法运行

    版本说明 遵循这个官方的版本说明解决版本冲突的问题(课件下面的版本仅供参考)

    组件版本关系

    Spring Cloud Alibaba VersionSentinel VersionNacos VersionRocketMQ VersionDubbo VersionSeata Version
    2.2.6.RELEASE1.8.11.4.24.4.02.7.81.3.0
    2021.1 or 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE1.8.01.4.14.4.02.7.81.3.0
    2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE1.8.01.3.34.4.02.7.81.3.0
    2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE1.7.11.2.14.4.02.7.61.2.0
    2.2.0.RELEASE1.7.11.1.44.4.02.7.4.11.0.0
    2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE1.7.01.1.44.4.02.7.30.9.0
    2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE1.6.31.1.14.4.02.7.30.7.1

    毕业版本依赖关系(推荐使用)

    Spring Cloud VersionSpring Cloud Alibaba VersionSpring Boot Version
    Spring Cloud 2020.0.12021.12.4.2
    Spring Cloud Hoxton.SR92.2.6.RELEASE2.3.2.RELEASE
    Spring Cloud Greenwich.SR62.1.4.RELEASE2.1.13.RELEASE
    Spring Cloud Hoxton.SR32.2.1.RELEASE2.2.5.RELEASE
    Spring Cloud Hoxton.RELEASE2.2.0.RELEASE2.2.X.RELEASE
    Spring Cloud Greenwich2.1.2.RELEASE2.1.X.RELEASE
    Spring Cloud Finchley2.0.4.RELEASE(停止维护,建议升级)2.0.X.RELEASE
    Spring Cloud Edgware1.5.1.RELEASE(停止维护,建议升级)1.5.X.RELEASE

    基础环境准备

    根据版本说明中的推荐,我们这里选择SpringBoot的版本为2.4.2,SpringCloud Alibaba的版本则为2021.1,组件对应关系如下

    ​ [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-XoSljQoe-1655998168281)(https://note.youdao.com/yws/public/resource/c7f6b78e148f14152e9f73f1cd2423a5/xmlnote/WEB6aab92a3dd3b97f2344e92d4a640c76e/WEBRESOURCE6b8eb52543623f0a77b6833633404b61/5366)]

    内容主要基于三个微服务:用户服务AccountService,订单服务OrderService,产品服务ProductService

    用到的组件有:

    • 注册中心、配置中心 Nacos
    • 限流 Sentinel
    • 分布式事务 Seata
    • 网关 SpringCloud Gateway
    • 认证授权 Spring Cloud Oauth2
    • docker、docker-compose

    由于用到的组件相对较多,部署会很繁琐,最关键的是没有资源服务器,所以在开发过程中我会逐渐将一些组件使用docker-compose部署

    本篇内容就是使用Dokcer-compose部署Nacos,Sentinel,MySQL,作为后面的文章的基础环境

    容器化

    MySQL

    由于nacos需要依赖于MySQL作为资源存储,所以在编写完整docker-compose之前我会先用docker启动临时的mysql容器,然后准备好nacos需要的数据库

    • 启动临时容器

       docker run --rm --name mysql -e MYSQL_ROOT_PASSWORD=123456 -v /app/cloud/mysql/data:/var/lib/mysql -p 3306:3306 -d mysql:5.7              
      
      • 1

    此处需要挂载宿主机目录,在启动docker-compse后就不需要再次初识化数据。

    • 用mysql客户端连接你的容器,然后导入nacos的数据表

    https://github.com/alibaba/nacos/tree/develop/distribution/conf/nacos-mysql.sql

    • 停止容器,由于加了–rm参数,所以容器会自动删除

    docker stop containerID

    Nacos

    我们来看看NACOS的环境变量,如下表所示:

    配置项描述可选参数默认值
    MODE模式 cluster/standalonecluster/standalonecluster
    PREFER_HOST_MODE是否支持 hostnamehostname/ipip
    NACOS_SERVER_PORT服务端口号8848
    SPRING_DATASOURCE_PLATFORM单机模式支持 mysqlmysql / emptyempty
    MYSQL_MASTER_SERVICE_HOSTmysql 主节点 host
    MYSQL_MASTER_SERVICE_PORTmysql 主节点 port3306
    MYSQL_MASTER_SERVICE_DB_NAMEmysql 主节点数据库名
    MYSQL_MASTER_SERVICE_USERmysql 主节点用户名
    MYSQL_MASTER_SERVICE_PASSWORDmysql 主节点密码
    MYSQL_SLAVE_SERVICE_HOSTmysql 从节点 host
    MYSQL_SLAVE_SERVICE_PORTmysql 从节点 port3306

    Nacos支持主从配置,考虑到资源问题,我们只配置一台单独的mysql服务器,有资源的同学可以搭建主从环境

    Sentinel

    sentinel比较简单,直接配置sentinel-dashboard镜像即可 (在系列的开始不需要引入sentinel组件,为了后面不再单独介绍,本次我也把他加到我的docker-compose中)

    Seata

    seata由于一些原因,还没发布官方镜像,暂时搁浅。

    docker-compose

    以下是我编写的docker-compse文件,大家可以自行修改

            ```java
            version: "3"
            services:
              mysql:
                container_name: mysql
                image: mysql:5.7
                environment:
                  - MYSQL_ROOT_PASSWORD=123456
                volumes:
                  - /app/cloud/mysql/data:/var/lib/mysql
                ports:
                  - "3306:3306"
                restart: always
            
              nacos:
                image: nacos/nacos-server:1.4.1
                container_name: nacos
                hostname: nacos
                restart: always
                environment:
                  - MODE=standalone
                  - TZ=Asia/Shanghai
                  - NACOS_SERVER_PORT=8848
                  - SPRING_DATASOURCE_PLATFORM=mysql
                  - MYSQL_SERVICE_HOST=120.78.224.108
                  - MYSQL_SERVICE_PORT=3306
                  - MYSQL_SERVICE_DB_NAME=nacos_config
                  - MYSQL_SERVICE_USER=root
                  - MYSQL_SERVICE_PASSWORD=123456
                  - PREFER_HOST_MODE=hostname
                volumes:
                  - /app/cloud/nacos/logs:/home/nacos/logs
                ports:
                  - "8848:8848"
            
              sentinel:
                image: bladex/sentinel-dashboard:1.8.0
                container_name: sentinel
                ports:
                  - "8858:8858"
                restart: always
              seata-server:
                image: seataio/seata-server:1.3.0
                hostname: seata-server
                ports:
                  - 8091:8091
                environment:
                  - SEATA_PORT=8091
                expose:
                  - 8091
            ```
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51

    将其上传至你的服务器,执行 docker-compose up -d 命令启动

    ​ [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-L5zh7Cy0-1655998168282)(https://note.youdao.com/yws/public/resource/c7f6b78e148f14152e9f73f1cd2423a5/xmlnote/WEB6aab92a3dd3b97f2344e92d4a640c76e/WEBRESOURCEd315af18985798339b173e1e507a5613/5367)]

    # 这里尽量开放一下服务器的端口
    查看防火墙状态:
    systemctl status firewalld
    systemctl stop firewalld
    systemctl start firewalld
    开启端口:
    firewall-cmd --zone=public --add-port=3306/tcp --permanent
    查询端口号8080是否开启:
    firewall-cmd --query-port=3306/tcp
    重启防火墙:
    firewall-cmd --reload
    查询有哪些端口是开启的:
    firewall-cmd --list-port
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    环境验证

    nacos

    访问nacos http://192.168.136.129:8848/nacos,使用账号密码nacos/nacos登录

    0

    在服务配置中添加一条数据

    0

    这是nacos持久化数据库

     Navicat Premium Data Transfer
    
     Source Server         : 192.168.203.133
     Source Server Type    : MySQL
     Source Server Version : 50736
     Source Host           : 192.168.203.133:3306
     Source Schema         : nacos_config
    
     Target Server Type    : MySQL
     Target Server Version : 50736
     File Encoding         : 65001
    
     Date: 04/04/2022 16:42:32
    */
    
    SET NAMES utf8mb4;
    SET FOREIGN_KEY_CHECKS = 0;
    
    -- ----------------------------
    -- Table structure for config_info
    -- ----------------------------
    DROP TABLE IF EXISTS `config_info`;
    CREATE TABLE `config_info`  (
      `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
      `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
      `group_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'content',
      `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'md5',
      `gmt_create` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      `gmt_modified` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
      `src_user` text CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT 'source user',
      `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'source ip',
      `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT '租户字段',
      `c_desc` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `c_use` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `effect` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `type` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `c_schema` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `uk_configinfo_datagrouptenant`(`data_id`, `group_id`, `tenant_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = 'config_info' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Records of config_info
    -- ----------------------------
    INSERT INTO `config_info` VALUES (1, 'itrip-service-orders.yaml', 'orders', 'spring:\n  application:\n    name: itrip-service-orders\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      # 配置控制台\n      transport:\n        dashboard: 192.168.203.130:8858\n      # 消息延时加载设置为false\n      eager: false\n      datasource:\n        ds:\n          nacos:\n            server-addr: 192.168.203.130:8848\n            namespace: cdc378f4-114b-471b-8732-b7d38bcb02ea\n            data-id: itrip-service-orders-sentinel\n            rule-type: flow\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9002\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', 'dc5f493a806a94791af84de50b5833e2', '2022-03-31 09:24:30', '2022-04-01 02:37:47', NULL, '192.168.203.1', '', 'cdc378f4-114b-471b-8732-b7d38bcb02ea', '', '', '', 'yaml', '');
    INSERT INTO `config_info` VALUES (2, 'itrip-service-users.yaml', 'users', 'spring:\n  application:\n    name: itrip-service-users\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      datasource:\n        ds:\n          nacos:\n            server-addr: 192.168.203.130:8848\n            data-id: itrip-service-users-sentinel-degrade\n            group-id: DEFAULT_GROUP\n            namespace: faf33017-b8c2-48fa-9b29-09d644006946\n            rule-type: degrade\n      transport:\n        dashboard: 192.168.203.130:8858\n      eager: false\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9001\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', '3e298f3ad9a7e64eae7336a362fb5d36', '2022-03-31 09:25:29', '2022-04-01 03:14:15', NULL, '192.168.203.1', '', 'faf33017-b8c2-48fa-9b29-09d644006946', '用户', '', '', 'yaml', '');
    INSERT INTO `config_info` VALUES (10, 'itrip-service-orders-sentinel', 'DEFAULT_GROUP', '[\r\n    {\r\n        \"resource\": \"getOrderListByUserId\",\r\n        \"limitApp\": \"default\",\r\n        \"grade\": 1,\r\n        \"count\": 1,\r\n        \"strategy\": 0,\r\n        \"controlBehavior\": 0,\r\n        \"clusterMode\": false\r\n    }\r\n]', '83328c14e75d4a4173eeb10bb4fadf8e', '2022-04-01 02:27:52', '2022-04-01 02:27:52', NULL, '192.168.203.1', '', 'cdc378f4-114b-471b-8732-b7d38bcb02ea', '订单的流控规则持久化配置', NULL, NULL, 'json', NULL);
    INSERT INTO `config_info` VALUES (15, 'itrip-service-users-sentinel-degrade', 'DEFAULT_GROUP', '[\r\n    {\r\n    \"resource\": \"/getOrderListByUserId\",\r\n    \"count\": 0.5,\r\n    \"grade\": 1,\r\n    \"passCount\": 0,\r\n    \"timeWindow\": 2\r\n  }\r\n]', '006192ea69dae386bfa1e03916de06b3', '2022-04-01 03:15:52', '2022-04-01 03:15:52', NULL, '192.168.203.1', '', 'faf33017-b8c2-48fa-9b29-09d644006946', '用户调用订单,出现熔断之后的配置', NULL, NULL, 'json', NULL);
    INSERT INTO `config_info` VALUES (16, 'itrip-gateway.yaml', 'gateway', 'server:\n  port: 9999\nspring:\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    gateway:\n      discovery:\n        #开启网关拉取nacos的服务\n        locator:\n          enabled: true\n      routes:\n        - id: itrip-service-orders\n          uri: lb://itrip-service-orders\n          predicates:\n            - Path=/orders/**\n          filters:\n            - StripPrefix=1\n        - id: itrip-service-users\n          uri: lb://itrip-service-users\n          predicates:\n            - Path=/users/**\n          filters:\n            - StripPrefix=1\n  application:\n    name: itrip-gateway', '0ad4d3dd795b25e2ad55a748699697eb', '2022-04-02 06:35:45', '2022-04-02 06:40:33', NULL, '192.168.203.1', '', '0cbe8b45-e878-4c59-9ab8-5b8616ac4d57', '网关的配置文件', '', '', 'yaml', '');
    
    -- ----------------------------
    -- Table structure for config_info_aggr
    -- ----------------------------
    DROP TABLE IF EXISTS `config_info_aggr`;
    CREATE TABLE `config_info_aggr`  (
      `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
      `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
      `group_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
      `datum_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'datum_id',
      `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '内容',
      `gmt_modified` datetime(0) NOT NULL COMMENT '修改时间',
      `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT '租户字段',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `uk_configinfoaggr_datagrouptenantdatum`(`data_id`, `group_id`, `tenant_id`, `datum_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '增加租户字段' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for config_info_beta
    -- ----------------------------
    DROP TABLE IF EXISTS `config_info_beta`;
    CREATE TABLE `config_info_beta`  (
      `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
      `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
      `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
      `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'app_name',
      `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'content',
      `beta_ips` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'betaIps',
      `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'md5',
      `gmt_create` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      `gmt_modified` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
      `src_user` text CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT 'source user',
      `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'source ip',
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT '租户字段',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `uk_configinfobeta_datagrouptenant`(`data_id`, `group_id`, `tenant_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = 'config_info_beta' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for config_info_tag
    -- ----------------------------
    DROP TABLE IF EXISTS `config_info_tag`;
    CREATE TABLE `config_info_tag`  (
      `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
      `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
      `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT 'tenant_id',
      `tag_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'tag_id',
      `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'app_name',
      `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'content',
      `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'md5',
      `gmt_create` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      `gmt_modified` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
      `src_user` text CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT 'source user',
      `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'source ip',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `uk_configinfotag_datagrouptenanttag`(`data_id`, `group_id`, `tenant_id`, `tag_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = 'config_info_tag' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for config_tags_relation
    -- ----------------------------
    DROP TABLE IF EXISTS `config_tags_relation`;
    CREATE TABLE `config_tags_relation`  (
      `id` bigint(20) NOT NULL COMMENT 'id',
      `tag_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'tag_name',
      `tag_type` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'tag_type',
      `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
      `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT 'tenant_id',
      `nid` bigint(20) NOT NULL AUTO_INCREMENT,
      PRIMARY KEY (`nid`) USING BTREE,
      UNIQUE INDEX `uk_configtagrelation_configidtag`(`id`, `tag_name`, `tag_type`) USING BTREE,
      INDEX `idx_tenant_id`(`tenant_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = 'config_tag_relation' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for group_capacity
    -- ----------------------------
    DROP TABLE IF EXISTS `group_capacity`;
    CREATE TABLE `group_capacity`  (
      `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
      `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
      `quota` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '配额,0表示使用默认值',
      `usage` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '使用量',
      `max_size` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
      `max_aggr_count` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '聚合子配置最大个数,,0表示使用默认值',
      `max_aggr_size` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
      `max_history_count` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '最大变更历史数量',
      `gmt_create` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      `gmt_modified` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `uk_group_id`(`group_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '集群、各Group容量信息表' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for his_config_info
    -- ----------------------------
    DROP TABLE IF EXISTS `his_config_info`;
    CREATE TABLE `his_config_info`  (
      `id` bigint(64) UNSIGNED NOT NULL,
      `nid` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
      `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
      `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
      `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'app_name',
      `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
      `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `gmt_create` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `gmt_modified` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `src_user` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
      `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `op_type` char(10) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT '租户字段',
      PRIMARY KEY (`nid`) USING BTREE,
      INDEX `idx_gmt_create`(`gmt_create`) USING BTREE,
      INDEX `idx_gmt_modified`(`gmt_modified`) USING BTREE,
      INDEX `idx_did`(`data_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 23 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '多租户改造' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Records of his_config_info
    -- ----------------------------
    INSERT INTO `his_config_info` VALUES (0, 1, 'itrip-service-orders.yaml', 'orders', '', 'spring:\r\n  application:\r\n    name: itrip-service-orders\r\n  # 配置注册中心\r\n  cloud:\r\n    nacos:\r\n      discovery:\r\n        server-addr: 192.168.203.130:8848\r\n    sentinel:\r\n      transport:\r\n        dashboard: 192.168.203.130:8858\r\n      datasource:\r\n        ds:\r\n          nacos:\r\n            server-addr: 192.168.203.130:8848\r\n            data-id: itrip-service-orders-sentinel\r\n            group-id: DEFAULT_GROUP\r\n            rule-type: flow\r\n  datasource:\r\n    driver-class-name: com.mysql.cj.jdbc.Driver\r\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\r\n    username: root\r\n    password: root\r\n\r\nserver:\r\n  port: 9002\r\n\r\nmybatis-plus:\r\n  type-aliases-package: com.changan.entity\r\n  configuration:\r\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\r\n  mapper-locations: classpath*:/mapper/UserMapper.xml\r\n', '3255fc2c19792aa9c53f3644fa3d2840', '2022-03-31 09:24:29', '2022-03-31 09:24:30', NULL, '192.168.203.1', 'I', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (0, 2, 'itrip-service-users.yaml', 'users', '', 'spring:\r\n  application:\r\n    name: itrip-service-users\r\n  # 配置注册中心\r\n  cloud:\r\n    nacos:\r\n      discovery:\r\n        server-addr: 192.168.203.130:8848\r\n  datasource:\r\n    driver-class-name: com.mysql.cj.jdbc.Driver\r\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\r\n    username: root\r\n    password: root\r\n\r\nserver:\r\n  port: 9001\r\n\r\nmybatis-plus:\r\n  type-aliases-package: com.changan.entity\r\n  configuration:\r\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\r\n  mapper-locations: classpath*:/mapper/UserMapper.xml\r\n', 'c405941ae6732e3b0aa463f2c767ba92', '2022-03-31 09:25:29', '2022-03-31 09:25:29', NULL, '192.168.203.1', 'I', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (1, 3, 'itrip-service-orders.yaml', 'orders', '', 'spring:\r\n  application:\r\n    name: itrip-service-orders\r\n  # 配置注册中心\r\n  cloud:\r\n    nacos:\r\n      discovery:\r\n        server-addr: 192.168.203.130:8848\r\n    sentinel:\r\n      transport:\r\n        dashboard: 192.168.203.130:8858\r\n      datasource:\r\n        ds:\r\n          nacos:\r\n            server-addr: 192.168.203.130:8848\r\n            data-id: itrip-service-orders-sentinel\r\n            group-id: DEFAULT_GROUP\r\n            rule-type: flow\r\n  datasource:\r\n    driver-class-name: com.mysql.cj.jdbc.Driver\r\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\r\n    username: root\r\n    password: root\r\n\r\nserver:\r\n  port: 9002\r\n\r\nmybatis-plus:\r\n  type-aliases-package: com.changan.entity\r\n  configuration:\r\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\r\n  mapper-locations: classpath*:/mapper/UserMapper.xml\r\n', '3255fc2c19792aa9c53f3644fa3d2840', '2022-03-31 09:30:31', '2022-03-31 09:30:31', NULL, '192.168.203.1', 'U', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (0, 4, 'itrip-service-orders-sentinel', 'orders', '', '[\r\n    {\r\n        \"resource\": \"getOrderListByUserId\",\r\n        \"limitApp\": \"default\",\r\n        \"grade\": 1,\r\n        \"count\": 1,\r\n        \"strategy\": 0,\r\n        \"controlBehavior\": 0,\r\n        \"clusterMode\": false\r\n    }\r\n]', '83328c14e75d4a4173eeb10bb4fadf8e', '2022-03-31 09:32:29', '2022-03-31 09:32:29', NULL, '192.168.203.1', 'I', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (4, 5, 'itrip-service-orders-sentinel', 'orders', '', '[\r\n    {\r\n        \"resource\": \"getOrderListByUserId\",\r\n        \"limitApp\": \"default\",\r\n        \"grade\": 1,\r\n        \"count\": 1,\r\n        \"strategy\": 0,\r\n        \"controlBehavior\": 0,\r\n        \"clusterMode\": false\r\n    }\r\n]', '83328c14e75d4a4173eeb10bb4fadf8e', '2022-03-31 10:10:20', '2022-03-31 10:10:20', NULL, '192.168.203.1', 'U', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (0, 6, 'itrip-service-users-sentinel-degrade', 'users', '', '[\r\n    {\r\n    \"resource\": \"/getOrderListByUserId\",\r\n    \"count\": 0.5,\r\n    \"grade\": 1,\r\n    \"passCount\": 0,\r\n    \"timeWindow\": 2\r\n  }\r\n]', '006192ea69dae386bfa1e03916de06b3', '2022-03-31 10:19:05', '2022-03-31 10:19:06', NULL, '192.168.203.1', 'I', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (2, 7, 'itrip-service-users.yaml', 'users', '', 'spring:\r\n  application:\r\n    name: itrip-service-users\r\n  # 配置注册中心\r\n  cloud:\r\n    nacos:\r\n      discovery:\r\n        server-addr: 192.168.203.130:8848\r\n  datasource:\r\n    driver-class-name: com.mysql.cj.jdbc.Driver\r\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\r\n    username: root\r\n    password: root\r\n\r\nserver:\r\n  port: 9001\r\n\r\nmybatis-plus:\r\n  type-aliases-package: com.changan.entity\r\n  configuration:\r\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\r\n  mapper-locations: classpath*:/mapper/UserMapper.xml\r\n', 'c405941ae6732e3b0aa463f2c767ba92', '2022-03-31 10:40:41', '2022-03-31 10:40:42', NULL, '192.168.203.1', 'U', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (2, 8, 'itrip-service-users.yaml', 'users', '', 'spring:\n  application:\n    name: itrip-service-users\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      datasource:\n        ds:\n          nacos:\n            server-addr: 192.168.203.130:8848\n            namespace: faf33017-b8c2-48fa-9b29-09d644006946\n            data-id: itrip-service-users-sentinel-degrade\n            group-id: users\n            rule-type: degrade\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9001\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', '6c661b278cc0dfda2b5fef269e655982', '2022-03-31 10:41:10', '2022-03-31 10:41:11', NULL, '192.168.203.1', 'U', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (6, 9, 'itrip-service-users-sentinel-degrade', 'users', '', '[\r\n    {\r\n    \"resource\": \"/getOrderListByUserId\",\r\n    \"count\": 0.5,\r\n    \"grade\": 1,\r\n    \"passCount\": 0,\r\n    \"timeWindow\": 2\r\n  }\r\n]', '006192ea69dae386bfa1e03916de06b3', '2022-03-31 10:48:06', '2022-03-31 10:48:07', NULL, '192.168.203.1', 'U', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (1, 10, 'itrip-service-orders.yaml', 'orders', '', 'spring:\n  application:\n    name: itrip-service-orders\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      transport:\n        dashboard: 192.168.203.130:8858\n      datasource:\n        ds:\n          nacos:\n            server-addr: 192.168.203.130:8848\n            namespace: cdc378f4-114b-471b-8732-b7d38bcb02ea\n            data-id: itrip-service-orders-sentinel\n            group-id: orders\n            rule-type: flow\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9002\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', '42f8fe72683eae64d521570fa9d97c33', '2022-04-01 02:01:34', '2022-04-01 02:01:35', NULL, '192.168.203.1', 'U', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (1, 11, 'itrip-service-orders.yaml', 'orders', '', 'spring:\n  application:\n    name: itrip-service-orders\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      # 配置控制台\n      transport:\n        dashboard: 192.168.203.130:8858\n      # 消息延时加载设置为false\n      eager: false\n      datasource:\n        ds:\n          nacos:\n            server-addr: 192.168.203.130:8848\n            namespace: cdc378f4-114b-471b-8732-b7d38bcb02ea\n            data-id: itrip-service-orders-sentinel\n            group-id: orders\n            rule-type: flow\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9002\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', 'cb15689c7d81942f1d0fc6bf9c7d7970', '2022-04-01 02:05:30', '2022-04-01 02:05:30', NULL, '192.168.203.1', 'U', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (4, 12, 'itrip-service-orders-sentinel', 'orders', '', '[\n    {\n        \"resource\": \"getOrderListByUserId\",\n        \"limitApp\": \"default\",\n        \"grade\": 1,\n        \"count\": 1000,\n        \"strategy\": 0,\n        \"controlBehavior\": 0,\n        \"clusterMode\": false\n    }\n]', '2a4666b2636d74298af48613b7be5989', '2022-04-01 02:05:41', '2022-04-01 02:05:42', NULL, '192.168.203.1', 'D', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (6, 13, 'itrip-service-users-sentinel-degrade', 'users', '', '[\n    {\n    \"resource\": \"/getOrderListByUserId\",\n    \"count\": 0.5,\n    \"grade\": 1,\n    \"passCount\": 0,\n    \"timeWindow\": 2\n  }\n]', '978f5b248f2a0c4411c813583193e770', '2022-04-01 02:05:47', '2022-04-01 02:05:48', NULL, '192.168.203.1', 'D', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (2, 14, 'itrip-service-users.yaml', 'users', '', 'spring:\n  application:\n    name: itrip-service-users\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      transport:\n        dashboard: 192.168.203.130:8858\n      datasource:\n        ds:\n          nacos:\n            server-addr: 192.168.203.130:8848\n            namespace: faf33017-b8c2-48fa-9b29-09d644006946\n            data-id: itrip-service-users-sentinel-degrade\n            group-id: users\n            rule-type: degrade\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9001\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', '2f0bf1b011e7698e09cd664d9baf2b38', '2022-04-01 02:06:11', '2022-04-01 02:06:11', NULL, '192.168.203.1', 'U', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (0, 15, 'itrip-service-orders-sentinel', 'DEFAULT_GROUP', '', '[\r\n    {\r\n        \"resource\": \"getOrderListByUserId\",\r\n        \"limitApp\": \"default\",\r\n        \"grade\": 1,\r\n        \"count\": 1,\r\n        \"strategy\": 0,\r\n        \"controlBehavior\": 0,\r\n        \"clusterMode\": false\r\n    }\r\n]', '83328c14e75d4a4173eeb10bb4fadf8e', '2022-04-01 02:27:51', '2022-04-01 02:27:52', NULL, '192.168.203.1', 'I', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (1, 16, 'itrip-service-orders.yaml', 'orders', '', 'spring:\n  application:\n    name: itrip-service-orders\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      # 配置控制台\n      transport:\n        dashboard: 192.168.203.130:8858\n      # 消息延时加载设置为false\n      eager: false\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9002\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', '14d0845d37d83828299227c893e361b7', '2022-04-01 02:30:14', '2022-04-01 02:30:15', NULL, '192.168.203.1', 'U', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (1, 17, 'itrip-service-orders.yaml', 'orders', '', 'spring:\n  application:\n    name: itrip-service-orders\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      # 配置控制台\n      transport:\n        dashboard: 192.168.203.130:8858\n      # 消息延时加载设置为false\n      eager: false\n      datasource:\n        ds:\n          server-addr: 192.168.203.130:8848\n          username: nacos\n          password: nacos\n          namespace: cdc378f4-114b-471b-8732-b7d38bcb02ea\n          data-id: itrip-service-orders-sentinel\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9002\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', 'fd1fab08f7ffc8dfff53d651a46c7e2d', '2022-04-01 02:31:50', '2022-04-01 02:31:50', NULL, '192.168.203.1', 'U', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (1, 18, 'itrip-service-orders.yaml', 'orders', '', 'spring:\n  application:\n    name: itrip-service-orders\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      # 配置控制台\n      transport:\n        dashboard: 192.168.203.130:8858\n      # 消息延时加载设置为false\n      eager: false\n      datasource:\n        ds:\n          server-addr: 192.168.203.130:8848\n          namespace: cdc378f4-114b-471b-8732-b7d38bcb02ea\n          data-id: itrip-service-orders-sentinel\n          rule-type: flow\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9002\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', 'ffdd9747e1dce76259be511385c11095', '2022-04-01 02:37:47', '2022-04-01 02:37:47', NULL, '192.168.203.1', 'U', 'cdc378f4-114b-471b-8732-b7d38bcb02ea');
    INSERT INTO `his_config_info` VALUES (2, 19, 'itrip-service-users.yaml', 'users', '', 'spring:\n  application:\n    name: itrip-service-users\n  # 配置注册中心\n  cloud:\n    nacos:\n      discovery:\n        server-addr: 192.168.203.130:8848\n    sentinel:\n      transport:\n        dashboard: 192.168.203.130:8858\n  datasource:\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://localhost:3306/itripdb?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8\n    username: root\n    password: root\n\nserver:\n  port: 9001\n\nmybatis-plus:\n  type-aliases-package: com.changan.entity\n  configuration:\n    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl\n  mapper-locations: classpath*:/mapper/UserMapper.xml\n', 'c6848c6c2044b081e483c9ab1209f8c0', '2022-04-01 03:14:15', '2022-04-01 03:14:15', NULL, '192.168.203.1', 'U', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (0, 20, 'itrip-service-users-sentinel-degrade', 'DEFAULT_GROUP', '', '[\r\n    {\r\n    \"resource\": \"/getOrderListByUserId\",\r\n    \"count\": 0.5,\r\n    \"grade\": 1,\r\n    \"passCount\": 0,\r\n    \"timeWindow\": 2\r\n  }\r\n]', '006192ea69dae386bfa1e03916de06b3', '2022-04-01 03:15:51', '2022-04-01 03:15:52', NULL, '192.168.203.1', 'I', 'faf33017-b8c2-48fa-9b29-09d644006946');
    INSERT INTO `his_config_info` VALUES (0, 21, 'itrip-gateway.yaml', 'gateway', '', 'server:\r\n  port: 9999\r\nspring:\r\n  cloud:\r\n    nacos:\r\n      discovery:\r\n        server-addr: 192.168.203.130:8848\r\n    gateway:\r\n      discovery:\r\n        locator:\r\n          enabled: true\r\n      routes:\r\n        - id: itrip-service-orders\r\n          uri: lb://itrip-service-orders\r\n          predicates:\r\n            - Path=/orders/**\r\n          filters:\r\n            - StripPrefix=1\r\n        - id: itrip-service-users\r\n          uri: lb://itrip-service-users\r\n          predicates:\r\n            - Path=/users/**\r\n          filters:\r\n            - StripPrefix=1\r\n  application:\r\n    name: itrip-gateway', '2ddb48eeabf9fb3d5666d5fdc0eacebc', '2022-04-02 06:35:45', '2022-04-02 06:35:45', NULL, '192.168.203.1', 'I', '0cbe8b45-e878-4c59-9ab8-5b8616ac4d57');
    INSERT INTO `his_config_info` VALUES (16, 22, 'itrip-gateway.yaml', 'gateway', '', 'server:\r\n  port: 9999\r\nspring:\r\n  cloud:\r\n    nacos:\r\n      discovery:\r\n        server-addr: 192.168.203.130:8848\r\n    gateway:\r\n      discovery:\r\n        locator:\r\n          enabled: true\r\n      routes:\r\n        - id: itrip-service-orders\r\n          uri: lb://itrip-service-orders\r\n          predicates:\r\n            - Path=/orders/**\r\n          filters:\r\n            - StripPrefix=1\r\n        - id: itrip-service-users\r\n          uri: lb://itrip-service-users\r\n          predicates:\r\n            - Path=/users/**\r\n          filters:\r\n            - StripPrefix=1\r\n  application:\r\n    name: itrip-gateway', '2ddb48eeabf9fb3d5666d5fdc0eacebc', '2022-04-02 06:40:33', '2022-04-02 06:40:33', NULL, '192.168.203.1', 'U', '0cbe8b45-e878-4c59-9ab8-5b8616ac4d57');
    
    -- ----------------------------
    -- Table structure for permissions
    -- ----------------------------
    DROP TABLE IF EXISTS `permissions`;
    CREATE TABLE `permissions`  (
      `role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
      `resource` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
      `action` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
      UNIQUE INDEX `uk_role_permission`(`role`, `resource`, `action`) USING BTREE
    ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for roles
    -- ----------------------------
    DROP TABLE IF EXISTS `roles`;
    CREATE TABLE `roles`  (
      `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
      `role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
      UNIQUE INDEX `idx_user_role`(`username`, `role`) USING BTREE
    ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Records of roles
    -- ----------------------------
    INSERT INTO `roles` VALUES ('nacos', 'ROLE_ADMIN');
    
    -- ----------------------------
    -- Table structure for tenant_capacity
    -- ----------------------------
    DROP TABLE IF EXISTS `tenant_capacity`;
    CREATE TABLE `tenant_capacity`  (
      `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Tenant ID',
      `quota` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '配额,0表示使用默认值',
      `usage` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '使用量',
      `max_size` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
      `max_aggr_count` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '聚合子配置最大个数',
      `max_aggr_size` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
      `max_history_count` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '最大变更历史数量',
      `gmt_create` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      `gmt_modified` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `uk_tenant_id`(`tenant_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = '租户容量信息表' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for tenant_info
    -- ----------------------------
    DROP TABLE IF EXISTS `tenant_info`;
    CREATE TABLE `tenant_info`  (
      `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
      `kp` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'kp',
      `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT 'tenant_id',
      `tenant_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT '' COMMENT 'tenant_name',
      `tenant_desc` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'tenant_desc',
      `create_source` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT 'create_source',
      `gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
      `gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE INDEX `uk_tenant_info_kptenantid`(`kp`, `tenant_id`) USING BTREE,
      INDEX `idx_tenant_id`(`tenant_id`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_bin COMMENT = 'tenant_info' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Records of tenant_info
    -- ----------------------------
    INSERT INTO `tenant_info` VALUES (1, '1', 'cdc378f4-114b-471b-8732-b7d38bcb02ea', 'orders', '订单的命名空间', 'nacos', 1648718577421, 1648718577421);
    INSERT INTO `tenant_info` VALUES (2, '1', 'faf33017-b8c2-48fa-9b29-09d644006946', 'users', '用户的命名空间', 'nacos', 1648718588816, 1648718588816);
    INSERT INTO `tenant_info` VALUES (3, '1', '0cbe8b45-e878-4c59-9ab8-5b8616ac4d57', 'gateway', '网关', 'nacos', 1648881242577, 1648881242577);
    
    -- ----------------------------
    -- Table structure for users
    -- ----------------------------
    DROP TABLE IF EXISTS `users`;
    CREATE TABLE `users`  (
      `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
      `password` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
      `enabled` tinyint(1) NOT NULL,
      PRIMARY KEY (`username`) USING BTREE
    ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Records of users
    -- ----------------------------
    INSERT INTO `users` VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', 1);
    
    SET FOREIGN_KEY_CHECKS = 1;
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286

    查看数据库是否有对应的记录
    在这里插入图片描述

    sentinel

    访问 http://192.168.203.129:8858/#/login使用账号sentinel/sentinel登录

    在这里插入图片描述

    sentinel安装成功!

    至此前期所需要的组件都安装成功,那么本期的“SpringCloud Alibaba微服务实战 - 基础环境准备”篇也就该结束啦

  • 相关阅读:
    内存函数(memcpy、memmove、memset、memcmp)你真的懂了吗?
    基于electron+vue+element构建项目模板之【打包篇】
    Ubuntu 20.04 LTS 安装Kubernetes 1.26
    7. 【B树】定义、操作(查增删)+ 【B+树】的定义、查找 + 【B+树 VS B树】
    会议邀请 | 思腾合力邀您共赴PRCV 2023第六届中国模式识别与计算机视觉大会
    JS逆向爬虫---请求参数加密②【某麦数据analysis参数加密】
    element ui el-select修改样式
    前端 | 前端工程化
    多个路径下python库导入
    不加班的测试/开发程序员不是好程序员?长远规划好自己的职场......
  • 原文地址:https://blog.csdn.net/weixin_50098749/article/details/125436837