一,下载启动控制台
1.1 获取sentinel 控制台
您可以从官方
网站中
下载最新版本的控制台
jar
包,下载地址如下:
https://github.com/alibaba/Sentinel/releases/download/1.6.3/sentinel-dashboard-1.6.3.jar
1.2 启动
使用如下命令在该包文件下执行 win dos 启动控制台:
java -Dserver.port=8081 -Dcsp.sentinel.dashboard.server=127.0.0.1:8081 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.6.3.jar
我在运行这段代码时报了一个错:
Unrecognized option: -
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
原因是我上面的启动代码写错了。
其中
-
Dserver.port=8080
用于指定
Sentinel
控制台端口为
8080
从
Sentinel 1.6.0
起,
Sentinel
控制台引入基本的
登录
功能,默认用户名和密码都是
sentinel 。可以参考
鉴权模块文档
配置用户名和密码。
启动 Sentinel 控制台需要 JDK 版本为 1.8 及以上版本。
二,客户端能接入控制台
将各个服务消费者通过配置的方式加上sentinel 依赖和注解,然后在sentinel 可视化页面上看到
2.1 引入依赖
父工程引入
alibaba
实现的
SpringCloud
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.1.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
子工程中引入
sentinel
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
2.2 配置启动参数
在需要监听的工程的application.yml中添加Sentinel 控制台配置信息
spring:
cloud:
sentinel:
transport:
dashboard: localhost:8080
配置好后,因为sentinel 的懒加载原因,需要请求一个接口,才能在sentinel 可视化页面上看到所监听的服务。也可以配置 sentinel.eager=true ,取消Sentinel控制台懒加载
2.3 打开浏览器查看