• SpringCloud怎么禁用sentinel



    简版答案

    在配置文件(如application.properties)中增加配置:

    spring.cloud.sentinel.enabled=false
    
    • 1

    长版答案

    接手了一个SpringCloud项目,默认已经集成了Sentinel,但是后来发现网站访问量很小,而且服务器资源也不够用了,需要禁用Sentinel来释放内存资源。

    理论上觉得应该在哪里有个开关,但是找了一小时才找到官方文档(算是文档吧):

    https://github.com/alibaba/spring-cloud-alibaba/blob/2.2.x/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-sentinel/src/main/resources/META-INF/additional-spring-configuration-metadata.json

    第一个配置就是了:

    {
      "properties": [
        {
          "name": "spring.cloud.sentinel.enabled",
          "type": "java.lang.Boolean",
          "defaultValue": true,
          "description": "enable or disable sentinel auto configure."
        },
        {
          "name": "resttemplate.sentinel.enabled",
          "type": "java.lang.Boolean",
          "defaultValue": true,
          "description": "enable or disable @SentinelRestTemplate."
        },
        {
          "name": "spring.cloud.sentinel.eager",
          "type": "java.lang.Boolean",
          "defaultValue": false,
          "description": "earlier initialize heart-beat when the spring container starts when the transport dependency is on classpath, the configuration is effective."
        },
        {
          "name": "spring.cloud.sentinel.web-context-unify",
          "type": "java.lang.Boolean",
          "defaultValue": true,
          "description": "Specify whether unify web context(i.e. use the default context name), and is true by default."
        },
        {
          "name": "spring.cloud.sentinel.transport.port",
          "type": "java.lang.String",
          "defaultValue": "8719",
          "description": "sentinel api port."
        },
        {
          "name": "spring.cloud.sentinel.transport.clientIp",
          "type": "java.lang.String",
          "description": "sentinel client ip connect to dashboard."
        },
        {
          "name": "spring.cloud.sentinel.transport.dashboard",
          "type": "java.lang.String",
          "description": "sentinel dashboard address, won't try to connect dashboard when address is empty."
        },
        {
          "name": "spring.cloud.sentinel.transport.heartbeatIntervalMs",
          "type": "java.lang.String",
          "description": "send heartbeat interval millisecond."
        },
        {
          "name": "spring.cloud.sentinel.filter.order",
          "type": "java.lang.Integer",
          "defaultValue": "Integer.MIN_VALUE",
          "description": "SentinelWebInterceptor order, will be register to InterceptorRegistry."
        },
        {
          "name": "spring.cloud.sentinel.filter.enabled",
          "type": "java.lang.Boolean",
          "defaultValue": true,
          "description": "Enable to register com.alibaba.csp.sentinel.adapter.spring.webmvc.SentinelWebInterceptor."
        },
        {
          "name": "spring.cloud.sentinel.metric.charset",
          "type": "java.lang.String",
          "defaultValue": "UTF-8",
          "description": "charset when sentinel write or search metric file."
        },
        {
          "name": "spring.cloud.sentinel.metric.fileSingleSize",
          "type": "java.lang.String",
          "description": "the metric file size."
        },
        {
          "name": "spring.cloud.sentinel.metric.fileTotalCount",
          "type": "java.lang.String",
          "description": "the total metric file count."
        },
        {
          "name": "spring.cloud.sentinel.log.dir",
          "type": "java.lang.String",
          "description": "log base directory."
        },
        {
          "name": "spring.cloud.sentinel.log.switch-pid",
          "type": "java.lang.Boolean",
          "defaultValue": false,
          "description": "log file should with pid."
        },
        {
          "name": "spring.cloud.sentinel.block-page",
          "type": "java.lang.String",
          "description": "the process page when the flow control is triggered."
        },
        {
          "name": "spring.cloud.sentinel.servlet.block-page",
          "type": "java.lang.String",
          "description": "recommend use spring.cloud.sentinel.block-page."
        },
        {
          "name": "spring.cloud.sentinel.flow.coldFactor",
          "type": "java.lang.String",
          "defaultValue": "3",
          "description": "sentinel the cold factor."
        },
        {
          "name": "management.health.sentinel.enabled",
          "type": "java.lang.Boolean",
          "description": "Whether to enable sentinel health check.",
          "defaultValue": true
        },
        {
          "defaultValue": "false",
          "name": "feign.sentinel.enabled",
          "description": "If true, an OpenFeign client will be wrapped with a Sentinel circuit breaker.",
          "type": "java.lang.Boolean"
        }
      ]
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
  • 相关阅读:
    【AI作画】使用stable-diffusion-webui搭建AI作画平台
    2.2.5 SQL注入(盲注)
    SpringMVC全注解开发
    k8s二进制安装
    安装EasyX--图形库--从代码到图形
    扩散模型 DDPM 核心代码梳理
    如何防止ERP实施范围的的扩大
    Next-ViT学习笔记
    PHP排序sort()、asort() 和 ksort() 的区别及用法
    git上传代码到GitHub
  • 原文地址:https://blog.csdn.net/h837087787/article/details/126777180