SpringCloud Alibaba Sentinel实现熔断与限流<2020-9>
SpringCloud Alibaba Sentinel
1、Sentinel是什么?
1.1、前言说明:
作用:实现熔断与限流 (Hystrix断路器 升级版)
文档直达: 官网中文文档
![**[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nPpye8gb-1598368138506)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200825221855431.png)]**](https://img-blog.csdnimg.cn/2020082523064036.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pmeDExMDE4MDQwOTE=,size_16,color_FFFFFF,t_70#pic_center)
1.2、Sentinel 的主要特性
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ImL2kRMc-1598368138509)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200825222003319.png)]](https://img-blog.csdnimg.cn/2020082523071037.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pmeDExMDE4MDQwOTE=,size_16,color_FFFFFF,t_70#pic_center)
2、Sentinel下载安装运行
下载地址: https://github.com/alibaba/Sentinel/releases
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-j15i4oln-1598368138510)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200825222801317.png)]](https://img-blog.csdnimg.cn/20200825230747926.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pmeDExMDE4MDQwOTE=,size_16,color_FFFFFF,t_70#pic_center)
直接 java -jar sentinel-dashboard-1.7.2.jar 运行
http://localhost:8080 账号:sentinel sentinel
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jKqKQrtU-1598368138512)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200825224231843.png)]](https://img-blog.csdnimg.cn/2020082523081894.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pmeDExMDE4MDQwOTE=,size_16,color_FFFFFF,t_70#pic_center)
3、创建演示工程
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OSu86J86-1598368138513)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200825230415272.png)]](https://img-blog.csdnimg.cn/20200825230844141.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pmeDExMDE4MDQwOTE=,size_16,color_FFFFFF,t_70#pic_center)
application.yml
server:
port: 8401
spring:
application:
name: cloudalibaba-sentinel-service
cloud:
nacos:
discovery:
server-addr: 192.168.199.130:8848 # nacos服务注册中心
sentinel:
transport:
dashboard: localhost:8080
port: 8719 #默认8719,假如被占用了会自动从8719开始依次+1扫描。直至找到未被占用的端口
# 监控图形化 界面
management:
endpoints:
web:
exposure:
include: '*'
注意:sentinel是懒加载机制 ,先执行几次接口 ,然后进入控制台查看流控详情
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QODUvpOi-1598368138515)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200825230055826.png)]](https://img-blog.csdnimg.cn/20200825230921566.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3pmeDExMDE4MDQwOTE=,size_16,color_FFFFFF,t_70#pic_center)
浙公网安备 33010602011771号