Sentinel 初始化监控

编程入门 行业动态 更新时间:2024-10-08 05:24:08

Sentinel <a href=https://www.elefans.com/category/jswz/34/1770206.html style=初始化监控"/>

Sentinel 初始化监控

1.启动服务注册中心 Nacos8848

2.新建module cloudalibaba-sentinel-service8401

<!--pom.xml依赖-->
<dependencies><!--springcloud alibaba nacos--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!--springcloud alibaba sentinel-datasource-nacos 后续做持久化用到--><dependency><groupId>com.alibaba.csp</groupId><artifactId>sentinel-datasource-nacos</artifactId></dependency><!--springcloud alibaba sentinel--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>com.atguigu.springcloud</groupId><artifactId>cloud-api-commons</artifactId><version>${project.version}</version></dependency>
</dependencies>
#yml配置
server:port: 8401spring:application:name: cloudalibaba-sentinel-servicecloud:nacos:discovery:#Nacos服务注册中心地址server-addr: localhost:8848sentinel:transport:#配置sentinel dashboard地址dashboard: localhost:8080#默认8719端口,假如被占用会自动从8719开始依次+1扫描,直至找到未被占用的端口port: 8719management:endpoints:web:exposure:include: '*'
//主启动
package com.atguigu.springcloud.alibaba;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient
public class MainApp8401 {public static void main(String[] args) {SpringApplication.run(MainApp8401.class,args);}
}
//业务类controller
package com.atguigu.springcloud.alibaba.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class FlowLimitController {@GetMapping("/testA")public String testA(){return "--------testA";}@GetMapping("/testB")public String testB(){return "--------testB";}
}

3.启动sentinel8080
java -jar sentinel-dashboard-1.7.x.jar

4.启动8401微服务查看sentinel控制台
先执行一次请求

然后打开sentinel监控:

这样sentinel8080就在监控微服务8401了。

更多推荐

Sentinel 初始化监控

本文发布于:2024-02-19 17:08:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1765242.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:初始化   Sentinel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!