前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >启动sentinel入门

启动sentinel入门

原创
作者头像
用户3293499
发布于 2024-10-06 13:33:53
发布于 2024-10-06 13:33:53
1570
举报
文章被收录于专栏:微服务微服务

启动sentinel

java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dcsp.sentinel.heartbeat.client.ip=192.168.101.9 -Dcsp.sentinel.log.dir=${HOME}/UserData/programs/sentinel/logs -Dproject.name=mysentinel -jar sentinel-dashboard-1.8.8.jar

配置参数

名称

含义

类型

默认值

是否必须

备注

project.name

指定应用的名称

String

null

若未指定,则默认解析 main 函数的类名作为应用名。实际项目使用中建议手动指定应用名。

csp.sentinel.app.type

指定应用的类型

int

0 (APP_TYPE_COMMON)

1.6.0 引入

csp.sentinel.metric.file.single.size

单个监控日志文件的大小

long

52428800 (50MB)

csp.sentinel.metric.file.total.count

监控日志文件的总数上限

int

6

csp.sentinel.metric.flush.interval

Sentinel metric log 任务的时间频率,单位为秒(s)

int

1

若配置0,则代表不打印 metric log。该配置项于 1.8.x 版本引入

csp.sentinel.spi.classloader

SPI 加载时使用的 ClassLoader,默认为给定类的 ClassLoader

String

default

若配置 context 则使用 thread context ClassLoader。1.7.0 引入

csp.sentinel.log.dir

Sentinel 日志文件目录

String

${user.home}/logs/csp/

1.3.0 引入

csp.sentinel.log.use.pid

日志文件名中是否加入进程号,用于单机部署多个应用的情况

boolean

false

1.3.0 引入

csp.sentinel.log.output.type

Record 日志输出的类型,file 代表输出至文件,console 代表输出至终端

String

file

1.6.2 引入

csp.sentinel.dashboard.server

控制台的地址,指定控制台后客户端会自动向该地址发送心跳包。地址格式为:hostIp:port

String

null

csp.sentinel.heartbeat.interval.ms

心跳包发送周期,单位毫秒

long

null

非必需,若不进行配置,则会从相应的HeartbeatSender 中提取默认值

csp.sentinel.api.port

本地启动 HTTP API Server 的端口号,默认为 8719,若端口冲突会自动向下探测可用的端口

int

8719

csp.sentinel.heartbeat.client.ip

指定心跳包中本机的 IP

String

sentinel.dashboard.auth.username

用于指定控制台的登录用户名为 sentinel

String

sentinel

sentinel.dashboard.auth.password

用于指定控制台的登录密码为 123456;如果省略这两个参数,默认用户和密码均为 sentinel

String

sentinel

server.servlet.session.timeout

用于指定 Spring Boot 服务端 session 的过期时间,如 7200 表示 7200 秒;60m 表示 60 分钟,默认为 30 分钟;

7200

spring-boot安装配置

安装依赖

代码语言:xml
AI代码解释
复制
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

docker

docker pull bladex/sentinel-dashboard

docker run --name sentinel -d -p 8858:8858 imageid

配置

spring.cloud.sentinel.transport.port: 8719 对应 csp.sentinel.api.port配置

spring.cloud.sentinel.dashboard: 127.0.0.1:8849 控制台地址,对应csp.sentinel.dashboard.server配置

代码语言:properties
AI代码解释
复制
spring.cloud.sentinel.datasource.ds2.nacos.server-addr=127.0.0.1:8848 
spring.cloud.sentinel.datasource.ds2.nacos.data-id=sentinel
spring.cloud.sentinel.datasource.ds2.nacos.group-id=DEFAULT_GROUP
spring.cloud.sentinel.datasource.ds2.nacos.data-type=json // json xml ,默认json
spring.cloud.sentinel.datasource.ds2.nacos.rule-type=degrade //flow,degrade,authority,system, param-flow, gw-flow, gw-api-group

// 配置内容可以如下
[

  {

    "resource": "/provider/hello/{name}",

    "controlBehavior": 0,

    "count": 1,

    "grade": 1,

    "limitApp": "default",

    "strategy": 0

  }

]

代码研究

SentinelAutoConfiguration

QA

启动后提示 Failed to fetch metric from <**>: socket timeout,且无法连接到sentinel的Dashboard

参考文档(待研究)

代码语言:java
AI代码解释
复制
public static void main(String[] args) {
    System.setProperty("csp.sentinel.dashboard.server","localhost:8849");
    System.setProperty("csp.sentinel.app.name","apptwo");
    ...
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Sentinel 流量控制 熔断降级 初探 原
    还记得之前写过一篇防雪崩利器:熔断器 Hystrix 的原理与使用https://my.oschina.net/u/3266761/blog/2654470,讲述了服务降级和熔断的控制,今天带来另一个流量控制与服务降级阿里开源框架sentinel。
chinotan
2019/04/03
4.2K0
Sentinel 流量控制 熔断降级 初探
                                                                            原
sentinel和本地配置规则文件
随着微服务的流行,服务和服务之间的稳定性变得越来越重要。 Sentinel 以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。
张云飞Vir
2022/10/28
1.3K0
Sentinel + Gateway 在网关统一流控
很久之前,姜同学写过一篇使用Hystrix对微服务进行保护,里面介绍了一些Hystrix是怎么对服务器的资源进行限流的,但是令人遗憾的是,Hystrix在github上的仓库已经停止维护了,但不可否认的是Hystrix就算是在今天依旧强大,它依然是微服务弹性架构的保障。强大归强大,一些不好用的缺点姜同学还是得拿出来说说。
姜同学
2022/12/08
1.4K0
Sentinel + Gateway 在网关统一流控
Sentinel-Dashboard持久化生产环境解决方案
Sentinel作为目前市面上常用的限流/降级/熔断平台,已经在诸多高并发项目上进行应用。通常来说一个微服务架构下的项目,流量控制、熔断降级等系统保护功能是必备的。由于现在公司都流行采用开源和商业化双线进行,Sentinel-DashBoard开源版本并不是一个生产环境拿来就能用的产品。
benym
2023/10/18
1.3K0
Sentinel-Dashboard持久化生产环境解决方案
超详细的Sentinel入门
Sentinel定位是分布式系统的流量防卫兵。目前互联网应用基本上都使用微服务,微服务的稳定性是一个很重要的问题,而限流、熔断降级是微服务保持稳定的一个重要的手段。
java技术爱好者
2021/04/21
5.1K0
超详细的Sentinel入门
SCA Sentinel 分布式系统的流量防卫兵
Spring Cloud 是一站式微服务解决方案。很多公司都在使用 Spring Cloud 组件。我们想要学习 Spring Cloud 微服务架构,就需要学习他们的组件。包含:注册中心、负载均衡、熔断处理、过程调用、网关服务、配置中心、消息总线、调用链路、数据监控等等。
程序员爱酸奶
2023/11/16
2300
SCA Sentinel 分布式系统的流量防卫兵
Spring Cloud Alibaba之服务容错组件 - Sentinel Dashboard控制台(十二)
上一篇文章我们已经对 Sentinel 有个简单的了解,接下来我们将讲解 Sentinel的具体使用。 Sentinel的使用分为两部分:
用户1212940
2022/04/13
9800
Spring Cloud Alibaba之服务容错组件 - Sentinel Dashboard控制台(十二)
重学SpringCloud系列八之分布式系统流量卫兵sentinel
随着微服务的流行,服务和服务之间的稳定性变得越来越重要。Sentinel 以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。
大忽悠爱学习
2022/05/10
7980
重学SpringCloud系列八之分布式系统流量卫兵sentinel
SpringCloud Alibaba 实战教程6-sentinel限流持久化配置nacos
resource:资源名称 limitApp:来源应用 grade:阀值类型,0-线程数,1-qps count:单机阀值 strategy:流控模式,0-直接,1-关联,2-链路 controlBehavior:流控效果,0-快速失败,1-warm up,2-排队等待 clusterMode:是否集群
gang_luo
2020/12/22
5370
SpringCloud Alibaba 实战教程6-sentinel限流持久化配置nacos
SpringCloud 实战|5.SpringCloud 整合Sentinel
在common-web子模块下添加sentinel相关依赖,使用nacos作为数据源,目的是为了能够让配置的规则能够持久化到nacos中。
AI码师
2022/09/19
3380
SpringCloud 实战|5.SpringCloud 整合Sentinel
Spring-Clould-Alibaba-sentinel控制台
启动服务访问 :http://localhost:8000/getGoodsWithID/1
JokerDJ
2023/11/27
2490
Spring-Clould-Alibaba-sentinel控制台
Sentinel规则持久化进Nacos
  一旦我们重启应用,sentinel规则将消失,生产环境需要将配置规则进行持久化
别团等shy哥发育
2023/02/25
3730
Sentinel规则持久化进Nacos
Sentinel规则持久化(7)
将限流配置规则持久化进Nacos保存,只要刷新8401某个rest地址,sentinel控制台 的流控规则就能看到,只要Nacos里面的配置不删除,针对8401上sentinel上的流控规则持续有效
一个风轻云淡
2022/11/13
2390
Sentinel规则持久化(7)
SpringCloud 实战|SpringCloud 整合Sentinel-轻轻松松实现限流
在common-web子模块下添加sentinel相关依赖,使用nacos作为数据源,目的是为了能够让配置的规则能够持久化到nacos中。
AI码师
2022/09/19
7811
SpringCloud 实战|SpringCloud 整合Sentinel-轻轻松松实现限流
Sentinel
随着微服务的流行,服务和服务之间的稳定性变得越来越重要。Sentinel 以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。
大忽悠爱学习
2021/12/07
1.2K0
Sentinel
Sentinel Gateway Nacos 网关限流三剑客
顾名思义,网关限流是通过网关层对我们的服务进行限流,达到保护后端服务的作用。在微服务架构的系统中,网关层可以屏蔽外部的请求直接对服务进行调用,网关层可以对内部服务进行隔离,保护的作用。
程序猿小亮
2021/04/01
8.9K0
Sentinel Gateway Nacos 网关限流三剑客
Sentinel整合Apollo进行规则持久化(二)
apollo-configservice:提供配置获取接口,提供配置更新推送接口,接口服务对象为Apollo客户端
BUG弄潮儿
2020/08/10
1.5K0
Sentinel 实现熔断与限流
随着微服务的流行,服务和服务之间的稳定性变得越来越重要。Sentinel 以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。
用户9615083
2022/12/25
1.5K0
Sentinel 实现熔断与限流
SpringCloudAlibaba之Sentinel
随着微服务的流行,服务和服务之间的稳定性变得越来越重要。Sentinel 以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。
shaoshaossm
2022/12/27
5540
SpringCloudAlibaba之Sentinel
sentinel规则持久化至nacos
一旦我们重启应用,Sentinel规则将消失,生产环境需要将配置规则进行持久化 1.pom <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <dependency> <groupId>com.alibaba.csp</groupId> <artifac
DencyCheng
2020/12/11
1.6K0
sentinel规则持久化至nacos
相关推荐
Sentinel 流量控制 熔断降级 初探 原
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档