国产精品chinese,色综合天天综合精品网国产在线,成午夜免费视频在线观看,清纯女学生被强行糟蹋小说

    <td id="ojr13"><tr id="ojr13"><label id="ojr13"></label></tr></td>
        • <source id="ojr13"></source>
            <td id="ojr13"><ins id="ojr13"><label id="ojr13"></label></ins></td>

            Article / 文章中心

            SpringCloud注冊中心Eureka

            發(fā)布時間:2021-11-23 點(diǎn)擊數(shù):561

            CAP理論#
            Zookeeper保證CP-
            ZooKeeper的leader節(jié)點(diǎn)掛掉之后會重新進(jìn)行l(wèi)eader選舉,選舉期間整個ZooKeeper集群都是不可用的;先選舉leader保證強(qiáng)一致性之后,不能保證可用性。
            Eureka保證AP-
            Eureka優(yōu)先保證可用性,Eureka各個節(jié)點(diǎn)是平等的,某幾個節(jié)點(diǎn)掛掉不會影響正常節(jié)點(diǎn)的工作,剩余的節(jié)點(diǎn)依然可以提供注冊和查詢服務(wù)。而Eureka的客戶端在向某個Eureka注冊或時如果發(fā)現(xiàn)連接失敗,則會自動切換至其它節(jié)點(diǎn),只要有一臺Eureka還在,就能保證注冊服務(wù)可用(保證可用性),只不過查到的信息可能不是最新的(不保證強(qiáng)一致性)。
            注冊中心搭建#
            Eureka是一個服務(wù)治理組件,它主要包括服務(wù)注冊和服務(wù)發(fā)現(xiàn),主要用來搭建服務(wù)注冊中心。
            Eureka是一個基于REST的服務(wù),用來定位服務(wù),進(jìn)行中間層服務(wù)器的負(fù)載均衡和故障轉(zhuǎn)移;
            (1)創(chuàng)建一個SpringBoot項目
            (2)pom引入注冊中心依賴包

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

            (3)啟動類加上注解@EnableEurekaServer

            @EnableEurekaServer public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class)
                        .bannerMode(Banner.Mode.LOG)
                        .build()
                        .run(args);
                }
            }

            (4)配置文件application.properties

            server.port=8094 #當(dāng)前IP eureka.instance.hostname=ip1 #清理服務(wù)頻次 eureka.instance.lease-renewal-interval-in-seconds=2 eureka.instance.lease-expiration-duration-in-seconds=10 #注冊策略 eureka.server.enable-self-preservation=false eureka.client.register-with-eureka=false eureka.client.fetch-registry=false #注冊地址:集群配置不配當(dāng)前ip eureka.client.service-url.defaultZone=http://ip2:${server.port}/eureka/