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

相关推荐
一颗知足的心2 小时前
SpringCloud Alibaba五大组件之——Sentinel
spring·spring cloud·sentinel
1.01^10003 天前
[000-01-008].第08节:Sentinel 环境搭建
sentinel
世俗ˊ3 天前
微服务-- Sentinel的使用
java·微服务·sentinel
朱杰jjj4 天前
Sentinel实时监控不展示问题
sentinel
灰色孤星A7 天前
微服务保护学习笔记(五)Sentinel授权规则、获取origin、自定义异常结果、规则持久化
微服务·sentinel·微服务保护·规则持久化·授权规则·雪崩问题
晴子呀12 天前
Redis Sentinel(哨兵)详解
数据库·redis·sentinel
cnsummerLi13 天前
springboot项目引入Sentinel熔断
java·spring boot·sentinel
Hsu琛君珩14 天前
【Redis】Redis Sentinel(哨兵)系统:自动故障恢复与高可用性配置全解
redis·sentinel·wpf
钗头风14 天前
(十五)SpringCloudAlibaba-Sentinel持久化到Nacos
sentinel
这河里吗l17 天前
Java后端面试题(微服务相关)(day12)
java·开发语言·微服务·gateway·sentinel