Sentinel搭建控制面板不显示项目

今天搭建sentinel控制面板项目时而显示 时而不显示。抓狂!
分享一下搭建心得及注意事项:

1.Sentinel控制台的安装启动

  1. 下载 https://github.com/alibaba/Sentinel/releases
    下载jar包
  2. 启动
java -jar sentinel-dashboard-1.8.5.jar    #默认是8080端口
  1. 登录
http://localhost:8080/#/login  #账号密码都是sentinel

2.创建工程

  1. 创建工程
  2. 添加坐标依赖
  3. 创建yaml
  4. 创建启动类
  5. 创建Controller

3.讲解

  1. 创建工程
  2. 添加坐标依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>item-master</artifactId>
        <groupId>org.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>sentinel</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--注册中心-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <!--配置-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <!--sentinel-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>
    </dependencies>
</project>
  1. 创建application.yaml和bootstrap.yaml

application.yaml:

spring:
  application:
    name: sentinel-client1
  cloud:
    sentinel:
      transport:
        port: 8719
        dashboard: localhost:8080
server:
  port: 9001

bootstrap.yaml:

spring:
  application:
    name: service-client1
  cloud:
    nacos:
      config:
        server-addr: ${spring.cloud.nacos.server-addr}
      server-addr: localhost:8848
      discovery:
        server-addr: ${spring.cloud.nacos.server-addr}

4.创建启动类和controller

package com.it;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableDiscoveryClient
public class SentinelApplication {
    public static void main(String[] args) {
        SpringApplication.run(SentinelApplication.class, args);
    }

    @RestController
    public class TestController {

        @GetMapping(value = "/hello")
        public String hello() {
            System.out.println("Hello Sentinel");
            return "Hello Sentinel";
        }

    }

}

5.启动nacos服务端
6.测试请求

http://localhost:9001/hello

7.刷新控制面板

http://localhost:8080/#/dashboard/home

这样控制面板就能显示应用了。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
搭建Sentinel,你需要进行以下步骤: 1. 在控制台的application.properties配置文件中新增以下配置: ``` sentinel.nacos.server-addr=192.168.230.129:8848 sentinel.nacos.group-id=SENTINEL-GROUP sentinel.nacos.username=nacos sentinel.nacos.password=nacos ``` 这些配置用于连接Nacos Config Server,以获取Sentinel的配置信息。\[1\] 2. 使用命令`sentinel remove <master_name>`来让Sentinel放弃对某个master的监听。例如,使用命令`sentinel remove T2`可以移除对T2的监听。\[2\] 3. 使用命令`sentinel failover <master_name>`来强制Sentinel执行failover,即主从切换,并将最新的配置发送给其他Sentinel。例如,使用命令`sentinel failover T1`可以执行T1的主从切换。\[3\] 通过以上步骤,你可以成功搭建Sentinel并进行相关配置和操作。 #### 引用[.reference_title] - *1* [Sentinel搭建与使用](https://blog.csdn.net/qq_38730338/article/details/125376474)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Sentinel高可用集群搭建](https://blog.csdn.net/demored/article/details/123791776)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

橘右今

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值