Sentinel
Github
https://github.com/alibaba/Sentinel/wiki/%E4%BB%8B%E7%BB%8D
国内官网文档
quick-start
下载和安装
https://github.com/alibaba/Sentinel/releases
?官方提供的手册:https://spring-cloud-alibaba-group.github.io/github-pages/hoxton/en-us/index.html#_spring_cloud_alibaba_sentinel
Sentinel 分为两个部分
核心库(Java客户端)
不依赖任何框架/库,只需要Java运行时环境,同时对Dubbo/SpringCloud 等框架也有较好的支持。?
控制台(Dashboard)
基于 SpringBoot开发,打包后可以直接运行,不需要额外的Tomcat等应用容器。
启动步骤
- 前提:jdk1.8环境和8080端口不能被占用
- 启动命令:java -jar sentinel-dashboard-1.8.2.jar
- 访问地址:localhost:8080
- 输入默认账号密码:sentinel/sentinel
搭建Sentinel项目
导入sentinel依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- sentinel依赖 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
完整pom.xml
<parent>
<artifactId>demo</artifactId>
<groupId>com.springcloud</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.springcloud</groupId>
<artifactId>sentinel-8401</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sentinel-8401</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</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-sentinel</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
application.properties 配置
server.port=8401
spring.cloud.nacos.discovery.server-addr=localhost:8848
spring.application.name=sentinel8401
management.endpoints.web.exposure.include=*
# sentinel dashboard 地址
spring.cloud.sentinel.transport.dashboard=localhost:8080
# 默认是8179端口。被占用会自动8719+1,直到找到为被占用的端口
spring.cloud.sentinel.transport.port=8179
创建 DemoController ,并请求接口。
查看 Sentinel 控制台
?
|