Sentinel官网下载地址
https://github.com/alibaba/Sentinel/releases
版本一致性:
Spring Cloud Alibaba Version:2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE
Sentinel Version:1.8.0
Nacos Version:1.4.1
RocketMQ Version:4.4.0
Dubbo Version:2.7.8
Seata Version:1.3.0
Spring Cloud Alibaba Version:2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE
Sentinel Version:1.7.1
Nacos Version:1.2.1
RocketMQ Version:4.4.0
Dubbo Version:2.7.6
Seata Version:1.2.0
官方版本说明:
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E
Spring Cloud Alibaba Sentinel官网文档:
https://github.com/alibaba/spring-cloud-alibaba/wiki/Sentinel
Sentinel 控制台官网文档:
https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0
Sentinel dashboard控制台运行启动
注意:启动 Sentinel 控制台需要 JDK 版本为 1.8 及以上版本。
Sentinel默认启动端口是8080,和Tomcat默认的端口冲突,如果需要修改Sentinel默认启动端口,使用参数:-Dserver.port=8849
Sentinel 启动命令格式:
java -jar sentinel-dashboard.jar
java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
示例:
java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
启动后:
INFO: Sentinel log output type is: file
INFO: Sentinel log charset is: utf-8
INFO: Sentinel log base directory is: C:\Users\用户名\logs\csp\
INFO: Sentinel log name use pid is: false
Tomcat started on port(s): 8700 (http) with context path ''
Sentinel Linux后台启动:
nohup java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -jar /java/sentinel-dashboard-1.8.1.jar &
Sentinel 指定日志目录启动:
java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -Dcsp.sentinel.log.dir=C:\logs\sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
启动后:
INFO: Sentinel log output type is: file
INFO: Sentinel log charset is: utf-8
INFO: Sentinel log base directory is: C:\logs\sentinel-dashboard\
INFO: Sentinel log name use pid is: false
启动(是否注册Sentinel自己):
不注册Sentinel自己
java -Dserver.port=8849 -Dcsp.sentinel.log.dir=C:\logs\sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
注册Sentinel自己
java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -Dcsp.sentinel.log.dir=C:\logs\sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
访问地址:
http://localhost:8849/
用户名:sentinel
密码:sentinel
从 Sentinel 1.6.0 起,Sentinel 控制台引入基本的登录功能,默认用户名和密码都是:sentinel
Sentinel dashboard控制台启动配置项
-Dserver.port=8080:用于指定 Sentinel 控制台端口为 8080,如若8080端口冲突,可使用 -Dserver.port=新端口 进行设置。。
-Dcsp.sentinel.dashboard.server=localhost:8080:指定控制台地址和端口,会自动向该地址发送心跳包。地址格式为:hostIp:port,l配置成ocalhost:8080即监控自己
-Dproject.name=sentinel-dashboard:指定Sentinel控制台程序显示的名称
-Dcsp.sentinel.log.dir:指定Sentinel 日志文件目录,默认是:${user.home}/logs/csp/
-Dcsp.sentinel.api.port=xxxx:本地的 Sentinel 客户端端口(可选,默认是 8719,有冲突会尝试向后探测)。若启动多个应用,则需要通过 -Dcsp.sentinel.api.port=xxxx 指定客户端监控 API 的端口(默认是 8719)。
-Dcsp.sentinel.app.type=1:从 1.6.3 版本开始,控制台支持网关流控规则管理。启动参数以将您的服务标记为 API Gateway,在接入控制台时您的服务会自动注册为网关类型,然后您即可在控制台配置网关规则和 API 分组。
用户可以通过如下参数进行鉴权配置:
-Dsentinel.dashboard.auth.username=sentinel 用于指定控制台的登录用户名为 sentinel;
-Dsentinel.dashboard.auth.password=123456 用于指定控制台的登录密码为 123456;如果省略这两个参数,默认用户和密码均为 sentinel;
-Dserver.servlet.session.timeout=7200 用于指定 Spring Boot 服务端 session 的过期时间,如 7200 表示 7200 秒;60m 表示 60 分钟,默认为 30 分钟;
同样也可以直接在 Spring properties 文件中进行配置。
注意:部署多台控制台时,session 默认不会在各实例之间共享,这一块需要自行改造。
配置方式
Sentinel 提供如下的配置方式:
JVM -D 参数方式
properties 文件方式(1.7.0 版本开始支持)
其中,project.name 参数只能通过 JVM -D 参数方式配置(since 1.8.0 取消该限制),其它参数支持所有的配置方式。
优先级顺序:JVM -D 参数的优先级最高。若 properties 和 JVM 参数中有相同项的配置,以 JVM 参数配置的为准。
用户可以通过 -Dcsp.sentinel.config.file 参数配置 properties 文件的路径,支持 classpath 路径配置(如 classpath:sentinel.properties)。
默认 Sentinel 会尝试从 classpath:sentinel.properties 文件读取配置,读取编码默认为 UTF-8。
| 配置项 |
类型 |
默认值 |
最小值 |
描述 |
| auth.enabled |
boolean |
true |
- |
是否开启登录鉴权,仅用于日常测试,生产上不建议关闭 |
| sentinel.dashboard.auth.username |
String |
sentinel |
- |
登录控制台的用户名,默认为 sentinel |
| sentinel.dashboard.auth.password |
String |
sentinel |
- |
登录控制台的密码,默认为 sentinel |
| sentinel.dashboard.app.hideAppNoMachineMillis |
Integer |
0 |
60000 |
是否隐藏无健康节点的应用,距离最近一次主机心跳时间的毫秒数,默认关闭 |
| sentinel.dashboard.removeAppNoMachineMillis |
Integer |
0 |
120000 |
是否自动删除无健康节点的应用,距离最近一次其下节点的心跳时间毫秒数,默认关闭 |
| sentinel.dashboard.unhealthyMachineMillis |
Integer |
60000 |
30000 |
主机失联判定,不可关闭 |
| sentinel.dashboard.autoRemoveMachineMillis |
Integer |
0 |
300000 |
距离最近心跳时间超过指定时间是否自动删除失联节点,默认关闭 |
| sentinel.dashboard.unhealthyMachineMillis |
Integer |
60000 |
30000 |
主机失联判定,不可关闭 |
| server.servlet.session.cookie.name |
String |
sentinel_dashboard_cookie |
- |
控制台应用的 cookie 名称,可单独设置避免同一域名下 cookie 名冲突 |
更多配置项见:
https://github.com/alibaba/Sentinel/wiki/%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE%E9%A1%B9
注:若通过控制台推送规则时出现 invalid type 或 empty type 的错误,请确保 transport 模块版本与 core 模块版本保持一致;若控制台版本 >= 1.7.1,请将接入端的相关依赖也升级至 1.7.1 及以上版本。
<h2><a id="Sentinel_0"></a>Sentinel官网下载地址</h2>
<p><a href="https://github.com/alibaba/Sentinel/releases" target="_blank">https://github.com/alibaba/Sentinel/releases</a></p>
<p>版本一致性:</p>
<p>Spring Cloud Alibaba Version:2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE</p>
<p>Sentinel Version:1.8.0</p>
<p>Nacos Version:1.4.1</p>
<p>RocketMQ Version:4.4.0</p>
<p>Dubbo Version:2.7.8</p>
<p>Seata Version:1.3.0</p>
<p>Spring Cloud Alibaba Version:2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE</p>
<p>Sentinel Version:1.7.1</p>
<p>Nacos Version:1.2.1</p>
<p>RocketMQ Version:4.4.0</p>
<p>Dubbo Version:2.7.6</p>
<p>Seata Version:1.2.0</p>
<p>官方版本说明:</p>
<p>https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E</p>
<p>Spring Cloud Alibaba Sentinel官网文档:</p>
<p>https://github.com/alibaba/spring-cloud-alibaba/wiki/Sentinel</p>
<p>Sentinel 控制台官网文档:</p>
<p>https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0</p>
<h2><a id="Sentinel_dashboard_46"></a>Sentinel dashboard控制台运行启动</h2>
<blockquote>
<p>注意:启动 Sentinel 控制台需要 JDK 版本为 1.8 及以上版本。</p>
</blockquote>
<p>Sentinel默认启动端口是8080,和Tomcat默认的端口冲突,如果需要修改Sentinel默认启动端口,使用参数:-Dserver.port=8849</p>
<p>Sentinel 启动命令格式:</p>
<pre><code class="lang-">java -jar sentinel-dashboard.jar
java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
</code></pre>
<p>示例:</p>
<pre><code class="lang-">java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
启动后:
INFO: Sentinel log output type is: file
INFO: Sentinel log charset is: utf-8
INFO: Sentinel log base directory is: C:\Users\用户名\logs\csp\
INFO: Sentinel log name use pid is: false
Tomcat started on port(s): 8700 (http) with context path ''
</code></pre>
<p>Sentinel Linux后台启动:</p>
<pre><code class="lang-">nohup java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -jar /java/sentinel-dashboard-1.8.1.jar &
</code></pre>
<p>Sentinel 指定日志目录启动:</p>
<pre><code class="lang-">java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -Dcsp.sentinel.log.dir=C:\logs\sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
启动后:
INFO: Sentinel log output type is: file
INFO: Sentinel log charset is: utf-8
INFO: Sentinel log base directory is: C:\logs\sentinel-dashboard\
INFO: Sentinel log name use pid is: false
</code></pre>
<p>启动(是否注册Sentinel自己):</p>
<p>不注册Sentinel自己</p>
<pre><code class="lang-">java -Dserver.port=8849 -Dcsp.sentinel.log.dir=C:\logs\sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
</code></pre>
<p>注册Sentinel自己</p>
<pre><code class="lang-">java -Dserver.port=8849 -Dcsp.sentinel.dashboard.server=localhost:8849 -Dproject.name=sentinel-dashboard -Dcsp.sentinel.log.dir=C:\logs\sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar
</code></pre>
<p>访问地址:</p>
<p><a href="http://localhost:8849/" target="_blank">http://localhost:8849/</a></p>
<p>用户名:sentinel</p>
<p>密码:sentinel</p>
<p>从 Sentinel 1.6.0 起,Sentinel 控制台引入基本的登录功能,默认用户名和密码都是:sentinel</p>
<h2><a id="Sentinel_dashboard_114"></a>Sentinel dashboard控制台启动配置项</h2>
<pre><code class="lang-">-Dserver.port=8080:用于指定 Sentinel 控制台端口为 8080,如若8080端口冲突,可使用 -Dserver.port=新端口 进行设置。。
-Dcsp.sentinel.dashboard.server=localhost:8080:指定控制台地址和端口,会自动向该地址发送心跳包。地址格式为:hostIp:port,l配置成ocalhost:8080即监控自己
-Dproject.name=sentinel-dashboard:指定Sentinel控制台程序显示的名称
-Dcsp.sentinel.log.dir:指定Sentinel 日志文件目录,默认是:${user.home}/logs/csp/
-Dcsp.sentinel.api.port=xxxx:本地的 Sentinel 客户端端口(可选,默认是 8719,有冲突会尝试向后探测)。若启动多个应用,则需要通过 -Dcsp.sentinel.api.port=xxxx 指定客户端监控 API 的端口(默认是 8719)。
-Dcsp.sentinel.app.type=1:从 1.6.3 版本开始,控制台支持网关流控规则管理。启动参数以将您的服务标记为 API Gateway,在接入控制台时您的服务会自动注册为网关类型,然后您即可在控制台配置网关规则和 API 分组。
用户可以通过如下参数进行鉴权配置:
-Dsentinel.dashboard.auth.username=sentinel 用于指定控制台的登录用户名为 sentinel;
-Dsentinel.dashboard.auth.password=123456 用于指定控制台的登录密码为 123456;如果省略这两个参数,默认用户和密码均为 sentinel;
-Dserver.servlet.session.timeout=7200 用于指定 Spring Boot 服务端 session 的过期时间,如 7200 表示 7200 秒;60m 表示 60 分钟,默认为 30 分钟;
</code></pre>
<p>同样也可以直接在 Spring properties 文件中进行配置。</p>
<blockquote>
<p>注意:部署多台控制台时,session 默认不会在各实例之间共享,这一块需要自行改造。</p>
</blockquote>
<p>配置方式</p>
<p>Sentinel 提供如下的配置方式:</p>
<p>JVM -D 参数方式</p>
<p>properties 文件方式(1.7.0 版本开始支持)</p>
<p>其中,project.name 参数只能通过 JVM -D 参数方式配置(since 1.8.0 取消该限制),其它参数支持所有的配置方式。<br />
优先级顺序:JVM -D 参数的优先级最高。若 properties 和 JVM 参数中有相同项的配置,以 JVM 参数配置的为准。<br />
用户可以通过 -Dcsp.sentinel.config.file 参数配置 properties 文件的路径,支持 classpath 路径配置(如 classpath:sentinel.properties)。</p>
<p>默认 Sentinel 会尝试从 classpath:sentinel.properties 文件读取配置,读取编码默认为 UTF-8。</p>
<table>
<thead>
<tr>
<th>配置项</th>
<th>类型</th>
<th>默认值</th>
<th>最小值</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>auth.enabled</td>
<td>boolean</td>
<td>true</td>
<td>-</td>
<td>是否开启登录鉴权,仅用于日常测试,生产上不建议关闭</td>
</tr>
<tr>
<td>sentinel.dashboard.auth.username</td>
<td>String</td>
<td>sentinel</td>
<td>-</td>
<td>登录控制台的用户名,默认为 sentinel</td>
</tr>
<tr>
<td>sentinel.dashboard.auth.password</td>
<td>String</td>
<td>sentinel</td>
<td>-</td>
<td>登录控制台的密码,默认为 sentinel</td>
</tr>
<tr>
<td>sentinel.dashboard.app.hideAppNoMachineMillis</td>
<td>Integer</td>
<td>0</td>
<td>60000</td>
<td>是否隐藏无健康节点的应用,距离最近一次主机心跳时间的毫秒数,默认关闭</td>
</tr>
<tr>
<td>sentinel.dashboard.removeAppNoMachineMillis</td>
<td>Integer</td>
<td>0</td>
<td>120000</td>
<td>是否自动删除无健康节点的应用,距离最近一次其下节点的心跳时间毫秒数,默认关闭</td>
</tr>
<tr>
<td>sentinel.dashboard.unhealthyMachineMillis</td>
<td>Integer</td>
<td>60000</td>
<td>30000</td>
<td>主机失联判定,不可关闭</td>
</tr>
<tr>
<td>sentinel.dashboard.autoRemoveMachineMillis</td>
<td>Integer</td>
<td>0</td>
<td>300000</td>
<td>距离最近心跳时间超过指定时间是否自动删除失联节点,默认关闭</td>
</tr>
<tr>
<td>sentinel.dashboard.unhealthyMachineMillis</td>
<td>Integer</td>
<td>60000</td>
<td>30000</td>
<td>主机失联判定,不可关闭</td>
</tr>
<tr>
<td>server.servlet.session.cookie.name</td>
<td>String</td>
<td>sentinel_dashboard_cookie</td>
<td>-</td>
<td>控制台应用的 cookie 名称,可单独设置避免同一域名下 cookie 名冲突</td>
</tr>
</tbody>
</table>
<p>更多配置项见:</p>
<pre><code class="lang-">https://github.com/alibaba/Sentinel/wiki/%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE%E9%A1%B9
</code></pre>
<blockquote>
<p>注:若通过控制台推送规则时出现 invalid type 或 empty type 的错误,请确保 transport 模块版本与 core 模块版本保持一致;若控制台版本 >= 1.7.1,请将接入端的相关依赖也升级至 1.7.1 及以上版本。</p>
</blockquote>