Sentinel

安装sentinel:

执行命令;

XML 复制代码
java -jar sentinel-dashboard-1.8.6.jar

注:sentinel的默认端口为8080,容易出现tomcat的冲突。

当端口冲突,可以使用该指令修改sentinel的端口

默认账号和密码都为sentinel

Springcloud整合sentinel:

导入依赖:

XML 复制代码
 <!--SpringCloud alibaba sentinel -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>
        <!--nacos-discovery-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>

application.yml文件配置:

XML 复制代码
server:
  port: 8401

spring:
  application:
    name: cloudalibaba-sentinel-service
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848         #Nacos服务注册中心地址
    sentinel:
      transport:
        dashboard: localhost:8858 #配置Sentinel dashboard控制台服务地址
        port: 8719 #默认8719端口,假如被占用会自动从8719开始依次+1扫描,直至找到未被占用的端口

测试类:

java 复制代码
package com.wen.cloud.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class FlowLimitController
{

    @GetMapping("/testA")
    public String testA()
    {
        return "------testA";
    }

    @GetMapping("/testB")
    public String testB()
    {
        return "------testB";
    }
}

测试:

先访问接口 sentinel才会监测出相应的接口:

相关推荐
库库林_沙琪马12 小时前
3、Sentinel
服务器·网络·sentinel
大大大大物~1 天前
Spring Cloud熔断与降级:核心区别与实践指南【怎么理解?解决了什么问题?各自的适用场景?Sentinel实现代码示例】
spring cloud·sentinel·熔断·降级
serendipity_hky1 天前
【SpringCloud | 第3篇】Sentinel 服务保护(限流、熔断降级)
java·后端·spring·spring cloud·微服务·sentinel
小毅&Nora2 天前
【后端】【诡秘架构】 ② 序列8:小丑 - 熔断降级的艺术:用 Sentinel 实现优雅降级,笑对流量洪峰
架构·sentinel·熔断降级
Haooog2 天前
微服务保护学习
java·学习·微服务·sentinel
布茹 ei ai3 天前
5、基于 GEE 的 Sentinel-1 SAR 地震滑坡变化检测系统:2022 泸定地震案例
javascript·sentinel·遥感·gee·云平台
lang201509283 天前
深入解析Sentinel熔断器核心机制
sentinel
lang201509283 天前
Sentinel系统保护规则深度解析
sentinel
lang201509284 天前
深入解析Sentinel熔断机制
java·前端·sentinel
lang201509284 天前
Sentinel熔断降级核心:DegradeSlot解析
sentinel