当前位置:   article > 正文

网关层面添加sentinel限流_sentinel是加在网关的吗

sentinel是加在网关的吗

网关层面添加sentinel限流

启动sentinel服务命令

在sentinel对应目录,打开命令行(cmd),启动运行sentinel

java -Dserver.port=8180 -Dcsp.sentinel.dashboard.server=localhost:8180 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar

  • 1
  • 2

网关服务添加依赖

 <!--假如网关层面进行限流,添加如下依赖-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
        </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

启动网关项目,检测sentinel控制台的网关菜单。

启动时,添加sentinel的jvm参数,通过此菜单可以让网关服务在sentinel控制台显示不一样的菜单,代码如下。

-Dcsp.sentinel.app.type=1
  • 1

![在这里插入图片描述](https://img-blog.csdnimg.cn/294d750b3716453dac35e6a08bc63267.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,s在这里插入图片描述
在这里插入图片描述
说明,假如没有发现请求链路,API管理,关闭网关项目,关闭sentinel,然后重启sentinel,重启网关项目.

在sentinel面板中设置限流策略

在这里插入图片描述

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号