简单通过Sentinel监控请求

一:运行Sentinel服务

java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8879 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar > log.file  2>&1 &
[root@localhost sentinal]# pwd
/usr/local/home/sentinal
[root@localhost sentinal]# ls
log.file  sentinel-dashboard-1.8.6.jar
[root@localhost sentinal]# pwd
/usr/local/home/sentinal
[root@localhost sentinal]# ps -ef | grep "java"
root      3178  1750  1 01:55 pts/0    00:00:09 java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8887 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar
root      3284  1750 15 02:07 pts/0    00:00:05 java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8887 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar
root      3312  1750  0 02:08 pts/0    00:00:00 grep --color=auto java
[root@localhost sentinal]# kill 3178
[root@localhost sentinal]# kill 3178
-bash: kill: (3178) - 没有那个进程
[1]-  退出 143              java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8887 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar > log.file 2>&1
[root@localhost sentinal]# java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8879 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar > log.file  2>&1 &
[3] 3335

二:安装Sentinel依赖

2.1:Sentinel Pom依赖

在这里插入图片描述

  • 这里Sentinel依赖信息可以单独放在common模块作为一组件common-sentinel供其他服务引用该依赖
   <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
    </dependency>

2.2:Sentinel YML 配置

注意:clientIp.localhost不同sentinel版本依赖缩进层级结构可能不一样,可根据idea提示回车
server:
  port: 8092
spring:
  application:
    name: chain-order-server
  rabbitmq:
    host: 192..101
    port: 5672
    username: root
    password: 123456
  cloud:
    nacos:
      config:
        server-addr: 101..62:8848
        file-extension: yaml
      discovery:
        server-addr: 101..62:8848
    sentinel:
      transport:
        dashboard: 192..104:8879 # sentinel dashboard地址
        port: 8879
        clientIp:
          localhost: 8092 # 该订单服务默认ip localhost和订单服务端口
      eager: true



management:
  endpoint:
    web:
      exposure:
        include: '*'

三:启动服务,测试请求,Sentinel监控

3.1:该业务服务ip默认本地,和端口,sentinel会进行拦截

clientIp:
localhost: 8092

3.2:postman发送请求

http://localhost:8092/syncOrder

3.3:查看Sentinel客户端

客户端地址
http://192…104:8879/#/dashboard
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值