当前位置:网站首页>【微服务|Sentinel】sentinel数据持久化
【微服务|Sentinel】sentinel数据持久化
2022-06-27 20:50:00 【步尔斯特】
持久化流程
为什么持久化?不持久化,重启应用,数据就没了啊。这也就是所谓的原始模式。
我们推荐通过控制台设置规则后将规则推送到统一的规则中心,客户端实现 ReadableDataSource 接口端监听规则中心实时获取变更。
流程如下:
DataSource 扩展常见的实现方式
- 拉模式:客户端主动向某个规则管理中心定期轮询拉取规则,这个规则中心可以是 RDBMS、文件,甚至是 VCS 等。这样做的方式是简单,缺点是无法及时获取变更;
- 推模式:规则中心统一推送,客户端通过注册监听器的方式时刻监听变化,比如使用 Nacos、Zookeeper 等配置中心。这种方式有更好的实时性和一致性保证。
我们来看看都有哪几种模式以及他们之间的区别。

pom文件依赖
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
yaml配置
spring:
cloud:
sentinel:
transport:
dashboard: localhost:8080
# port: 8719
# client-ip: localhost
eager: true
web-context-unify: false
datasource:
# 规则命名:可以任意命名
flow-rule:
# 持久化在nacos中,还可选择zookeeper,consul等
nacos:
# nacos服务地址
server-addr: ip:8848
namespace: 45de6484-833e-4cce-b895-f14095f20605
group-id: SENTINEL_GROUP
# 配置DataId
data-id: ossa-service-producer-flow-rule
data-type: json
# 流控规则:FLOW,DEGRADE,PARAM_FLOW等
rule-type: flow
nacos配置

[
{
"resource": "/test",
"limitApp": "default",
"grade": 1,
"count": 2,
"strategy": 0,
"controlBehavior": 0,
"clusterMode": false
},
{
"resource": "/producer/{id}",
"limitApp": "default",
"grade": 1,
"count": 2,
"strategy": 0,
"controlBehavior": 0,
"clusterMode": false
}
]
边栏推荐
- Getting started with pytorch
- Go语言fsnotify接口实现监测文件修改
- Technical implementation process of easycvr platform routing log function [code attached]
- 【IDEA】IDEA 格式化 代码技巧 idea 格式化 会加 <p> 标签
- Hiplot 在線繪圖工具的本地運行/開發庫開源
- Detect objects and transfer images through mqtt
- 凌云出海记 | 沐融科技&华为云:打造非洲金融SaaS解决方案样板
- Summary of solutions to cross system data consistency problems
- [js]var, let,const 的区别
- Realization of kaggle cat dog recognition by pytorch
猜你喜欢

在线JSON转PlainText工具

这类人开始被VC疯抢,月薪8万

Liuleifeng, a "good man in Guangzhou" in the first quarter of 2022, has a strong sense of integrity and food safety

第一性原理(最优解理论)

Arcgis-engine二次开发之空间关系查询与按图形查询

Sentinel

【蓝桥杯集训100题】scratch数字计算 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第16题
![[Blue Bridge Cup training 100 questions] scratch digital calculation Blue Bridge Cup competition special prediction programming question collective training simulation exercise question No. 16](/img/7c/d4ea8747ce45fd2eb59a8f968653db.png)
[Blue Bridge Cup training 100 questions] scratch digital calculation Blue Bridge Cup competition special prediction programming question collective training simulation exercise question No. 16

Stream + Nacos

Livox Lidar+APX15 实时高精度雷达建图复现整理
随机推荐
MapReduce初级编程实践
Typora 1.2.5等版本下载
Practice torch FX: pytorch based model optimization quantization artifact
clickonce 部署ClickOnce应用程序时出错-清单中的引用与下载的程序集的标识不匹配
Hiplot 在線繪圖工具的本地運行/開發庫開源
Azure Kinect DK realizes 3D reconstruction (Jetson real-time version)
如何设置企业微信群机器人定时发消息?
Consumer finance app user insight in the first quarter of 2022 - a total of 44.79 million people
Batch processing - Excel import template 1.1- support multiple sheet pages
上手了一个自然语言模型BLOOM
What problems should be paid attention to in the serpentine wiring of PCB?
Advertising is too "wild", Yoshino "surrenders"
SQL Server 2016详细安装教程(附注册码和资源)
Summary of various loams (laser SLAM)
First principles (optimal solution theory)
OData - SAP S4 OP 中使用SAP API Hub 的API
Discuz small fish game wind shadow legend business gbk+utf8 version template /dz game website template
How to start ID from 1 after MySQL deletes a table
Redis principle - string
Open source of local run / development library of hiplot online drawing tool