日韩成人免费在线_国产成人一二_精品国产免费人成电影在线观..._日本一区二区三区久久久久久久久不

當前位置:首頁 > 科技  > 軟件

Sentinel安裝和項目整合Sentinel

來源: 責編: 時間:2023-10-08 07:05:15 278觀看
導讀今日目標安裝Sentinel項目整合Sentinel昨天我們已經介紹了Sentinel的原理,今天來了解一下Sentinel快速入門1. Sentinel介紹和安裝1.1.初識SentinelSentinel是阿里巴巴開源的一款微服務流量控制組件。官網地址:https://s

今日目標

  • 安裝Sentinel
  • 項目整合Sentinel

昨天我們已經介紹了Sentinel的原理,今天來了解一下Sentinel快速入門Of828資訊網——每日最新資訊28at.com

1. Sentinel介紹和安裝

1.1.初識Sentinel

Sentinel是阿里巴巴開源的一款微服務流量控制組件。官網地址:https://sentinelguard.io/zh-cn/index.htmlOf828資訊網——每日最新資訊28at.com

Sentinel 具有以下特征:Of828資訊網——每日最新資訊28at.com

?豐富的應用場景:Sentinel 承接了阿里巴巴近 10 年的雙十一大促流量的核心場景,例如秒殺(即突發流量控制在系統容量可以承受的范圍)、消息削峰填谷、集群流量控制、實時熔斷下游不可用應用等。Of828資訊網——每日最新資訊28at.com

?完備的實時監控:Sentinel 同時提供實時的監控功能。您可以在控制臺中看到接入應用的單臺機器秒級數據,甚至 500 臺以下規模的集群的匯總運行情況。Of828資訊網——每日最新資訊28at.com

?廣泛的開源生態:Sentinel 提供開箱即用的與其它開源框架/庫的整合模塊,例如與 Spring Cloud、Dubbo、gRPC 的整合。您只需要引入相應的依賴并進行簡單的配置即可快速地接入 Sentinel。Of828資訊網——每日最新資訊28at.com

?完善的 SPI 擴展點:Sentinel 提供簡單易用、完善的 SPI 擴展接口。您可以通過實現擴展接口來快速地定制邏輯。例如定制規則管理、適配動態數據源等。Of828資訊網——每日最新資訊28at.com

1.2. Sentinel安裝

相對于于前面Nacos的下載、shell指令的啟動,Sentinel為開發者提供開箱即用的jar包,小伙伴可以從  release頁面 下載不同版本的控制臺 jar 包。我使用的是sentinel-dashboard-1.8.6.jarOf828資訊網——每日最新資訊28at.com

圖片圖片Of828資訊網——每日最新資訊28at.com

1.2.1.Sentinel運行

將jar包放到任意非中文目錄,執行命令:Of828資訊網——每日最新資訊28at.com

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

圖片圖片Of828資訊網——每日最新資訊28at.com

如果要修改Sentinel的默認端口、賬戶、密碼,可以通過下列配置:Of828資訊網——每日最新資訊28at.com

配置項Of828資訊網——每日最新資訊28at.com

默認值Of828資訊網——每日最新資訊28at.com

說明Of828資訊網——每日最新資訊28at.com

server.port
Of828資訊網——每日最新資訊28at.com

8080
Of828資訊網——每日最新資訊28at.com

服務端口
Of828資訊網——每日最新資訊28at.com

sentinel.dashboard.auth.username
Of828資訊網——每日最新資訊28at.com

sentinel
Of828資訊網——每日最新資訊28at.com

默認用戶名
Of828資訊網——每日最新資訊28at.com

sentinel.dashboard.auth.password
Of828資訊網——每日最新資訊28at.com

sentinel
Of828資訊網——每日最新資訊28at.com

默認密碼
Of828資訊網——每日最新資訊28at.com

例如,修改端口:Of828資訊網——每日最新資訊28at.com

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

如果您覺得本文不錯,歡迎關注,點贊,收藏支持,您的關注是我堅持的動力!Of828資訊網——每日最新資訊28at.com

1.2.2.Sentinel訪問

訪問http://localhost:8080頁面,可以訪問sentinel的控制臺了:Of828資訊網——每日最新資訊28at.com

圖片圖片Of828資訊網——每日最新資訊28at.com

需要輸入賬號和密碼,默認都是:sentinelOf828資訊網——每日最新資訊28at.com

登錄后,發現一片空白,什么都沒有:Of828資訊網——每日最新資訊28at.com

圖片圖片Of828資訊網——每日最新資訊28at.com

這是因為我們還沒有與微服務整合Of828資訊網——每日最新資訊28at.com

3. 微服務整合Sentinel

Sentinel項目實際上和前面介紹的Seata項目是項目的,不過我這里是將項目名稱進行修改Of828資訊網——每日最新資訊28at.com

【步驟一】:環境導入微服務

獲取代碼地址:Of828資訊網——每日最新資訊28at.com

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

圖片圖片Of828資訊網——每日最新資訊28at.com

sentinel-study:父工程,負責管理項目依賴Of828資訊網——每日最新資訊28at.com

  • sentinel-account-service:賬戶服務,用于用戶的資金管理。提供扣減余額的接口
  • sentinel-order-service:庫存服務,用于管理商品庫存。提供扣減庫存的接口,創建訂單時,需要調用sentinel-account-service和sentinel-storage-service
  • sentinel-storage-service:訂單服務,用于管理訂單。

【步驟二】:引入Sentinel依賴

在sentinel-order-service服務中新增sentinel的pom依賴,如下:Of828資訊網——每日最新資訊28at.com

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

【步驟三】:配置控制臺Sentinel

在sentinel-order-service服務中修改application.yaml文件,添加下面內容:Of828資訊網——每日最新資訊28at.com

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

【步驟四】:啟動項目

啟動order、Account和Storage三個微服務Of828資訊網——每日最新資訊28at.com

圖片圖片Of828資訊網——每日最新資訊28at.com

【步驟五】:訪問order-service的任意端點

打開POSTMAN,Of828資訊網——每日最新資訊28at.com

  • 請求方式:POST
  • 訪問地址:http://localhost:9092/order?userId=user20230929&commodityCode=100202003032041&count=3&mnotallow=30

圖片圖片Of828資訊網——每日最新資訊28at.com

  • 這樣才能觸發sentinel的監控。

然后再訪問sentinel的控制臺,查看效果:Of828資訊網——每日最新資訊28at.com

圖片圖片Of828資訊網——每日最新資訊28at.com

本文鏈接:http://www.www897cc.com/showinfo-26-12299-0.htmlSentinel安裝和項目整合Sentinel

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。郵件:2376512515@qq.com

上一篇: 記一次 .NET某賬本軟件 非托管泄露分析

下一篇: 十種新興網絡安全威脅和攻擊手法

標簽:
  • 熱門焦點
Top 主站蜘蛛池模板: 陈巴尔虎旗| 南城县| 延吉市| 邮箱| 宁国市| 漳浦县| 昌乐县| 龙海市| 朔州市| 防城港市| 龙岩市| 余庆县| 故城县| 云梦县| 临洮县| 霍林郭勒市| 惠安县| 当阳市| 大竹县| 涿州市| 朔州市| 阿勒泰市| 历史| 昔阳县| 策勒县| 申扎县| 百色市| 万年县| 巨野县| 晋城| 甘泉县| 宾阳县| 长海县| 明星| 长泰县| 准格尔旗| 鲁甸县| 铁力市| 隆昌县| 吐鲁番市| 汝州市|