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

相关推荐
v***56511 小时前
使用bitnamiredis-sentinel部署Redis 哨兵模式
数据库·redis·sentinel
Owen__z12 天前
GEE统计特定区域特定时间上的Landsat/Sentinel的影像信息
python·sentinel·gee·geemap·landsat
我要去腾讯12 天前
Springcloud核心组件之Sentinel详解
java·spring cloud·sentinel
哦你看看17 天前
Redis Sentinel哨兵集群
linux·redis·bootstrap·sentinel
2501_9387900718 天前
Spring Cloud Alibaba 2023 版:Nacos 服务发现与 Sentinel 限流的整合方案
sentinel·服务发现
青鱼入云18 天前
Sentinel介绍
微服务·sentinel
青鱼入云18 天前
Feign如何集成Sentinel
spring cloud·微服务·sentinel
一周困⁸天.20 天前
Redis Sentinel哨兵集群
redis·bootstrap·sentinel
一条懒鱼66620 天前
Redis Sentinel哨兵集群
数据库·redis·sentinel
2301_7976042421 天前
d44:Sentinel 微服务流量控制与 Seata 分布式事务
分布式·微服务·sentinel