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才会监测出相应的接口:

相关推荐
YOU OU8 天前
Alibaba Sentinel
sentinel
流烟默8 天前
Sentinel 规则持久化到 Nacos 实践(网关篇 + 普通应用篇)
nacos·sentinel·规则持久化
莫得感情 o9 天前
Redis 09 · 高可用:Sentinel 如何发现故障并完成切主
redis·缓存·sentinel
凌云若寒10 天前
CODESOFT试用流程
linux·运维·网络·数据库·sentinel
多敲代码防脱发16 天前
Alibaba Sentinel(熔断、限流)(国内下载Sentinel)
java·开发语言·sentinel
2601_9621819619 天前
【Spring Cloud Alibaba】Sentinel 服务熔断与流量控制
sentinel
lv__pf21 天前
Sentinel【TL微服务10、11】
java·微服务·sentinel
凤山老林21 天前
高可靠 API 网关架构:Spring Cloud Gateway 集成 Sentinel 实现智能限流、动态路由与安全管控
安全·spring cloud·架构·sentinel
就叫_这个吧23 天前
java springcloud熔断降级组件sentinel基础应用及nacos持久化处理
java·spring cloud·nacos·sentinel
aikopen23 天前
高可用 API 网关限流与微服务过载保护实战:从 Sentinel 动态阈值到 DB 连接池舱壁
数据库·微服务·sentinel