当前位置:网站首页>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
边栏推荐
- Domestic GD chip can filter
- Multifunctional toolbox wechat applet source code
- Ctfshow - web362 (ssti)
- Stm32mp157 wm8960 audio driver debugging notes
- CISSP certified daily knowledge points (April 14, 2022)
- os_ authent_ Prefix
- iptables初探
- Summary of actual business optimization scheme - main directory - continuous update
- 昇腾 AI 开发者创享日全国巡回首站在西安成功举行
- logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
猜你喜欢
实战业务优化方案总结---主目录---持续更新
WiFi ap6212 driver transplantation and debugging analysis technical notes
ctfshow-web362(SSTI)
Stm32mp157 wm8960 audio driver debugging notes
使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
教你用简单几个步骤快速重命名文件夹名
Teach you to quickly rename folder names in a few simple steps
Matlab tips (6) comparison of seven filtering methods
In win10 system, all programs run as administrator by default
Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary
随机推荐
WiFi ap6212 driver transplantation and debugging analysis technical notes
22 year flying Book manpower Kit
ESP32 LVGL8. 1 - event (event 17)
Function recursion and solving interesting problems
listener.log
Daily network security certification test questions (April 14, 2022)
Daily network security certification test questions (April 12, 2022)
视频边框背景如何虚化,简单操作几步实现
QT curve / oscilloscope customplot control
ESP32 LVGL8. 1 - input devices (input devices 18)
机器学习实战 -朴素贝叶斯
Machine learning practice - naive Bayes
kettle庖丁解牛第17篇之文本文件输出
Daily CISSP certification common mistakes (April 19, 2022)
Use bitnami / PostgreSQL repmgr image to quickly set up PostgreSQL ha
In shell programming, the shell file with relative path is referenced
Cutting permission of logrotate file
QT error: no matching member function for call to ‘connect‘
Creation and use of QT dynamic link library
Resolution: cnpm: unable to load file \cnpm. PS1, because running scripts is prohibited on this system