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

相关推荐
接着奏乐接着舞1 天前
Sentinel
sentinel
随风,奔跑2 天前
Spring Boot Alibaba(三)----Sentinel
spring boot·后端·sentinel
武超杰2 天前
Sentinel 安装启动 + 全规则详解 + Feign 整合 + 持久化
sentinel
青槿吖2 天前
Sentinel 进阶实战:Feign 整合 + 全局异常 + Nacos 持久化,生产环境直接用
java·开发语言·spring cloud·微服务·云原生·ribbon·sentinel
StackNoOverflow2 天前
Sentinel服务保护框架完全指南:从原理到实践
java·数据库·sentinel
tsyjjOvO2 天前
SpringCloud Alibaba Sentinel 从入门到精通
spring·spring cloud·sentinel
恼书:-(空寄2 天前
Sentinel 限流降级:滑动窗口原理 + 生产实战全解
sentinel·限流
身如柳絮随风扬3 天前
深入理解 Sentinel:服务雪崩、熔断原理、使用实践与规则持久化
java·微服务·sentinel
weixin_704266053 天前
Sentinel:微服务流量防护与熔断降级实战指南
sentinel
武超杰3 天前
微服务服务保护:Sentinel 从入门到流控规则实战
微服务·架构·sentinel