当前位置:网站首页>Sentinel rule persistence into Nacos
Sentinel rule persistence into Nacos
2022-04-23 18:38:00 【Hua Weiyun】
@toc
Source code address :gitee Code warehouse address
1、 Why would you Sentienl Rule persistence ?
Once we restart the app ,sentinel The rules will disappear , The production environment needs to persist the configuration rules
2、 The idea of persistence
We will now persist the current limiting configuration rule into Nacos preservation , Just refresh 8401 Some rest Address ,sentinel You can see the flow control rules of the console , as long as Nacos The configuration is not deleted , in the light of 8401 On sentinel The flow control rules on the Internet remain valid .
3、 Operation steps
3.1 Introducing dependencies into a project
<!--SpringCloud ailibaba sentinel-datasource-nacos --><dependency> <groupId>com.alibaba.csp</groupId> <artifactId>sentinel-datasource-nacos</artifactId></dependency>
3.2 add to Nacos Data source configuration
application.yml
server: port: 8401spring: application: name: cloudalibaba-sentinel-service cloud: nacos: discovery: #Nacos Address of service registration center server-addr: localhost:8848 sentinel: transport: # To configure Sentinel dashboard Address dashboard: localhost:8080 # Default 8719 port , If it is occupied, it will be automatically transferred from 8719 Start in sequence +1 scanning , Until the unoccupied port is found port: 8719 datasource: ds1: # add to nacos Configuration of data source , take sentinel Configure persistence nacos Inside nacos: server-addr: localhost:8848 dataId: cloudalibaba-sentinel-service groupId: DEFAULT_GROUP data-type: json rule-type: flowmanagement: endpoints: web: exposure: include: '*'
3.3 add to Nacos Business rule configuration
[ { "resource": "/rateLimit/byUrl", "limitApp": "default", "grade": 1, "count": 1, "strategy": 0, "controlBehavior": 0, "clusterMode": false }]
resource: Resource name ;
limitApp: Source application ;
grade: Threshold type ,0 Number of threads ,1 Express QPS;
count: Stand alone threshold ;
strategy: Flow control mode ,0 It means direct ,1 Express Association ,2 Represents a link ;
controlBehavior: Flow control effect ,0 Express a quick failure ,1 Express Warm Up,2 Stand in line ;
clusterMode: Cluster or not .
3.4 start-up sentinel
3.5 Start at this time 8401 Micro service and refresh Sentinel
Found that the business rules have .
nacos above :
sentinel above :
3.6 test
What we configured above means , This interface can only handle 1 A request , Then we frequently refresh requests , See if the current limit rules are in effect .
Normal access first :http://localhost:8401/rateLimit/byUrl
Frequent visits :http://localhost:8401/rateLimit/byUrl
You can see , Triggered the current limit rule . Here we do not specify in the program blockHandler, Therefore, the information after the default current limit is displayed .
3.7 stop it 8401 Micro service view
stop it 8401 It is found that the flow control rules are gone .
3.8 restart 8401 Look at microservices again sentinel
Or not? , Let's visit once http://localhost:8401/rateLimit/byUrl, Refresh again Sentinel
Configuration error , Persistence validation passed .
版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231836021946.html
边栏推荐
- In win10 system, all programs run as administrator by default
- Daily network security certification test questions (April 13, 2022)
- [popular science] CRC verification (I) what is CRC verification?
- Notepad + + replaces tabs with spaces
- Kettle paoding jieniu Chapter 17 text file output
- Introduction to quantexa CDI syneo platform
- 多功能工具箱微信小程序源码
- Multifunctional toolbox wechat applet source code
- 解决:cnpm : 无法加载文件 ...\cnpm.ps1,因为在此系统上禁止运行脚本
- Interpretation and compilation of JVM
猜你喜欢
Query the logistics update quantity according to the express order number
Summary of actual business optimization scheme - main directory - continuous update
根据快递单号查询物流查询更新量
Excel intercept text
Custom prompt box MessageBox in QT
STM32学习记录0008——GPIO那些事1
Promote QT default control to custom control
iptables初探
实战业务优化方案总结---主目录---持续更新
ESP32 LVGL8. 1 - input devices (input devices 18)
随机推荐
Nacos作为服务配置中心实战
[mathematical modeling] - analytic hierarchy process (AHP)
The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
Quantexa CDI(场景决策智能)Syneo平台介绍
iptables -L执行缓慢
On iptables
纠结
WiFi ap6212 driver transplantation and debugging analysis technical notes
Software test summary
Jeecg boot microservice architecture
Daily CISSP certification common mistakes (April 13, 2022)
STM32: LCD display
STM32: LCD显示
Query the logistics update quantity according to the express order number
Daily CISSP certification common mistakes (April 11, 2022)
Seata处理分布式事务
ctfshow-web362(SSTI)
In shell programming, the shell file with relative path is referenced
After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
Daily network security certification test questions (April 14, 2022)