四、安装使用Sentinel
1. 安装Sentinel
Sentinel官网
Sentinel文档
Sentinel控制台jar下载
- 从github下载最新的Sentinel控制台jar包。
- 运行Sentinel的jar包
cd到Sentinel控制台jar包所在目录,执行命令java -jar .\sentinel-dashboard-1.8.8.jar --server.port=8081 --csp.sentinel.dashboard.server=localhost:8081 --project.name=sentinel-dashboard
java -jar .\sentinel-dashboard-1.8.8.jar --server.port=8081 --csp.sentinel.dashboard.server=localhost:8081 --project.name=sentinel-dashboard
2.登录Sentinel后台
在浏览器输入http://localhost:8081/,进入Sentinel后台登录页面,如下图:

输入用户和密码,都是sentinel,进入管理后台主页,如下图:

3. 微服务整合Sentinel
3.1 引入sentinel依赖
在pom文件中加下如下代码:
<!-- sentinnel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
3.2 配置控制台地址
在application.yml文件中加下如下代码:
spring:
application:
name: order-service
cloud:
# sentinel 配置
sentinel:
transport:
dashboard: localhost:8081
3.3 访问微服务的任意端点,触发sentinel监控
本文访问的是接口http://localhost:8071/order,刷新sentinel控制台主页面,如下图:

4. 总结
- 启动sentinel控制台jar包
- 微服务中引入sentinel依赖
- 配置sentinel
- 触发sentinel监控
- sentinel实时监控

3511

被折叠的 条评论
为什么被折叠?



