springcloud集成sentinel

sentinel

Sentinel 以流量为切入点,从流量控制、熔断降级、系统负载保护等多个维度保护服务的稳定性。

github sentinel
选择对应版本
image.png
sentinel1.8.0点我下载
这边推荐sentinel版本为1.8.0 或者1.8.1(高本版不适配),我这边使用的sipingcloud原生组件集成sentinel,没有用到阿里nacos集成那一套,网关是gateway,注册中心是eureka,配置中心是config
项目结构

网关层集成

确保服务都注册到注册中心了
image.png
pom.xml文件

<!-- 限流、熔断框架 不连通客户端本地可用 -->
<dependency>
  <groupId>com.alibaba.csp</groupId>
  <artifactId>sentinel-core</artifactId>
  <version>1.8.2</version>
</dependency>
<dependency>
  <groupId>com.alibaba.csp</groupId>
  <artifactId>sentinel-annotation-aspectj</artifactId>
  <version>1.8.2</version>
</dependency>

<!--sentinel启动器-->
<dependency>
  <groupId>com.alibaba.cloud</groupId>
  <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
  <version>2.0.0.RELEASE</version>
</dependency>

<!-- sentinel客户端与dashboard通信依赖 -->
<dependency>
  <groupId>com.alibaba.csp</groupId>
  <artifactId>sentinel-transport-simple-http</artifactId>
  <version>1.8.2</version>
</dependency>

application.yml yaml文件

spring:
	cloud:
		sentinel:
			transport:
				client-ip: localhost
				dashboard: localhost:8888 #控制台地址
				port: 8733
			eager: true

启动sentinel dashbord

sentinel-dashboard-1.8.0.jar 是标准的Spring Boot应用,通过java -jar sentinel-dashboard-1.8.0.jar 启动。

默认端口是8080,账号密码是:sentinel/sentinel

通过修改启动脚本修改 端口/账号/密码

java -jar -Dserver.port=8888 -Dsentinel.dashboard.auth.username=sentinel -Dsentinel.dashboard.auth.password=123456 sentinel-dashboard-1.8.0.jar 

官方文档

访问页面

通过本地ip+端口,根据自己的启动方式输入对应账号密码登录就可以,随便点击自己服务的一个接口,一定要走网关服务暴露出去的才能监控到,如果只是单体服务的话,在单体服务里面集成就可以了。
image.png

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值