title: SpringCloudAlibaba-14-sentinel规则持久化-file
date: 2020-02-02 10:07:44
tags:

SpringCloudAlibaba

前言

之前的限流及其其他操作,当我们重启应用后,对应的规则在sentinel里面已经丢失不复存在了。现在我们主要说明sentinel参数如何持久化?

内容

1.规则持久化

目前支持file,nacos,zk,apollo,redis这5种类型
如果你想扩展其他的也提供了对应的接口。

2.规则持久化-file

我们先讲解规则存放在file里面。

  1. 1.在应用程序的resources文件下创建file:flowrule.json
  2. 2.填写限流属性规则:

  3. 3.我们将上面配置添加到配置中去:application.yml

server:
  port: 18080
spring:
  application:
    name: sentinel-core-example
  cloud:
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080
      datasource:
        ds1:
          file:
            file: classpath:flowrule.json
            data-type: json
            rule-type: flow

毕业于<br>相信技术可以改变人与人之间的生活<br>码农一枚