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

相关推荐
述雾学java8 小时前
Spring Cloud Feign 整合 Sentinel 实现服务降级与熔断保护
java·spring cloud·sentinel
虚!!!看代码11 小时前
【Sentinel学习】
网络·sentinel
Fireworkitte11 小时前
Redis 源码 tar 包安装 Redis 哨兵模式(Sentinel)
数据库·redis·sentinel
何苏三月11 小时前
SpringCloud系列 - Sentinel 服务保护(四)
spring·spring cloud·sentinel
夢想执行家1 天前
Docker拉取bladex 、 sentinel-dashboard
docker·eureka·sentinel
sevevty-seven12 天前
Sentinel
linux·服务器·sentinel
秋恬意12 天前
什么是Sentinel?以及优缺点
sentinel
liang899912 天前
Sentinel(一):Sentinel 介绍和安装
sentinel
述雾学java14 天前
Sentinel 服务限流机制
sentinel
2401_8532757315 天前
Sentinel实现原理
服务器·网络·sentinel