当前位置:网站首页>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
边栏推荐
- MVVM模型
- 使用 bitnami/postgresql-repmgr 镜像快速设置 PostgreSQL HA
- Daily CISSP certification common mistakes (April 13, 2022)
- STM32 learning record 0008 - GPIO things 1
- QT tablewidget insert qcombobox drop-down box
- Test post and login function
- ESP32 LVGL8. 1 - label (style 14)
- ESP32 LVGL8. 1 - input devices (input devices 18)
- logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours
- Daily CISSP certification common mistakes (April 18, 2022)
猜你喜欢

Summary of actual business optimization scheme - main directory - continuous update

QT tablewidget insert qcombobox drop-down box

教你用简单几个步骤快速重命名文件夹名

ctfshow-web362(SSTI)

Quantexa CDI(场景决策智能)Syneo平台介绍

硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)

Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary

Function recursion and solving interesting problems

ctfshow-web362(SSTI)

os_authent_prefix
随机推荐
Jeecg boot microservice architecture
ESP32 LVGL8. 1 - label (style 14)
CISSP certified daily knowledge points (April 15, 2022)
ESP32 LVGL8. 1 - anim animation (anim 16)
Daily CISSP certification common mistakes (April 12, 2022)
Sentinel服务熔断实战(sentinel整合ribbon+openFeign+fallback)
Interpretation and compilation of JVM
回路-通路
Introduction to QT programming
STM32: LCD display
数据库上机实验四(数据完整性与存储过程)
SQL database syntax learning notes
Gson fastjason Jackson of object to JSON difference modifies the field name
Use of regular expressions in QT
Ctfshow - web362 (ssti)
How to virtualize the video frame and background is realized in a few simple steps
硬核解析Promise對象(這七個必會的常用API和七個關鍵問題你都了解嗎?)
机器学习理论之(7):核函数 Kernels —— 一种帮助 SVM 实现非线性化决策边界的方式
Software test summary
硬核解析Promise对象(这七个必会的常用API和七个关键问题你都了解吗?)