Sentinel熔断降级用法

最后更新于:2022-04-02 07:10:15

[TOC] ## jeecg-cloud-sentinel ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/70/d8/70d8fb095a6de35b9ae668356223ba02_560x671.png) ### sentinel使用准备 #### 启动sentinel项目 com.alibaba.csp.sentinel.dashboard.JeecgSentinelDashboardApplication ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/c6/fd/c6fd364dc0292c089791d87f50cf81f1_479x185.png) #### 访问地址 [http://localhost:8087](http://localhost:8087) 账号密码:sentinel/sentinel ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/a7/9b/a79be1a5f8ec3aca0dbc412b000c294b_1146x669.png) **说明:第一次访问,内容是空。** ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/20/ff/20ff90d10cb1b357de441651393bebc8_1920x848.png) 访问gateway任意接口,就会出现应用 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/09/69/0969aeca22df698ee75937e701d189c0_2536x1123.png) #### 网关中(gateway)配置sentinel 添加sentinel依赖 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/cb/1f/cb1fff3326fdddf1821a0423845dd6f0_1292x657.png) 添加sentinel配置 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/e4/89/e4893c1281f30555bb1009eaab9245e4_1122x598.png) ### 限流某个微服务模块的全部接口 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/c0/48/c048c8e90db5d03ed2e63a52903c0999_1881x578.png) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/18/72/1872ffa520092b9ef893001def1dc966_1154x697.png) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/18/a5/18a529d6132517b96cf4d22de014b3db_1862x507.png) 添加成功后nacos中会自动生成jeecg-gateway-flow-rules文件 如下图 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/bf/87/bf879abbfabf5663de850b41e0f173ff_1490x622.png) 查看nacos文件内容 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/1b/31/1b319f21947e47d4aa39166853add6cb_2071x381.png) 访问某个接口进行测试 1秒点一下测试结果如下 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/05/ee/05eefff5c018fd80d3fde5b05f6d6f4c_1170x480.png) 快速点击测试结果如下 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/99/c1/99c1d6afcd950d73cc4c476a09f322c0_871x470.png) 说明我们的限流配置起了作用 ### 如何配置单独限制某个接口 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/d8/72/d872a7c6a25b54da97e1aea3eebfe15b_1893x719.png) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/6c/db/6cdbbdb863390f0d04a97a93e9fa82b8_1867x785.png) **docker 部署脚本:** `bladex/sentinel-dashboard`, 默认账号密码为 \[sentinel sentinel\] ``` version: '3.5' services: sentinel-dashboard: image: bladex/sentinel-dashboard:1.8.0 container_name: sentinel-dashboard #account and password: [sentinel sentinel] #修改默认密码为 123456 environment: - sentinel.dashboard.auth.password=123456 restart: always ports: - 8858:8858 ``` * 官方文档:https://sentinelguard.io/zh-cn/docs/dashboard.html
';