springcloud 集成Sentinel 1.8持久化到nacos

2021-03-06 08:27

阅读:431

标签:framework   loading   info   规则   sys   work   dash   rgba   名称   

1、客户端pom引入

 dependency>
            groupId>com.alibaba.cloudgroupId>
            artifactId>spring-cloud-starter-alibaba-sentinelartifactId>
            version>2.2.4.RELEASEversion>
            exclusions>
                exclusion>
                    groupId>com.alibabagroupId>
                    artifactId>fastjsonartifactId>
                exclusion>
            exclusions> 
  dependency>
 dependency>
    groupId>com.alibaba.cspgroupId>
    artifactId>sentinel-datasource-nacosartifactId>
    version>1.8.0version>
dependency>

2、yaml文件修改

spring:
  cloud: 
    sentinel:
      port: 8719
      eager: true
      transport: 
     # sentinel客户端地址 dashboard:
127.0.0.1:8080 datasource: flow: nacos:
#nacos地址 server
-addr: ${spring.cloud.nacos.discovery.server-addr}
       #nacos dataId 详细看 sentinel 客户端添加到nacos下的保持一致 dataId: ${spring.application.name}
-flow-rules
#nacos namespace 详细看 sentinel 客户端添加到nacos下的保持一致 namespace: ${spring.cloud.nacos.discovery.namespace}
       #nacos namespace  详细看 sentinel 客户端添加到nacos下的保持一致        groupId: SENTINEL_GROUP
#data-type: json # 规则类型,取值见: # org.springframework.cloud.alibaba.sentinel.datasource.RuleType rule-type: flow #熔断降级 名称随意 degrade: nacos: server-addr: ${spring.cloud.nacos.discovery.server-addr} dataId: ${spring.application.name}-degrade-rules namespace: ${spring.cloud.nacos.discovery.namespace} groupId: SENTINEL_GROUP rule-type: degrade #系统规则 名称随意 system: nacos: server-addr: ${spring.cloud.nacos.discovery.server-addr} dataId: ${spring.application.name}-system-rules namespace: ${spring.cloud.nacos.discovery.namespace} groupId: SENTINEL_GROUP rule-type: system #授权规则 名称随意 authority: nacos: server-addr: ${spring.cloud.nacos.discovery.server-addr} dataId: ${spring.application.name}-authority-rules namespace: ${spring.cloud.nacos.discovery.namespace} groupId: SENTINEL_GROUP rule-type: authority #参数规则 名称随意 param-flow: nacos: server-addr: ${spring.cloud.nacos.discovery.server-addr} dataId: ${spring.application.name}-param-flow-rules namespace: ${spring.cloud.nacos.discovery.namespace} groupId: SENTINEL_GROUP rule-type: param-flow

 

3、测试
   在sentinel 客户端增加 接口的 熔断规则后 访问该接口 出现如下场景 即是成功

技术图片

 

springcloud 集成Sentinel 1.8持久化到nacos

标签:framework   loading   info   规则   sys   work   dash   rgba   名称   

原文地址:https://www.cnblogs.com/ldmy/p/14302332.html


评论


亲,登录后才可以留言!