Sentinel 控制台安装
下载sentinel-dashboard.jar包
https://github.com/alibaba/Sentinel/releases
运行jar包
我特意指定了端口是18080,同时不让sentinel-dashboard监控自己
nohup java -Dserver.port=18080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.7.2.jar > log.file 2>&1 &
访问sentinel-dashboard
用户名密码都是sentinel
新增Sentinel客户端
参考文档
https://github.com/alibaba/spring-cloud-alibaba/wiki/Sentinel
https://github.com/alibaba/Sentinel/wiki/%E6%B3%A8%E8%A7%A3%E6%94%AF%E6%8C%81
配置POM文件
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
配置dashboard地址
server.port=18080
spring.application.name=test
spring.cloud.sentinel.transport.dashboard=192.168.152.153:18080
配置SentinelResource注解
启动客服端
访问下controller端口
因为我们没有在sentinel-dashboard配置规则,所以访问的时候,是没有什么感觉异常的地方。sentinel对代码侵入性小
查看sentinel-dashboard
sentinel-dashboard已经开始解控我们的应用了
设置下限流
再次快速访问接口时
再次快速访问接口,我们发现,有些请求被熔断降级了