首页 文章资讯内容详情

SpringCloud之Eureka详细的配置

2026-06-01 4 花语

本文内容纲要:

-介绍 -术语和概念 -配置说明 -Eureka服务器配置 -EurekaInstacen配置 -Eureka客户端配置

介绍

SpringCloud是一个完整的微服务治理框架,包括服务发现和注册,服务网关,熔断,限流,负载均衡和链路跟踪等组件。

SpringCloud-Eureka主要提供服务注册和发现功能。本文提供了该组件配置的全面说明。

术语和概念

Eureka服务端:负责服务注册、发现并管理每项服务的中心 **Eureka实例:**服务(如订单系统)部署多个服务器,每个服务器上提供的服务都是实例。 Eureka服务:指提供特定服务功能的服务,例如:订单系统,同一服务可以提供多个实例; Eureka客户端:主要向服务中心注册自己成为服务。但它既可以是服务提供者,也可以是消费者。它与Eureka实例感觉相似,但实际上意义不同。

配置说明

Eureka服务器配置

################serverConfigurationassociatedwithclient####################33 #Openself-protectionmode.Nomatterwhatthesituation,theserverwillmaintainacertainnumberofservices.Avoidnetworkproblemsbetweenclientandserver,andalargenumberofservicesarecleared. eureka.server.enable-self-preservation=true #Enablethetimedtasktoclearinvalidservices.Default1minute eureka.server.eviction-interval-timer-in-ms=60000 #Howlong,clearexpireddeltadata eureka.server.delta-retention-timer-interval-in-ms=0 #,isitalsoavailabletotheclient? eureka.server.disable-delta=false #eurekaWhethertheserverrecordstheidentityoftheclientheader eureka.server.log-identity-headers=true #Requestfrequencylimiter eureka.server.rate-limiter-burst-size=10 #Whethertoenabletherequestfrequencylimiter eureka.server.rate-limiter-enabled=false #Requestfrequencyaverage eureka.server.rate-limiter-full-fetch-average-rate=100 #Whethertolimitthefrequencyrequesttothestandardclient.Iffalse,onlylimitnon-standardclients eureka.server.rate-limiter-throttle-standard-clients=false #Registerservice,averagevalueofrequestfrequencyforpullingservicelistdata eureka.server.rate-limiter-registry-fetch-average-rate=500 #Setthetrustedclientlist eureka.server.rate-limiter-privileged-clients= #Inthesettimerangeclass,thepercentageexpectedtoberenewedwiththeclient. eureka.server.renewal-percent-threshold=0.85 #Howlongtoupdatetherenewalthreshold eureka.server.renewal-threshold-update-interval-ms=0 #Howlongdoesittakeforcachedregistrationdatatoexpire? eureka.server.response-cache-auto-expiration-in-seconds=180 #Howlongtoupdatetheserviceregistrationdatainthecache eureka.server.response-cache-update-interval-ms=0 #Cachethetimeoftheincrementaldatasothatnoinformationislostwhensearching eureka.server.retention-time-in-m-s-in-delta-queue=0 #Whenthetimestampsareinconsistent,whethertosynchronize eureka.server.sync-when-timestamp-differs=true #Whethertoadoptaread-onlycachepolicy,theread-onlypolicydoesnotexpireforcacheddata. eureka.server.use-read-only-response-cache=true ################serverCustomizedImplementationConfiguration####################33 #jsonsimplementationclassnameforconversion eureka.server.json-codec-name= #PropertyResolver eureka.server.property-resolver= #eurekaserverxmlcodecimplementationname eureka.server.xml-codec-name= ################Associationbetweenservernodeandnode####################33 #replicationdataisintherequest,alwayscompressed eureka.server.enable-replicated-request-compression=false #Indicateswhetherreplicationbetweenclusternodesshouldbebatchedtoimprovenetworkefficiency. eureka.server.batch-replication=false #Allowthemaximumnumberofreplicationeventsthatarebackeduptothebackuppool.Thisbackuppoolisresponsibleforothereventsexceptstatusupdates.Thisvaluecanbesetaccordingtomemorysize,timeoutandreplicationtraffic. eureka.server.max-elements-in-peer-replication-pool=10000 #Allowthemaximumnumberofreplicationeventsthatarebackeduptothestatefulbackuppool eureka.server.max-elements-in-status-replication-pool=10000 #Multipleservicecenterssynchronizethemaximumidletimeofinformationthreadswitheachother eureka.server.max-idle-thread-age-in-minutes-for-peer-replication=15 #Statussynchronizationthreadmaximumidletime eureka.server.max-idle-thread-in-minutes-age-for-status-replication=15 #Serviceregistryeachinstanceofthemaximumnumberofthreadstocopydatatoeachother eureka.server.max-threads-for-peer-replication=20 #Serviceregistryeachinstanceofthemaximumnumberofthreadscopyingstatedata eureka.server.max-threads-for-status-replication=1 Communicationtimebetween#instanceanddatareplication eureka.server.max-time-for-replication=30000 #Theminimumnumberofnormalpeer-to-peerservices.-1indicatesthattheservicecenterisasinglenode. eureka.server.min-available-instances-for-peer-replication=-1 Theminimumnumberofthreadsopenedbetween#instanceandmutualreplication eureka.server.min-threads-for-peer-replication=5 Between#instanceforstatereplication,theminimumnumberofthreadsopened eureka.server.min-threads-for-status-replication=1 Numberoftimesthatcanberetriedwhencopyingdatabetween#instance eureka.server.number-of-replication-retries=5 #eurekaHowoftentoupdatedatabetweennodes.Thedefaultis10minutes. eureka.server.peer-eureka-nodes-update-interval-ms=600000 #eurekaThetimeintervalbetweenservicestatusupdates. eureka.server.peer-eureka-status-refresh-time-interval-ms=0 #eurekaPeer-to-peerconnectiontimeout eureka.server.peer-node-connect-timeout-ms=200 #eurekaidletimeafterpeernodeconnection eureka.server.peer-node-connection-idle-timeout-seconds=30 #Readdataconnectiontimeoutbetweennodes eureka.server.peer-node-read-timeout-ms=200 #eurekaserverTotalnumberofconnectionsbetweennodes eureka.server.peer-node-total-connections=1000 #eurekaserverMaximumnumberofsinglemachinesconnectedbetweennodes eureka.server.peer-node-total-connections-per-host=10 #Thenumberoftimeseurekatriedtoobtainregistrationinformationwhentheservicenodewasstarted eureka.server.registry-sync-retries= #Wheneurekatriestoobtainregistrationinformationmultipletimeswhentheservicenodestartsup eureka.server.registry-sync-retry-wait-ms= #Whentheeurekaserverisstarted,youcannotwaitfortheinstanceregistrationinformationfromthepeernode.Howlongshoulditwait? eureka.server.wait-time-in-ms-when-sync-empty=0 ################serverConfigurationassociatedwithremote####################33 #,isitalsoprovidedtotheremoteregion? eureka.server.disable-delta-for-remote-regions=false #Oldbehavioroftheapplicationthatisrolledbacktotheremotezone(ifconfigured)Ifthereisnoinstanceoftheapplicationinthelocalzone,itwillbedisabled. eureka.server.disable-transparent-fallback-to-other-region=false #IndicateswhetherthecontentobtainedfromtheEurekaservermustbecompressedfortheremotezoneiftheserversupportsit. eureka.server.g-zip-content-from-remote-region=true #Connectioneurekaremotenoteconnectiontimeout eureka.server.remote-region-connect-timeout-ms=1000 #remoteregionApplicationwhitelist eureka.server.remote-region-app-whitelist. #Connecteurekaremotenoteconnectionidletime eureka.server.remote-region-connection-idle-timeout-seconds=30 #ExecutingremoteregionTherequestthreadpoolsizeforobtainingregistrationinformation eureka.server.remote-region-fetch-thread-pool-size=20 #remoteregionTimeoutfromreadingdatafrompeereureka eureka.server.remote-region-read-timeout-ms=1000 #Timeintervalforobtainingregistrationinformationfromremoteregion eureka.server.remote-region-registry-fetch-interval=30 #remoteregionThetotalnumberofconnectionsconnectingeurekanodes eureka.server.remote-region-total-connections=1000 #remoteregionThenumberofstand-aloneconnectionsconnectingeurekanodes eureka.server.remote-region-total-connections-per-host=50 #remoteregionfetchesthestoragefileoftheregistrationinformation,andthisreliablestoragefileneedsafullyqualifiednametospecify eureka.server.remote-region-trust-store= #remoteregionPasswordofthestoredfile eureka.server.remote-region-trust-store-password= #remoteregionurl.separatedbymultiplecommas eureka.server.remote-region-urls= #remoteregionurl.separatedbymultiplecommas eureka.server.remote-region-urls-with-name. ################serverConfigurationassociatedwithASG/AWS/EIP/route52####################33 #CachetheexpirationtimeofASGinformation. eureka.server.a-s-g-cache-expiry-timeout-ms=0 #QuerythetimeouttimeofASGinformation. eureka.server.a-s-g-query-timeout-ms=300 #ServiceupdateASGinformationfrequency eureka.server.a-s-g-update-interval-ms=0 #AWSAccessID eureka.server.a-w-s-access-id= #AWSSecurityKey eureka.server.a-w-s-secret-key= #AWSbindingstrategy eureka.server.binding-strategy=eip #Usethenameoftherolethatautomaticallyextendsthegroupingfromathird-partyAWSaccountdescription. eureka.server.list-auto-scaling-groups-role-name= #Whethershouldestablishaconnectionguide eureka.server.prime-aws-replica-connections=true #NumberoftimestheservertriestobindcandidateEIPs eureka.server.e-i-p-bind-rebind-retries=3 #ThetimeintervalatwhichtheserverbindstheEIP.Ifthebindingischecked,itisre-boundifthebindingfails.Ifandonlyifitisalreadybound eureka.server.e-i-p-binding-retry-interval-ms=10 #TimeintervalatwhichtheserverbindsEIP.Ifandonlyiftheserviceisbound eureka.server.e-i-p-binding-retry-interval-ms-when-unbound= #Thenumberoftimestheservertriestobindroute53 eureka.server.route53-bind-rebind-retries=3 #Servletintervalhowlongtotrytobindroute53 eureka.server.route53-binding-retry-interval-ms=30 # eureka.server.route53-domain-t-t-l=10

EurekaInstacen配置

#Hostnameoftheserviceregistryinstance eureka.instance.hostname=localhost #RegistertheapplicationgroupnameintheEurekaservice eureka.instance.app-group-name= #RegistertheapplicationnameintheEurekaservice eureka.instance.appname= #UniqueIDoftheinstanceregisteredtotheservicecenter eureka.instance.instance-id= #IPaddressoftheinstance eureka.instance.ip-address= #Instance,whetherIPispreferredoverhostname eureka.instance.prefer-ip-address=false #GroupnameassociatedwiththisinstanceforautomaticextensionoftheAWSplatform, eureka.instance.a-s-g-name= #Deploythedatacenterforthisinstance eureka.instance.data-center-info= #Defaultaddressresolutionorder eureka.instance.default-address-resolution-order= #Instanceenvironmentconfiguration eureka.instance.environment= #Initializetheinstanceandregistertotheinitialstateoftheservicecenter eureka.instance.initial-status=up #Indicatewhetheraslongasthisinstanceisregisteredtotheservicecenter,immediatelycommunicate eureka.instance.instance-enabled-onit=false #Thenamespaceoftheserviceinstanceforfindingattributes eureka.instance.namespace=eureka #Thechilddefinitionmetadataoftheserviceinstancecanbeacceptedbytheservicecenter. eureka.instance.metadata-map.test=test #Servicecenterdeletesthewaitingtime(inseconds)ofthisserviceinstance,andthetimeintervalistheheartbeattimereceivedbythelastservicecenter. eureka.instance.lease-expiration-duration-in-seconds=90 #Theintervalatwhichtheinstancesendsaheartbeattotheservicecentertoindicatethattheserviceinstanceisavailable. eureka.instance.lease-renewal-interval-in-seconds=30 #Instance,registrationservicecenter,thenumberofcommunicationopenedbydefault eureka.instance.registry.default-open-for-traffic-count=1 #Numberofrenewalsperminute eureka.instance.registry.expected-number-of-renews-per-min=1 #Instancehealthcheckurl,absolutepath eureka.instance.health-check-url= #Instancehealthcheckurl,relativepath eureka.instance.health-check-url-path=/health #Instanceshomepageurl,absolutepath eureka.instance.home-page-url= #Instanceshomepageurl,relativepath eureka.instance.home-page-url-path=/ #Instancesecurityhealthcheckurl,absolutepath eureka.instance.secure-health-check-url= #https eureka.instance.secure-port=443 #httpsCommunicationportisenabled eureka.instance.secure-port-enabled=false #http eureka.instance.non-secure-port=80 #httpCommunicationportisenabled eureka.instance.non-secure-port-enabled=true #Securityvirtualhostname(https)forthisinstance eureka.instance.secure-virtual-host-name=unknown #Virtualhostnameofthisinstance(http) eureka.instance.virtual-host-name=unknown #Thestatusoftheinstanceisrenderedurl,absolutepath eureka.instance.status-page-url= #Thestatusoftheinstanceisrenderedurl,relativepath eureka.instance.status-page-url-path=/status

Eureka客户端配置

#Thisclientisavailable eureka.client.enabled=true #InstanceWhethertoregisteryourowninformationontheeurekaserverforotherservicestodiscover,thedefaultistrue eureka.client.register-with-eureka=false #Thisclientgetstheregistrationinformationontheeurekaserverregistry,thedefaultistrue eureka.client.fetch-registry=false #Whethertofilterout,non-UPinstances.Defaultistrue eureka.client.filter-only-up-instances=true #zoneandurladdresswithEurekaRegistrationServiceCenter eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/ #clientistheidlewaitingtimeafterconnectingtotheEurekaserver.Thedefaultis30seconds. eureka.client.eureka-connection-idle-timeout-seconds=30 #clientconnectstoeurekaserverconnectiontimeout,thedefaultis5seconds eureka.client.eureka-server-connect-timeout-seconds=5 #clientReadtimeoutfortheserver eureka.client.eureka-server-read-timeout-seconds=8 #clientConnectionalleurekaservertotalnumberofconnections,thedefault200 eureka.client.eureka-server-total-connections=200 #clientConnecttothenumberofsingle-machineconnectionsontheeurekaserver.Thedefaultis50. eureka.client.eureka-server-total-connections-per-host=50 #Executiveindexrollbackrefreshrelatedattribute,whichisthemaximummultipleoftheretrydelay,thedefaultis10 eureka.client.cache-refresh-executor-exponential-back-off-bound=10 #Executionprogramcacherefreshthreadpoolsize,thedefaultis5 eureka.client.cache-refresh-executor-thread-pool-size=2 #Executionprogramrollbackrelatedattributes,whichisthemaximummultipleoftheretrydelay.Thedefaultis10 eureka.client.heartbeat-executor-exponential-back-off-bound=10 #Executionprogramthreadpoolsize,thedefaultis5 eureka.client.heartbeat-executor-thread-pool-size=5 #Askthefrequency(s)oftheEurekaserviceurlinformationchange,thedefaultis300seconds eureka.client.eureka-service-url-poll-interval-seconds=300 #Thetime(s)requiredtoinitiallycopytheinstanceinformationtotheeurekaserver.Thedefaultis40seconds. eureka.client.initial-instance-info-replication-interval-seconds=40 #Howlongdoesittaketocopytheinstanceinformationtotheeurekaserveragain,thedefaultis30seconds? eureka.client.instance-info-replication-interval-seconds=30 #Timeinterval(s)fromtheeurekaserverregistrytoobtainregistrationinformation,thedefaultis30seconds eureka.client.registry-fetch-interval-seconds=30 #Gettheregionwheretheinstanceislocated.Thedefaultisus-east-1 eureka.client.region=us-east-1 #InstanceWhethertousetheeurekaserverinthesamezone,thedefaultistrue.Ideally,theeurekaclientandserverareinthesamezone. eureka.client.prefer-same-zone-eureka=true #Getalistofavailableareasintheregionwheretheinstanceislocated,separatedbycommas.(AWS) eureka.client.availability-zones.china=defaultZone,defaultZone1,defaultZone2 Thelistofcomma-separatedregionsinthe#eurekaserviceregistryinformation.Ifyoudonotreturntheseregions,theclientwillstartupwitherrors.Thedefaultisnull eureka.client.fetch-remote-regions-registry= #Serverisabletoredirectclientrequeststothebackupserver.Ifsettofalse,theserverwillprocesstherequestdirectly,andifsettotrue,itmaysendanHTTPredirecttotheclient.Defaultisfalse eureka.client.allow-redirects=false # eureka.client.client-data-accept= #Incrementalinformationcanbeprovidedtotheclient,thedefaultisfalse eureka.client.disable-delta=false The#eurekaserverserialization/deserializationinformationobtainsthereplacementstringofthe"_"symbol.Thedefaultis"__" eureka.client.escape-char-replacement=__ The#eurekaserverserialization/deserializationinformationobtainsareplacementstringforthe"$"symbol.Thedefaultis"_-" eureka.client.dollar-replacement="_-" #Whentheserversupportscompression,whethertosupporttheinformationobtainedfromtheserverforcompression.Defaultistrue eureka.client.g-zip-content=true #Whethertorecordthedifferencebetweentheinformationintheregistrybetweentheeurekaserverandtheclient,thedefaultisfalse eureka.client.log-delta-diff=false #Ifsettotrue,theclientsstatusupdatewillbeupdatedon-demandtotheremoteserver.Thedefaultistrue. eureka.client.on-demand-update-status-change=true #ThisclientisonlyinterestedininformationaboutasingleVIPregistry.Thedefaultisnull eureka.client.registry-refresh-single-vip-address= #clientisforcedtoregistertotheservicecenterduringtheinitializationphase,thedefaultisfalse eureka.client.should-enforce-registration-at-init=false #clientWhentheshutdownisdisplayed,thelogoutserviceisdisplayedfromtheservicecenter.Thedefaultistrue. eureka.client.should-unregister-on-shutdown=true #Gettheproxyhostoftheeurekaservice,thedefaultisnull eureka.client.proxy-host= #Gettheproxypasswordoftheeurekaservice,thedefaultisnull eureka.client.proxy-password= #Gettheproxyportoftheeurekaservice,thedefaultisnull eureka.client.proxy-port= #Gettheproxyusernameoftheeurekaservice,thedefaultisnull eureka.client.proxy-user-name= #Attributeinterpreter eureka.client.property-resolver= #Gettheimplementationnameofthefallbackoptionwhentheeurekaclientreadstheregistryatthefirststartup. eureka.client.backup-registry-impl= #×××Configuration,ifthelatestXXXisstable,itcanberemoved,thedefaultisnull eureka.client.decoder-name= #,ifthelatestencoderisstable,itcanberemoved,thedefaultisnull eureka.client.encoder-name= #WhethertousetheDNSmechanismtogetalistofservicesandthencommunicate.Defaultisfalse eureka.client.use-dns-for-fetching-service-urls=false #GettheDNSnametobequeriedtogettheeurekaserver.ThisconfigurationisonlyusedwhentheeurekaserveripaddresslistisintheDNS.Thedefaultisnull eureka.client.eureka-server-d-n-s-name= #Gettheportoftheeurekaserver.ThisconfigurationisonlyusedwhentheeurekaserveripaddresslistisintheDNS.Thedefaultisnull eureka.client.eureka-server-port= #indicatesthepathoftheeurekaregistrationcenter.Ifitisconfiguredaseureka,itishttp://x.x.x.x:x/eureka/.Addingthisconfigurationtotheeurekaconfigurationfileindicatesthateurekaisregisteredasaclienttotheregistrationcentertoformaneurekacluster.ThisconfigurationisonlyusedintheDNSaddresslistoftheeurekaserver.Thedefaultisnull. eureka.client.eureka-server-u-r-l-context=

本文内容总结:介绍,术语和概念,配置说明,Eureka服务器配置,EurekaInstacen配置,Eureka客户端配置,

原文链接:https://www.cnblogs.com/BlogNetSpace/p/11264235.html