IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Java知识库 -> 2022/6/18 Spring Cloud Alibaba入门(基础环境准备) -> 正文阅读

[Java知识库]2022/6/18 Spring Cloud Alibaba入门(基础环境准备)

目录

1丶Spring Cloud Alibaba简介

2丶Spring Cloud Netflix

? ? ? ? 2.1丶什么是维护模式

? ? ? ? 2.2丶替代品

?3丶Spring Cloud Alibaba介绍

? ? ? ? 3.1丶主要功能

? ? ? ? 3.2丶组件

? ? ? ? 3.3丶版本管理规范

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

? ? ? ? ? ? ? ? 3.4.1丶2021.x 分支

? ? ? ? ? ? ? ? 3.4.2丶2.2.x 分支

? ? ? ? ? ? ? ? 3.4.3丶组件版本关系

?4丶基础环境准备

? ? ? ? ?4.1丶Dokcer-compose安装

? ? ? ? ?4.2丶Dokcer-compose常用命令

? ? ? ? ?4.3丶容器化

? ? ? ? ? ? ? ? 4.3.1丶安装 Nacos

????????????????4.3.2丶MySQL

? ? ? ? ? ? ? ? 4.3.3丶Nacos

? ? ? ? ? ? ? ? 4.3.4丶Sentinel

? ? ? ? ? ? ? ? 4.3.5丶Seata

? ? ? ? ? ? ? ? 4.3.6丶docker-compose

5丶环境验证?

? ? ? ? 5.1丶nacos

? ? ? ? 5.2丶sentinel


1丶Spring Cloud Alibaba简介

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

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

2丶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 系列技术栈进入维护模式(不再添加新特性)

? ? ? ? 2.1丶什么是维护模式

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

? ? ? ? 2.2丶替代品

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

CURRENT

REPLACEMENT

Hystrix

Resilience4j

Hystrix Dashboard / Turbine

Micrometer + Monitoring System

Ribbon

Spring Cloud Loadbalancer

Zuul 1

Spring Cloud Gateway

Archaius 1

Spring 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 的更多便利。

?3丶Spring Cloud Alibaba介绍

????????github地址

? ? ? ? 3.1丶主要功能

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

? ? ? ? 3.2丶组件

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

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

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

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

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

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

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

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

? ? ? ? 3.3丶版本管理规范

项目的版本号格式为 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 进行开发,所以三者之间的版本关系特别重要,一旦选错版本,项目就没法运行

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

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

版本说明 · alibaba/spring-cloud-alibaba Wiki · GitHub

由于 Spring Boot 2.4 以上和一下版本变化较大,目前企业级客户老项目相关 Spring Boot 版本仍停留在 Spring Boot 2.4 以下,为了同时满足存量用户和新用户不同需求,社区以 Spring Boot 2.4 为分界线,同时维护 2.2.x 和 2021.x 两个分支迭代。

? ? ? ? ? ? ? ? 3.4.1丶2021.x 分支

适配 Spring Boot 2.4, Spring Cloud 2021.x 版本及以上的 Spring Cloud Alibaba 版本如下表(最新版本用*标记):?(注意,该分支 Spring Cloud Alibaba 版本命名方式进行了调整, 未来将对应 Spring Cloud 版本, 前三位为 Spring Cloud 版本,最后一位为扩展版本,比如适配 Spring Cloud 2021.0.1 版本对应的 Spring Cloud Alibaba 第一个版本为:2021.0.1.0,第个二版本为:2021.0.1.1,依此类推)

Spring Cloud Alibaba VersionSpring Cloud VersionSpring Boot Version

2021.0.1.0*

Spring Cloud 2021.0.1

2.6.3

? ? ? ? ? ? ? ? 3.4.2丶2.2.x 分支

适配 Spring Boot 为 2.4, Spring Cloud Hoxton 版本及以下的 Spring Cloud Alibaba 版本如下表(最新版本用*标记):

Spring Cloud Alibaba VersionSpring Cloud VersionSpring Boot Version

2.2.7.RELEASE*

Spring Cloud Hoxton.SR12

2.3.12.RELEASE

2021.1

Spring Cloud 2020.0.1

2.4.2

2.2.6.RELEASE

Spring Cloud Hoxton.SR9

2.3.2.RELEASE

2.1.4.RELEASE

Spring Cloud Greenwich.SR6

2.1.13.RELEASE

2.2.1.RELEASE

Spring Cloud Hoxton.SR3

2.2.5.RELEASE

2.2.0.RELEASE

Spring Cloud Hoxton.RELEASE

2.2.X.RELEASE

2.1.2.RELEASE

Spring Cloud Greenwich

2.1.X.RELEASE

2.0.4.RELEASE(停止维护,建议升级)

Spring Cloud Finchley

2.0.X.RELEASE

1.5.1.RELEASE(停止维护,建议升级)

Spring Cloud Edgware

1.5.X.RELEASE

? ? ? ? ? ? ? ? 3.4.3丶组件版本关系

每个 Spring Cloud Alibaba 版本及其自身所适配的各组件对应版本如下表所示:

Spring Cloud Alibaba VersionSentinel VersionNacos VersionRocketMQ VersionDubbo VersionSeata Version

2021.0.1.0

1.8.3

1.4.2

4.9.2

2.7.15

1.4.2

2.2.7.RELEASE

1.8.1

2.0.3

4.6.1

2.7.13

1.3.0

2.2.6.RELEASE

1.8.1

1.4.2

4.4.0

2.7.8

1.3.0

2021.1 or 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE

1.8.0

1.4.1

4.4.0

2.7.8

1.3.0

2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE

1.8.0

1.3.3

4.4.0

2.7.8

1.3.0

2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE

1.7.1

1.2.1

4.4.0

2.7.6

1.2.0

2.2.0.RELEASE

1.7.1

1.1.4

4.4.0

2.7.4.1

1.0.0

2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE

1.7.0

1.1.4

4.4.0

2.7.3

0.9.0

2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE

1.6.3

1.1.1

4.4.0

2.7.3

0.7.1

?4丶基础环境准备

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

?内容主要基于三个微服务:用户服务AccountService,用户服务UserService,订单服务RecordService

用到的组件有:

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

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

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

? ? ? ? ?4.1丶Dokcer-compose安装

compose swram mechine

docker三剑客之一

注意:安装Dokcer-compose请先安装docker

参考地址:2022/6/15 docker安装与项目部署(入门教程)_Abcdzzr的博客-CSDN博客

# 下载1.25.0 docker compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 添加可执行权限
sudo chmod +x /usr/local/bin/docker-compose
# 测试安装
sudo docker-compose --version
#启动一个容器
docker-compose up -d
#停止容器
docker-compose down

? ? ? ? ?4.2丶Dokcer-compose常用命令

参考:Docker Compose 命令详解_BUG弄潮儿的博客-CSDN博客

MySQL 8.x

version: '3.1'
services:
  mysql8:
    image: mysql:8.0.13
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    command:
      --default-authentication-plugin=mysql_native_password
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --explicit_defaults_for_timestamp=true
      --lower_case_table_names=1
    ports:
      - 3306:3306
    volumes:
      - ./data:/var/lib/mysql

adminer

version: '3.1'
services:
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

gitlab

version: '3'
services:
    web:
      image: 'twang2218/gitlab-ce-zh'
      restart: always
      hostname: '119.45.140.73'
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://119.45.140.73:8080'
          gitlab_rails['gitlab_shell_ssh_port'] = 2222
          unicorn['port'] = 8888
          nginx['listen_port'] = 8080
      ports:
        - '8080:8080'
        - '8443:443'
        - '2222:22'
      volumes:
        - ./config:/etc/gitlab
        - ./data:/var/opt/gitlab
        - ./logs:/var/log/gitlab

?Jenkins

version: '3.1'
services:
  jenkins:
    restart: always
    image: jenkinsci/jenkins
    container_name: jenkins
    ports:
      - 8080:8080
      - 50000:50000
    environment:
      TZ: Asia/Shanghai
    volumes:
      - data:/var/jenkins_home

volumes:
  data:

?tomcat

version: '3.1'
services:
  tomcat:
    image: tomcat:latest
    restart: always
    ports:
      - 8080:8080

? ? ? ? ?4.3丶容器化

? ? ? ? ? ? ? ? 4.3.1丶安装 Nacos

docker pull nacos/nacos-server:1.4.1

nacos中的数据是存放在内存中的,一旦重启nacos数据就会丢失,所以说nacos一定要配置持久化

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

????????????????4.3.2丶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

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

  • 用mysql客户端连接你的容器,创建数据库(nacos_config)然后导入nacos的数据表

https://github.com/alibaba/nacos/tree/develop/distribution/conf/nacos-mysql.sql此数据库表可能存在bug,建议使用下面的数据库表

/*
 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;
  • 停止容器,由于加了--rm参数,所以容器会自动删除

docker stop containerID

? ? ? ? ? ? ? ? 4.3.3丶Nacos

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

配置项

描述

可选参数

默认值

MODE

模式 cluster/standalone

cluster/standalone

cluster

PREFER_HOST_MODE

是否支持 hostname

hostname/ip

ip

NACOS_SERVER_PORT

服务端口号

8848

SPRING_DATASOURCE_PLATFORM

单机模式支持 mysql

mysql / empty

empty

MYSQL_MASTER_SERVICE_HOST

mysql 主节点 host

MYSQL_MASTER_SERVICE_PORT

mysql 主节点 port

3306

MYSQL_MASTER_SERVICE_DB_NAME

mysql 主节点数据库名

MYSQL_MASTER_SERVICE_USER

mysql 主节点用户名

MYSQL_MASTER_SERVICE_PASSWORD

mysql 主节点密码

MYSQL_SLAVE_SERVICE_HOST

mysql 从节点 host

MYSQL_SLAVE_SERVICE_PORT

mysql 从节点 port

3306

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

? ? ? ? ? ? ? ? 4.3.4丶Sentinel

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

? ? ? ? ? ? ? ? 4.3.5丶Seata

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

? ? ? ? ? ? ? ? 4.3.6丶docker-compose

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

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

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

?如果是云服务器,请在安全组配置开放对应的端口号

# 这里尽量开放一下服务器的端口
查看防火墙状态:
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

5丶环境验证?

? ? ? ? 5.1丶nacos

ip地址填你的

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

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

?查看数据库是否有对应的记

? ? ? ? 5.2丶sentinel

ip地址填你的

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

sentinel安装成功!

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

  Java知识库 最新文章
计算距离春节还有多长时间
系统开发系列 之WebService(spring框架+ma
springBoot+Cache(自定义有效时间配置)
SpringBoot整合mybatis实现增删改查、分页查
spring教程
SpringBoot+Vue实现美食交流网站的设计与实
虚拟机内存结构以及虚拟机中销毁和新建对象
SpringMVC---原理
小李同学: Java如何按多个字段分组
打印票据--java
上一篇文章      下一篇文章      查看所有文章
加:2022-06-20 22:54:28  更:2022-06-20 22:56:50 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/23 16:30:27-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码