10.19 每日总结(今日Sentinel)
今天学习服务保护框架Sentinel。
学习时长2小时
 
运行代码java -Dserver.port=8090 -Dcsp.sentinel.dashboard.server=localhost:8090 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
微服务整合
我们在`cart-service`模块中整合sentinel,连接`sentinel-dashboard`控制台,步骤如下: 1)引入sentinel依赖
<!--sentinel-->
<dependency>
    <groupId>com.alibaba.cloud</groupId> 
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
2)配置控制台
修改application.yaml文件,添加下面内容:
spring:
  cloud: 
    sentinel:
      transport:
        dashboard: localhost:8090
3)cart-service的任意端点
重启`cart-service`,然后访问查询购物车接口,sentinel的客户端就会将服务访问的信息提交到`sentinel-dashboard`控制台。并展示出统计信息:

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号