1. 安装 sentinel
2. 引入依赖
修改pom.xml
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
3. 修改配置
/order/src/main/resources/application.yml
spring:
cloud:
sentinel:
transport:
port: 9999
dashboard: 192.168.88.151:8858
重点:
- port: 9999
表示的是sentinel 回调该服务的端口,
通过该端口sentinel 感知当前服务的请求上下文和状态 - dashboar: 192.168.88.151:8858
表示的是sentinel 服务端所在的ip和端口
4. 重启服务
5. 访问服务
访问该服务已有的controller 入口,如下:
访问:http://127.0.0.1:8001/order3/message
6. 查看sentinel
访问:http://192.168.88.151:8858/#/dashboard/identity/service-order
相关阅读:
1. sentinel 如何持久化到nacos ?
2. sentinel 持久化nacos 并支持双向更新?