当前位置:网站首页>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
边栏推荐
- Introduction to quantexa CDI syneo platform
- 深入理解 Golang 中的 new 和 make 是什么, 差异在哪?
- Sentinel规则持久化进Nacos
- In shell programming, the shell file with relative path is referenced
- The connection of imx6 network port is unstable after power on
- 解决:cnpm : 无法加载文件 ...\cnpm.ps1,因为在此系统上禁止运行脚本
- CISSP certified daily knowledge points (April 13, 2022)
- Daily network security certification test questions (April 13, 2022)
- Matlab tips (6) comparison of seven filtering methods
- [mathematical modeling] - analytic hierarchy process (AHP)
猜你喜欢
Solution to Chinese garbled code after reg file is imported into the registry
CANopen STM32 transplantation
WiFi ap6212 driver transplantation and debugging analysis technical notes
Custom prompt box MessageBox in QT
硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)
ctfshow-web362(SSTI)
解决:cnpm : 無法加載文件 ...\cnpm.ps1,因為在此系統上禁止運行脚本
[popular science] CRC verification (I) what is CRC verification?
Notepad + + replaces tabs with spaces
Use of regular expressions in QT
随机推荐
Resolution: cnpm: unable to load file \cnpm. PS1, because running scripts is prohibited on this system
Solution to Chinese garbled code after reg file is imported into the registry
Ctfshow - web362 (ssti)
Database computer experiment 4 (data integrity and stored procedure)
Imx6 debugging LVDS screen technical notes
Cygwin64 right click to add menu, and open cygwin64 here
The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
In win10 system, all programs run as administrator by default
QT curve / oscilloscope customplot control
CISSP certified daily knowledge points (April 12, 2022)
listener. log
Résolution: cnpm: impossible de charger le fichier... Cnpm. PS1 parce que l'exécution de scripts est désactivée sur ce système
【ACM】70. climb stairs
14个py小游戏源代码分享第二弹
串口调试工具cutecom和minicom
Dynamically add default fusing rules to feign client based on sentinel + Nacos
【数学建模】—— 层次分析法(AHP)
Golang 语言实现TCP UDP通信
Daily network security certification test questions (April 12, 2022)
Implementation of TCP UDP communication with golang language