work hard work smart

专注于Java后端开发。 不断总结,举一反三。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

服务容错-Sentinel

Posted on 2021-01-08 15:23  work hard work smart  阅读(117)  评论(0编辑  收藏  举报

1、什么是Sentinel

Sentinel轻量级的流量控制,熔断降级Java库。面向云原生微服务的高可用流控防护组件

https://github.com/alibaba/Sentinel

 

2、集成Sentinel

在Order服务中集成Sentinel

增加依赖

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>

        <!-- /actuator/sentinel-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

  

增加配置

 

 

访问Order服务

http://192.168.20.108:8071/order/actuator/sentinel

 

3、Sentinel控制台安装 

https://github.com/alibaba/Sentinel/releases

下载版本 1.6.3 (与集成的版本保持一致)

https://github.com/alibaba/Sentinel/releases/tag/1.6.3

 

下载: sentinel-dashboard-1.6.3.jar

 放在D:\Tools\sentinel

cd D:\Tools\sentinel

java -jar sentinel-dashboard-1.6.3.jar

 

 

打开客户端:  http://localhost:8080 用户名和密码分别为sentinel和sentinel

 

Order服务整合Sentinel控制台

指定Sentinel控制台的地址。

 

 

再次查看 http://localhost:8080,还是和原来一样,空白的页面

调用一个order服务的接口,如http://localhost:8071/order/prod/1

再次查看 http://localhost:8080,已经有了Order服务,说明Sentinel是懒加载的。