文章目录
- 一:运行Sentinel服务
- 二:安装Sentinel依赖
- 2.1:Sentinel Pom依赖
- 2.2:Sentinel YML 配置
- 注意:clientIp.localhost不同sentinel版本依赖缩进层级结构可能不一样,可根据idea提示回车
- 三:启动服务,测试请求,Sentinel监控
- 3.1:该业务服务ip默认本地,和端口,sentinel会进行拦截
- 3.2:postman发送请求
- 3.3:查看Sentinel客户端
一:运行Sentinel服务
java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8879 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar > log.file 2>&1 &
[root@localhost sentinal]# pwd
/usr/local/home/sentinal
[root@localhost sentinal]# ls
log.file sentinel-dashboard-1.8.6.jar
[root@localhost sentinal]# pwd
/usr/local/home/sentinal
[root@localhost sentinal]# ps -ef | grep "java"
root 3178 1750 1 01:55 pts/0 00:00:09 java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8887 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar
root 3284 1750 15 02:07 pts/0 00:00:05 java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8887 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar
root 3312 1750 0 02:08 pts/0 00:00:00 grep --color=auto java
[root@localhost sentinal]# kill 3178
[root@localhost sentinal]# kill 3178
-bash: kill: (3178) - 没有那个进程
[1]- 退出 143 java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8887 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar > log.file 2>&1
[root@localhost sentinal]# java -Dserver.port=8879 -Dcsp.sentinel.dashboard.server=localhost:8879 -Dproject.name=sentinel-dashboard -Dsentinel.dashboard.auth.username=admin -Dsentinel.dashboard.auth.password=admin -jar sentinel-dashboard-1.8.6.jar > log.file 2>&1 &
[3] 3335
二:安装Sentinel依赖
2.1:Sentinel Pom依赖
- 这里Sentinel依赖信息可以单独放在common模块作为一组件common-sentinel供其他服务引用该依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
2.2:Sentinel YML 配置
注意:clientIp.localhost不同sentinel版本依赖缩进层级结构可能不一样,可根据idea提示回车
server:
port: 8092
spring:
application:
name: chain-order-server
rabbitmq:
host: 192..101
port: 5672
username: root
password: 123456
cloud:
nacos:
config:
server-addr: 101..62:8848
file-extension: yaml
discovery:
server-addr: 101..62:8848
sentinel:
transport:
dashboard: 192..104:8879 # sentinel dashboard地址
port: 8879
clientIp:
localhost: 8092 # 该订单服务默认ip localhost和订单服务端口
eager: true
management:
endpoint:
web:
exposure:
include: '*'
三:启动服务,测试请求,Sentinel监控
3.1:该业务服务ip默认本地,和端口,sentinel会进行拦截
clientIp:
localhost: 8092
3.2:postman发送请求
http://localhost:8092/syncOrder
3.3:查看Sentinel客户端
客户端地址
http://192…104:8879/#/dashboard