国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka

這篇具有很好參考價(jià)值的文章主要介紹了微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。


服務(wù)發(fā)現(xiàn)(注冊(cè))機(jī)制

nodejs的Eureka Client開源實(shí)現(xiàn)

微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka,微服務(wù),eureka,架構(gòu)
服務(wù)發(fā)現(xiàn)組件具備功能:
服務(wù)注冊(cè)表
服務(wù)注冊(cè)與服務(wù)發(fā)現(xiàn)
服務(wù)檢查

Eureka架構(gòu)圖
微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka,微服務(wù),eureka,架構(gòu)

Eureka使用

引用

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>
</dependencies>

配置

server:
  port: 8761

eureka:
  client:
    registerWithEureka: false # 是否將自己注冊(cè)到Eureka Server
    fetch-registry: false # 是否從Eureka Server獲取注冊(cè)信息
    service-url:
      defaultZone: http://localhost:8761/eureka/ # 設(shè)置與Eureka Server交互的地址,多個(gè)地址用,分隔

啟動(dòng)類標(biāo)記

@SpringBootApplication
@EnableEurekaServer // 聲明這是一個(gè)Eureka Server
public class EurekaApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaApplication.class, args);
    }
}

訪問(wèn)

http://localhost:8761/

微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka,微服務(wù),eureka,架構(gòu)

微服務(wù)注冊(cè)

微服務(wù)工程添加引用

注意添加版本號(hào),否則會(huì)下載不下來(lái)

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
    <version>1.4.7.RELEASE</version>
</dependency>

增加配置

spring:
  application:
    name: microservice-provider-user # 用于指定注冊(cè)到Eureka Server上的應(yīng)用名稱

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
    instance:
      prefer-ip-address: true # 表示將自己的IP注冊(cè)到Eureka Server

啟動(dòng)類增加注解

import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient // 聲明這是一個(gè)Eureka Client

啟動(dòng)服務(wù)注冊(cè)

微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka,微服務(wù),eureka,架構(gòu)

Eureka Server集群部署

防止因Eureka Server宕機(jī)導(dǎo)致微服務(wù)不可用
通過(guò)運(yùn)行多個(gè)實(shí)例并相互注冊(cè)的方式實(shí)現(xiàn)高可用部署,實(shí)例間彼此增量地同步信息,確保所有節(jié)點(diǎn)數(shù)據(jù)一致。

修改配置文件

spring:
  application:
    name: microservice-discovery-eureka
---
spring:
  config:
    activate:
      on-profile: peer1 # 指定profile=peer1
server:
  port: 8761
eureka:
  instance:
    hostname: peer1 # 指定當(dāng)profile=peer1時(shí),主機(jī)名是peer1
  client:
    serviceUrl:
      defaultZone: http://peer2:8762/eureka/ # 將自己注冊(cè)到peer2這個(gè)Eureka上面去
---
spring:
  config:
    activate:
      on-profile: peer2
server:
  port: 8762
eureka:
  instance:
    hostname: peer2
  client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/

啟動(dòng)多個(gè)eureka實(shí)例

java -jar microservice-discovery-eureka-3.0.2.jar --spring.profiles.active=peer1
java -jar microservice-discovery-eureka-3.0.2.jar --spring.profiles.active=peer2

微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka,微服務(wù),eureka,架構(gòu)
微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka,微服務(wù),eureka,架構(gòu)

微服務(wù)注冊(cè)到多個(gè)eureka實(shí)例

eureka:
  client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/,http://peer2:8762/eureka/
    instance:
      prefer-ip-address: true # 表示將自己的IP注冊(cè)到Eureka Server

為Eureka Server添加用戶認(rèn)證

前面的示例均可以匿名訪問(wèn),可以通過(guò)spring-security先登錄之后在訪問(wèn)

引入spring-security

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>

配置

server:
  port: 8761

eureka:
  client:
    registerWithEureka: false # 是否將自己注冊(cè)到Eureka Server
    fetch-registry: false # 是否從Eureka Server獲取注冊(cè)信息
    service-url:
      defaultZone: http://user:password123@localhost:8761/eureka/
spring:
  security:
    user:
      name: user # 配置登錄的賬號(hào)
      password: password123 # 配置登錄的密碼

關(guān)閉security的csrf,否則client無(wú)法注冊(cè)

未設(shè)置,client注冊(cè)會(huì)報(bào)Cannot execute request on any known server

/**
 * 高版本的丟棄了
 *
 * security:
 *   basic:
 *    enabled: true
 * 配置,應(yīng)該使用以下方式開啟
 * @param http
 * @throws Exception
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig {
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{
        http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER);
        http.csrf().disable();
        //注意:為了可以使用 http://${user}:${password}@${host}:${port}/eureka/ 這種方式登錄,所以必須是httpBasic,
        // 如果是form方式,不能使用url格式登錄
        http.authorizeRequests().anyRequest().authenticated().and().httpBasic();
        return http.build();
    }
}

client注冊(cè)

僅需修改注冊(cè)地址即可,注意和server保持一致

eureka:
  client:
    service-url:
      defaultZone: http://user:password123@localhost:8761/eureka/ # 需要這種格式 http://user:password@EUREKA_HOST:EUREKA_PORT/eureka/

Eureka自我保護(hù)模式

https://blog.csdn.net/fengzelun/article/details/117718784

常見問(wèn)題

1、Cannot execute request on any known server

https://juejin.cn/post/6995434651862958087文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-767479.html

到了這里,關(guān)于微服務(wù)注冊(cè)與發(fā)現(xiàn)——Eureka的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 1-Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)以及Eureka集群搭建(實(shí)操型)

    1-Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)以及Eureka集群搭建(實(shí)操型)

    直接看下面的文章 idea創(chuàng)建maven多模塊項(xiàng)目. 簡(jiǎn)單介紹一下: 父工程: dog-cloud-parent 管理實(shí)體項(xiàng)目: dog-po 微服務(wù)-服務(wù)提供者: dog-provider-8001 微服務(wù)-服務(wù)消費(fèi)者: dog-consumer-80 如下: 1.3.1 父工程:dog-cloud-parent pom如下: 1.3.2 管理實(shí)體項(xiàng)目:dog-po 如下: 1.3.3 服務(wù)提供者:dog-

    2024年02月16日
    瀏覽(23)
  • 服務(wù)注冊(cè)發(fā)現(xiàn)_搭建單機(jī)Eureka注冊(cè)中心

    服務(wù)注冊(cè)發(fā)現(xiàn)_搭建單機(jī)Eureka注冊(cè)中心

    創(chuàng)建cloud-eureka-server7001模塊 pom添加依賴 寫yml文件 主啟動(dòng)類 測(cè)試 訪問(wèn)瀏覽器localhostL:7001 參數(shù): Environment: 環(huán)境,默認(rèn)為test,該參數(shù)在實(shí)際使用過(guò)程中,可以不用更改 Data center: 數(shù)據(jù)中心,使用的是默認(rèn)的是 “MyOwn” Current time:當(dāng)前的系統(tǒng)時(shí)間 Uptime:已經(jīng)運(yùn)行了多少時(shí)間

    2024年02月07日
    瀏覽(20)
  • springcloud Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)

    springcloud Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)

    代碼上傳到 :https://github.com/13thm/study_springcloud/tree/main/days3 什么是服務(wù)治理 Spring Cloud 封裝了 Netflix 公司開發(fā)的 Eureka 模塊來(lái)實(shí)現(xiàn)服務(wù)治理 什么是服務(wù)注冊(cè)與發(fā)現(xiàn) Eureka采用了CS的設(shè)計(jì)架構(gòu),Eureka Server 作為服務(wù)注冊(cè)功能的服務(wù)器,它是服務(wù)注冊(cè)中心。而系統(tǒng)中的其他微服務(wù),使

    2024年01月18日
    瀏覽(56)
  • 第二章 Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)

    第二章 Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)

    gitee:springcloud_study: springcloud:服務(wù)集群、注冊(cè)中心、配置中心(熱更新)、服務(wù)網(wǎng)關(guān)(校驗(yàn)、路由、負(fù)載均衡)、分布式緩存、分布式搜索、消息隊(duì)列(異步通信)、數(shù)據(jù)庫(kù)集群、分布式日志、系統(tǒng)監(jiān)控鏈路追蹤。 1. Eureka基礎(chǔ)知識(shí) 什么是服務(wù)治理? 在傳統(tǒng)的rpc遠(yuǎn)程調(diào)用框

    2024年02月03日
    瀏覽(19)
  • SpringCloud服務(wù)注冊(cè)與發(fā)現(xiàn)組件Eureka(五)

    SpringCloud服務(wù)注冊(cè)與發(fā)現(xiàn)組件Eureka(五)

    Eureka github 地址: https://github.com/Netflix/eureka Eureka是Netflix開發(fā)的服務(wù)發(fā)現(xiàn)框架,本身是一個(gè)基于REST的服務(wù),主要用于定位運(yùn)行在AWS域中的中間層服務(wù),以達(dá)到負(fù)載均衡和中間層服務(wù)故障轉(zhuǎn)移的目的。SpringCloud將它集成在其子項(xiàng)目spring-cloud-netflix中,以實(shí)現(xiàn)SpringCloud的服務(wù)發(fā)現(xiàn)功

    2024年02月09日
    瀏覽(91)
  • 什么是SpringCloud Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)

    什么是SpringCloud Eureka服務(wù)注冊(cè)與發(fā)現(xiàn)

    ??前言 本篇博文是關(guān)于SpringCloud Eureka 介紹,希望你能夠喜歡 ??個(gè)人主頁(yè):晨犀主頁(yè) ??個(gè)人簡(jiǎn)介:大家好,我是晨犀,希望我的文章可以幫助到大家,您的滿意是我的動(dòng)力???? ??歡迎大家:這里是CSDN,我總結(jié)知識(shí)的地方,歡迎來(lái)到我的博客,感謝大家的觀看?? 如果文

    2024年02月09日
    瀏覽(34)
  • Eureka、Zookeeper、Consul服務(wù)注冊(cè)與發(fā)現(xiàn)

    Eureka、Zookeeper、Consul服務(wù)注冊(cè)與發(fā)現(xiàn)

    一、Eureka服務(wù)注冊(cè)與發(fā)現(xiàn) 1.1 概念 Eureka 是 Netflix 公司開源的一個(gè)服務(wù)注冊(cè)與發(fā)現(xiàn)的組件 。 Eureka 和其他 Netflix 公司的服務(wù)組件(例如負(fù)載均衡、熔斷器、網(wǎng)關(guān)等) 一起,被 Spring Cloud 社區(qū)整合為Spring-Cloud-Netflix 模塊。 Eureka 包含兩個(gè)組件:Eureka Server (注冊(cè)中心) 和 Eureka Clien

    2024年02月02日
    瀏覽(21)
  • Spring Cloud Eureka:服務(wù)注冊(cè)與發(fā)現(xiàn)

    Spring Cloud Eureka:服務(wù)注冊(cè)與發(fā)現(xiàn)

    ??wei_shuo的個(gè)人主頁(yè) ??wei_shuo的學(xué)習(xí)社區(qū) ??Hello World ! Spring Cloud Eureka是Spring Cloud生態(tài)系統(tǒng)中的一個(gè)組件,它是用于實(shí)現(xiàn)服務(wù)注冊(cè)與發(fā)現(xiàn)的服務(wù)治理組件。在微服務(wù)架構(gòu)中,服務(wù)之間存在復(fù)雜的依賴關(guān)系,而Spring Cloud Eureka可以幫助解決服務(wù)之間相互查找和通信的問(wèn)題 Eurek

    2024年02月09日
    瀏覽(88)
  • Eureka:構(gòu)建可靠的服務(wù)注冊(cè)和發(fā)現(xiàn)系統(tǒng)

    在分布式系統(tǒng)中,服務(wù)注冊(cè)和發(fā)現(xiàn)是一項(xiàng)關(guān)鍵任務(wù)。Netflix開源的Eureka框架為我們提供了一種可靠、高效的解決方案。本文將介紹Eureka的主要特點(diǎn)和工作原理,并提供一些實(shí)際的代碼示例。 服務(wù)注冊(cè)和發(fā)現(xiàn) :Eureka允許微服務(wù)在啟動(dòng)時(shí)自動(dòng)向注冊(cè)中心注冊(cè)自己的信息,包括服務(wù)

    2024年02月12日
    瀏覽(21)
  • 【Spring Cloud 三】Eureka服務(wù)注冊(cè)與服務(wù)發(fā)現(xiàn)

    【Spring Cloud 三】Eureka服務(wù)注冊(cè)與服務(wù)發(fā)現(xiàn)

    【Spring Cloud一】微服務(wù)基本知識(shí) 目前公司項(xiàng)目使用的注冊(cè)中心主要是Spring Cloud Alibaba的Nacos做的注冊(cè)中心和配置中心。之前也是對(duì)Nacos的基本原理通過(guò)手寫代碼的方式進(jìn)行了實(shí)現(xiàn)。出于對(duì)于Eureka的好奇所以就對(duì)Spring Cloud Neflix的Eureka進(jìn)行理論學(xué)習(xí)和實(shí)踐。 Eureka是一個(gè) 注冊(cè)發(fā)現(xiàn)中

    2024年02月14日
    瀏覽(986)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包