偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Sentinel安裝和項(xiàng)目整合Sentinel

開(kāi)發(fā) 項(xiàng)目管理
相對(duì)于于前面Nacos的下載、shell指令的啟動(dòng),Sentinel為開(kāi)發(fā)者提供開(kāi)箱即用的jar包,小伙伴可以從 release頁(yè)面 下載不同版本的控制臺(tái) jar 包。

今日目標(biāo)

  • 安裝Sentinel
  • 項(xiàng)目整合Sentinel

昨天我們已經(jīng)介紹了Sentinel的原理,今天來(lái)了解一下Sentinel快速入門

1. Sentinel介紹和安裝

1.1.初識(shí)Sentinel

Sentinel是阿里巴巴開(kāi)源的一款微服務(wù)流量控制組件。官網(wǎng)地址:https://sentinelguard.io/zh-cn/index.html

Sentinel 具有以下特征:

?豐富的應(yīng)用場(chǎng)景:Sentinel 承接了阿里巴巴近 10 年的雙十一大促流量的核心場(chǎng)景,例如秒殺(即突發(fā)流量控制在系統(tǒng)容量可以承受的范圍)、消息削峰填谷、集群流量控制、實(shí)時(shí)熔斷下游不可用應(yīng)用等。

?完備的實(shí)時(shí)監(jiān)控:Sentinel 同時(shí)提供實(shí)時(shí)的監(jiān)控功能。您可以在控制臺(tái)中看到接入應(yīng)用的單臺(tái)機(jī)器秒級(jí)數(shù)據(jù),甚至 500 臺(tái)以下規(guī)模的集群的匯總運(yùn)行情況。

?廣泛的開(kāi)源生態(tài):Sentinel 提供開(kāi)箱即用的與其它開(kāi)源框架/庫(kù)的整合模塊,例如與 Spring Cloud、Dubbo、gRPC 的整合。您只需要引入相應(yīng)的依賴并進(jìn)行簡(jiǎn)單的配置即可快速地接入 Sentinel。

?完善的 SPI 擴(kuò)展點(diǎn):Sentinel 提供簡(jiǎn)單易用、完善的 SPI 擴(kuò)展接口。您可以通過(guò)實(shí)現(xiàn)擴(kuò)展接口來(lái)快速地定制邏輯。例如定制規(guī)則管理、適配動(dòng)態(tài)數(shù)據(jù)源等。

1.2. Sentinel安裝

相對(duì)于于前面Nacos的下載、shell指令的啟動(dòng),Sentinel為開(kāi)發(fā)者提供開(kāi)箱即用的jar包,小伙伴可以從  release頁(yè)面 下載不同版本的控制臺(tái) jar 包。我使用的是sentinel-dashboard-1.8.6.jar

圖片圖片

1.2.1.Sentinel運(yùn)行

將jar包放到任意非中文目錄,執(zhí)行命令:

java -Dserver.port=8080 -jar sentinel-dashboard-1.8.6.jar

圖片圖片

如果要修改Sentinel的默認(rèn)端口、賬戶、密碼,可以通過(guò)下列配置:

配置項(xiàng)

默認(rèn)值

說(shuō)明

server.port

8080

服務(wù)端口

sentinel.dashboard.auth.username

sentinel

默認(rèn)用戶名

sentinel.dashboard.auth.password

sentinel

默認(rèn)密碼

例如,修改端口:

java -Dserver.port=8888 -jar sentinel-dashboard-1.8.6.jar

如果您覺(jué)得本文不錯(cuò),歡迎關(guān)注,點(diǎn)贊,收藏支持,您的關(guān)注是我堅(jiān)持的動(dòng)力!

1.2.2.Sentinel訪問(wèn)

訪問(wèn)http://localhost:8080頁(yè)面,可以訪問(wèn)sentinel的控制臺(tái)了:

圖片圖片

需要輸入賬號(hào)和密碼,默認(rèn)都是:sentinel

登錄后,發(fā)現(xiàn)一片空白,什么都沒(méi)有:

圖片圖片

這是因?yàn)槲覀冞€沒(méi)有與微服務(wù)整合

3. 微服務(wù)整合Sentinel

Sentinel項(xiàng)目實(shí)際上和前面介紹的Seata項(xiàng)目是項(xiàng)目的,不過(guò)我這里是將項(xiàng)目名稱進(jìn)行修改

【步驟一】:環(huán)境導(dǎo)入微服務(wù)

獲取代碼地址:

https://github.com/bangbangzhou/learn_springboot/tree/main/sentinel-study

圖片圖片

sentinel-study:父工程,負(fù)責(zé)管理項(xiàng)目依賴

  • sentinel-account-service:賬戶服務(wù),用于用戶的資金管理。提供扣減余額的接口
  • sentinel-order-service:庫(kù)存服務(wù),用于管理商品庫(kù)存。提供扣減庫(kù)存的接口,創(chuàng)建訂單時(shí),需要調(diào)用sentinel-account-service和sentinel-storage-service
  • sentinel-storage-service:訂單服務(wù),用于管理訂單。

【步驟二】:引入Sentinel依賴

在sentinel-order-service服務(wù)中新增sentinel的pom依賴,如下:

<!--流控降級(jí)管理-->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

【步驟三】:配置控制臺(tái)Sentinel

在sentinel-order-service服務(wù)中修改application.yaml文件,添加下面內(nèi)容:

spring:
  cloud: 
    sentinel:
      transport:
        dashboard: localhost:8080

【步驟四】:啟動(dòng)項(xiàng)目

啟動(dòng)order、Account和Storage三個(gè)微服務(wù)

圖片圖片

【步驟五】:訪問(wèn)order-service的任意端點(diǎn)

打開(kāi)POSTMAN,

  • 請(qǐng)求方式:POST
  • 訪問(wèn)地址:http://localhost:9092/order?userId=user20230929&commodityCode=100202003032041&count=3&mnotallow=30

圖片圖片

  • 這樣才能觸發(fā)sentinel的監(jiān)控。

然后再訪問(wèn)sentinel的控制臺(tái),查看效果:

圖片圖片

責(zé)任編輯:武曉燕 來(lái)源: springboot葵花寶
相關(guān)推薦

2022-05-03 19:38:15

限流微服務(wù)Sentinel

2021-11-04 10:11:02

Sentinel網(wǎng)關(guān)限流

2025-03-06 08:37:01

2020-07-13 09:09:23

Sentinel源碼Bucket

2021-05-07 08:02:53

Sentinel 流量服務(wù)

2025-01-06 13:00:00

RedisSentinel高可用模式

2023-11-21 17:36:04

OpenFeignSentinel

2023-09-25 15:34:14

2023-10-08 12:14:42

Sentinel流量控制

2022-05-29 21:38:11

限流熔斷流量

2021-05-17 07:50:06

流控規(guī)則Sentinel

2021-05-14 07:45:07

Sentinel 接口限流

2022-05-16 13:46:38

Redis高可用Sentinel

2022-05-09 07:35:48

動(dòng)態(tài)集群限流

2021-05-21 08:30:26

Sentinel GateWay 微服務(wù)

2025-03-06 10:59:24

2021-05-20 08:01:15

Nacos 存儲(chǔ)Sentinel

2024-09-06 13:53:28

2024-11-05 15:02:41

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)