# 服务容错-Sentinel
- sentinel是什么
- 整合sentinel
# 导航
# sentinel是什么
sentinel是一个轻量级的流量控制、熔断降级Java库 github-sentinel (opens new window)
# 整合sentinel(为内容中心加sentinel)
# 步骤1 加依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
actuator暴露配置
management:
endpoint:
endpoints:
web:
exposure:
include: '*'
1
2
3
4
5
6
2
3
4
5
6
不需要加注解和配置
如何证明项目整合了sentinel?
项目整合了sentinel,会暴露出一个接口:/actuator/sentinel
启动项目后,直接访问:
http://localhost:8010/actuator/sentinel
1
{
"blockPage": null,
"appName": "centent-center",
"consoleServer": [],
"coldFactor": "3",
"rules": {
"systemRules": [],
"authorityRule": [],
"paramFlowRule": [],
"flowRules": [],
"degradeRules": []
},
"metricsFileCharset": "UTF-8",
"filter": {
"order": -2147483648,
"urlPatterns": ["/**"],
"enabled": true
},
"totalMetricsFileCount": 6,
"datasource": {},
"clientIp": "192.168.5.71",
"clientPort": "8719",
"logUsePid": false,
"metricsFileSize": 52428800,
"logDir": "C:\\Users\\Torey\\logs\\csp\\",
"heartbeatIntervalMs": null
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 8-4 Sentinel控制台
- 搭建sentinel控制台
- 整合应用 和 控制台
# 搭建Sentinel控制台
查看应该下载那个版本
从这里下载对应版本的sentinel控制台 (opens new window)
# 整合内容中心和控制台
在yml里配置
spring:
cloud:
sentinel:
transport:
# 指定sentinel控制台地址
dashboard: localhost:8080
1
2
3
4
5
6
2
3
4
5
6
重启内容中心后,需要访问某个接口,才能看到控制台的内容(由此可知:sentinel是懒加载的,ribbon也是懒加载的)