dubbo+sentinel最简集成实例

说明

在集成seata后,下面来集成sentinel进行服务链路追踪管理~

背景

sample-front网关服务已配置好

集成

一、启动sentinel.jar

1、官网下载

选择1:在本地启动
复制代码
nohup java -Dserver.port=8082 -Dcsp.sentinel.dashboard.server=localhost:8082 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar > sentinel.log 2>&1 &
选择2:在远程服务器启动
复制代码
nohup java -Dserver.port=8082 -Dcsp.sentinel.dashboard.server=YOUR_IP:8082 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar > sentinel.log 2>&1 &

二、客服端服务

1、pom依赖

复制代码
<!--sentinel -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>

2、yml配置

复制代码
spring:
  cloud:
    sentinel:
      eager: true
      transport:
        dashboard: localhost:8082

特别说明:如果是本地部署sentinel,是可以看到服务和调用记录的,但是原创部署的sentinel,会自动connect sentinel客户端,用的IP是本地IP,如果远程服务器不能访问到本地IP是不能监控链路的,eager参数用于不访问链接接口就看到服务,不加也可以

3、访问

随意多次访问开放的restfull接口

复制代码
http://localhost:IP/???

4、看到访问记录

三、总结

至此完成集成,一定要注意的是,sentinel server端会自动与客户端服务通信, 如果与获取的客户端服务IP通信不了,是看不到链路追踪的结果的,如果有公网IP可以增加配置

复制代码
spring:
  cloud:
    sentinel:
      eager: true
      transport:
        client-ip: 你的公网IP,sentinel服务能访问的IP
相关推荐
妄小闲3 小时前
百度竞价推广:搜索竞价信息流推广代运营
dubbo
Sam-August1 天前
【分布式架构实战】Spring Cloud 与 Dubbo 深度对比:从架构到实战,谁才是微服务的王者?
java·spring cloud·dubbo
syty20201 天前
K8s是什么
容器·kubernetes·dubbo
程序员小潘1 天前
Dubbo3序列化安全机制导致的一次生产故障
dubbo
LuiChun2 天前
docker desktop更新到【4.45.0 】后,旧容器镜像都丢失了
docker·容器·dubbo
T_Ghost2 天前
SpringCloud微服务服务容错机制Sentinel熔断器
spring cloud·微服务·sentinel
你是人间五月天3 天前
sentinel实现控制台与nacos数据双向绑定
windows·sentinel
无名客03 天前
sentinel限流常见的几种算法以及优缺点
算法·sentinel·限流
tsxchen3 天前
centos9安装sentinel
sentinel
寒士obj3 天前
Sentinel服务治理:服务降级、熔断与线程隔离
sentinel