springCloud的eureka高可用配置方案思路是:几个服务之间相互注册,比如两个服务,A注册到B上,B注册到A上,如果是三个服务则是:A注册到BC上,B注册到AC上,C注册到AB上,这样就会在几个服务间进行同步,同时服务提供方向三个服务均注册,这样就会保证当一个服务宕机的时候,不影响整个系统的正常运行,从而保证了eureka的高可用。本博主在最后验证了服务提供方仅注册到其中一个的方法,其高可靠性也是有保障的。所以服务提供方只需向服务注册中心之一提供注册就可以了,他们之间可以自行同步,保证高可用性。

  下面贴出主要的配置代码,其他的都一样,我们在这里主要贴出yml配置和控制台效果

8880

1 #本项目端口2 server:3   port: 8880
4 #定义应用名称为order5 spring:6 application:7 name: server8 #服务注册中心实例主机名9 eureka:10 instance:11 hostname: host12 client:13 #是否向注册中心注册自己14     register-with-eureka: false
15 #是否获取注册表16     fetch-registry: false
17     service-url:18       defaultZone: http://127.0.0.1:8881/eureka/,http://127.0.0.1:8882/eureka/
19  

8881

1 #本项目端口2 server:3   port: 8881
4 #定义应用名称为order5 spring:6 application:7 name: server18 #服务注册中心实例主机名9 eureka:10 instance:11 hostname: host112 client:13 #是否向注册中心注册自己14     register-with-eureka: false
15 #是否获取注册表16     fetch-registry: false
17     service-url:18       defaultZone: http://127.0.0.1:8880/eureka/,http://127.0.0.1:8882/eureka/
19  

8882

1 server:2   port: 8882
3 #定义应用名称为order4 spring:5 application:6 name: server27 #服务注册中心实例主机名8 eureka:9 instance:10 hostname: host211 client:12 #是否向注册中心注册自己13     register-with-eureka: true
14 #是否获取注册表15     fetch-registry: false
16 #服务地址17     service-url:18       defaultZone: http://127.0.0.1:8880/eureka/,http://127.0.0.1:8881/eureka/

注意8880和8881未向自己注册,8002向自己注册,分别启动服务,8880和8881均未出现任何报错,而8882启动成功后会有超时报错信息

1 2018-09-20 10:16:13.038  INFO 7944 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4ec4f3a0: startup date [Thu Sep 20 10:16:13 CST 2018]; root of context hierarchy2 2018-09-20 10:16:13.286  INFO 7944 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported forautowiring3 2018-09-20 10:16:13.307  INFO 7944 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fbb30aa3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)4
5 .   ____          _            __ _ _6  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
7 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
8  \\/  ___)| |_)| | | | | || (_| |) ) ) )9   '  |____| .__|_| |_|_| |_\__, | / / / /
10  =========|_|==============|___/=/_/_/_/
11  :: Spring Boot ::        (v2.0.5.RELEASE)12
13 2018-09-20 10:16:13.560  INFO 7944 --- [           main] c.sharp.forward.EurekaServerApplication  : No active profile set, falling back to default profiles: default
14 2018-09-20 10:16:13.574  INFO 7944 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@74589991: startup date [Thu Sep 20 10:16:13 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4ec4f3a015 2018-09-20 10:16:14.384  INFO 7944 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=86aa96a4-8d41-33fd-af49-92950d537d7716 2018-09-20 10:16:14.399  INFO 7944 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported forautowiring17 2018-09-20 10:16:14.477  INFO 7944 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fbb30aa3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)18 2018-09-20 10:16:14.932  INFO 7944 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8880(http)19 2018-09-20 10:16:14.951  INFO 7944 ---[           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]20 2018-09-20 10:16:14.951  INFO 7944 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
21 2018-09-20 10:16:14.958  INFO 7944 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\topbandSoft\java\jre1.8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:/topbandSoft/java/jre1.8/bin/server;D:/topbandSoft/java/jre1.8/bin;D:/topbandSoft/java/jre1.8/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Java\jre7;D:\topbandSoft\java\jdk1.8\bin;D:\topbandSoft\java\jdk1.8\jre\bin;D:\topbandSoft\git\Git\cmd;D:\topbandSoft\svn\bin;D:\topbandSoft\maven\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin;C:\Program Files\bin;D:\topbandSoft\zookeeper/bin;D:\topbandSoft\zookeeper/conf;;D:\topbandSoft\eclipse4.8\eclipse;;.]22 2018-09-20 10:16:15.067  INFO 7944 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext23 2018-09-20 10:16:15.067  INFO 7944 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1493ms24 2018-09-20 10:16:15.230  WARN 7944 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.25 2018-09-20 10:16:15.231  INFO 7944 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.26 2018-09-20 10:16:15.243  INFO 7944 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@7443d25a27 2018-09-20 10:16:16.136  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]28 2018-09-20 10:16:16.136  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webMvcMetricsFilter' to: [/*]29 2018-09-20 10:16:16.136  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]30 2018-09-20 10:16:16.136  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]31 2018-09-20 10:16:16.136  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]32 2018-09-20 10:16:16.137  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpTraceFilter' to: [/*]33 2018-09-20 10:16:16.137  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'servletContainer' to urls: [/eureka/*]34 2018-09-20 10:16:16.137  INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]35 2018-09-20 10:16:16.201  INFO 7944 --- [ost-startStop-1] c.s.j.s.i.a.WebApplicationImpl           : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'36 2018-09-20 10:16:16.251  INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson37 2018-09-20 10:16:16.252  INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson38 2018-09-20 10:16:16.348  INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml39 2018-09-20 10:16:16.348  INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml40 2018-09-20 10:16:16.561  WARN 7944 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.41 2018-09-20 10:16:16.561  INFO 7944 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.42 2018-09-20 10:16:16.621  INFO 7944 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [classorg.springframework.web.servlet.resource.ResourceHttpRequestHandler]43 2018-09-20 10:16:16.769  INFO 7944 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@74589991: startup date [Thu Sep 20 10:16:13 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4ec4f3a044 2018-09-20 10:16:16.822  INFO 7944 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>>org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)45 2018-09-20 10:16:16.823  INFO 7944 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto publicorg.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)46 2018-09-20 10:16:16.832  INFO 7944 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.status(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)47 2018-09-20 10:16:16.834  INFO 7944 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/lastn],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.lastn(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)48 2018-09-20 10:16:16.858  INFO 7944 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]49 2018-09-20 10:16:16.858  INFO 7944 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]50 2018-09-20 10:16:17.166  INFO 7944 --- [           main] o.s.ui.freemarker.SpringTemplateLoader   : SpringTemplateLoader for FreeMarker: using resource loader [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@74589991: startup date [Thu Sep 20 10:16:13 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@4ec4f3a0] and template loader path [classpath:/templates/]51 2018-09-20 10:16:17.167  INFO 7944 --- [           main] o.s.w.s.v.f.FreeMarkerConfigurer         : ClassTemplateLoader for Spring macros added to FreeMarker configuration52 2018-09-20 10:16:17.321  INFO 7944 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING53 2018-09-20 10:16:17.353  INFO 7944 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-154 2018-09-20 10:16:17.353  INFO 7944 --- [           main] com.netflix.discovery.DiscoveryClient    : Client configured to neither register nor query for data.55 2018-09-20 10:16:17.362  INFO 7944 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1537409777361 with initial instances count: 056 2018-09-20 10:16:17.409  INFO 7944 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initializing ...57 2018-09-20 10:16:17.412  INFO 7944 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Adding new peer nodes [http://127.0.0.1:8881/eureka/,http://127.0.0.1:8882/eureka/]58 2018-09-20 10:16:17.612  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson59 2018-09-20 10:16:17.612  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson60 2018-09-20 10:16:17.612  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml61 2018-09-20 10:16:17.612  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml62 2018-09-20 10:16:17.696  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson63 2018-09-20 10:16:17.696  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson64 2018-09-20 10:16:17.696  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml65 2018-09-20 10:16:17.696  INFO 7944 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml66 2018-09-20 10:16:17.756  INFO 7944 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:http://127.0.0.1:8881/eureka/67 2018-09-20 10:16:17.756  INFO 7944 --- [           main] c.n.eureka.cluster.PeerEurekaNodes       : Replica node URL:http://127.0.0.1:8882/eureka/68 2018-09-20 10:16:17.762  INFO 7944 --- [           main] c.n.e.registry.AbstractInstanceRegistry  : Finished initializing remote region registries. All known remote regions: []69 2018-09-20 10:16:17.763  INFO 7944 --- [           main] c.n.eureka.DefaultEurekaServerContext    : Initialized70 2018-09-20 10:16:17.784  INFO 7944 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'71 2018-09-20 10:16:17.793  INFO 7944 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)72 2018-09-20 10:16:17.793  INFO 7944 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)73 2018-09-20 10:16:17.794  INFO 7944 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)74 2018-09-20 10:16:17.831  INFO 7944 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup75 2018-09-20 10:16:17.837  INFO 7944 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'environmentManager' has been autodetected for JMX exposure76 2018-09-20 10:16:17.838  INFO 7944 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'refreshScope' has been autodetected for JMX exposure77 2018-09-20 10:16:17.839  INFO 7944 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure78 2018-09-20 10:16:17.841  INFO 7944 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]79 2018-09-20 10:16:17.848  INFO 7944 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]80 2018-09-20 10:16:17.855  INFO 7944 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=74589991,type=ConfigurationPropertiesRebinder]81 2018-09-20 10:16:17.863  INFO 7944 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 082 2018-09-20 10:16:17.867  INFO 7944 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application server with eureka with status UP83 2018-09-20 10:16:17.881  INFO 7944 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Setting the eureka configuration..84 2018-09-20 10:16:17.881  INFO 7944 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka data center value eureka.datacenter is not set, defaulting to default85 2018-09-20 10:16:17.881  INFO 7944 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Eureka environment value eureka.environment is not set, defaulting to test86 2018-09-20 10:16:17.892  INFO 7944 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : isAws returned false87 2018-09-20 10:16:17.892  INFO 7944 --- [      Thread-13] o.s.c.n.e.server.EurekaServerBootstrap   : Initialized server context88 2018-09-20 10:16:17.892  INFO 7944 --- [      Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl    : Got 1 instances from neighboring DS node89 2018-09-20 10:16:17.892  INFO 7944 --- [      Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl    : Renew threshold is: 190 2018-09-20 10:16:17.892  INFO 7944 --- [      Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl    : Changing status to UP91 2018-09-20 10:16:17.908  INFO 7944 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8880 (http) with context path ''92 2018-09-20 10:16:17.909  INFO 7944 --- [      Thread-13] e.s.EurekaServerInitializerConfiguration : Started Eureka Server93 2018-09-20 10:16:17.910  INFO 7944 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 888094 2018-09-20 10:16:17.912  INFO 7944 --- [           main] c.sharp.forward.EurekaServerApplication  : Started EurekaServerApplication in 5.373 seconds (JVM running for 5.771)95 2018-09-20 10:16:21.748  INFO 7944 --- [nio-8880-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'96 2018-09-20 10:16:21.748  INFO 7944 --- [nio-8880-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started97 2018-09-20 10:16:21.766  INFO 7944 --- [nio-8880-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms98 2018-09-20 10:17:07.667  INFO 7944 --- [io-8880-exec-10] c.n.e.registry.AbstractInstanceRegistry  : Registered instance SERVER2/hh-PC:server2:8882 with status UP (replication=false)99 2018-09-20 10:17:08.688 ERROR 7944 --- [et_127.0.0.1-18] c.n.e.cluster.ReplicationTaskProcessor   : It seems to be a socket read timeout exception, it will retry later. if it continues to happen and some eureka node occupied all the cpu time, you should set property 'eureka.server.peer-node-read-timeout-ms' to a bigger value100
101 com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out102 at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]103 at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.9.3.jar:1.9.3]104 at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.9.3.jar:1.9.3]105 at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]106 at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]107 at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]108 at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1]109 at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116) ~[eureka-core-1.9.3.jar:1.9.3]110 at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:80) ~[eureka-core-1.9.3.jar:1.9.3]111 at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187) [eureka-core-1.9.3.jar:1.9.3]112 at java.lang.Thread.run(Unknown Source) [na:1.8.0_171]113 Caused by: java.net.SocketTimeoutException: Read timed out114 at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_171]115 at java.net.SocketInputStream.socketRead(Unknown Source) ~[na:1.8.0_171]116 at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]117 at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]118 at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:161) ~[httpcore-4.4.10.jar:4.4.10]119 at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82) ~[httpcore-4.4.10.jar:4.4.10]120 at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:278) ~[httpcore-4.4.10.jar:4.4.10]121 at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.6.jar:4.5.6]122 at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.6.jar:4.5.6]123 at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.10.jar:4.4.10]124 at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:286) ~[httpcore-4.4.10.jar:4.4.10]125 at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257) ~[httpclient-4.5.6.jar:4.5.6]126 at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:230) ~[httpclient-4.5.6.jar:4.5.6]127 at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.10.jar:4.4.10]128 at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.10.jar:4.4.10]129 at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684) ~[httpclient-4.5.6.jar:4.5.6]130 at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486) ~[httpclient-4.5.6.jar:4.5.6]131 at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.6.jar:4.5.6]132 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.6.jar:4.5.6]133 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.6.jar:4.5.6]134 at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar:1.19.1]135 ... 10 common frames omitted136
137 2018-09-20 10:17:08.693 ERROR 7944 --- [et_127.0.0.1-16] c.n.e.cluster.ReplicationTaskProcessor   : It seems to be a socket read timeout exception, it will retry later. if it continues to happen and some eureka node occupied all the cpu time, you should set property 'eureka.server.peer-node-read-timeout-ms' to a bigger value138
139 com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out140 at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]141 at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.9.3.jar:1.9.3]142 at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.9.3.jar:1.9.3]143 at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]144 at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]145 at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]146 at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1]147 at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116) ~[eureka-core-1.9.3.jar:1.9.3]148 at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:80) ~[eureka-core-1.9.3.jar:1.9.3]149 at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187) [eureka-core-1.9.3.jar:1.9.3]150 at java.lang.Thread.run(Unknown Source) [na:1.8.0_171]151 Caused by: java.net.SocketTimeoutException: Read timed out152 at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_171]153 at java.net.SocketInputStream.socketRead(Unknown Source) ~[na:1.8.0_171]154 at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]155 at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]156 at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:161) ~[httpcore-4.4.10.jar:4.4.10]157 at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82) ~[httpcore-4.4.10.jar:4.4.10]158 at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:278) ~[httpcore-4.4.10.jar:4.4.10]159 at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.6.jar:4.5.6]160 at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.6.jar:4.5.6]161 at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.10.jar:4.4.10]162 at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:286) ~[httpcore-4.4.10.jar:4.4.10]163 at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257) ~[httpclient-4.5.6.jar:4.5.6]164 at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:230) ~[httpclient-4.5.6.jar:4.5.6]165 at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.10.jar:4.4.10]166 at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.10.jar:4.4.10]167 at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684) ~[httpclient-4.5.6.jar:4.5.6]168 at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486) ~[httpclient-4.5.6.jar:4.5.6]169 at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.6.jar:4.5.6]170 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.6.jar:4.5.6]171 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.6.jar:4.5.6]172 at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar:1.19.1]173 ... 10 common frames omitted174
175 2018-09-20 10:17:17.897  INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms176 2018-09-20 10:18:17.897  INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms177 2018-09-20 10:19:17.898  INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms178 2018-09-20 10:20:17.898  INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms179 2018-09-20 10:21:17.899  INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms180 2018-09-20 10:22:17.899  INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 0ms

View Code

这是因为服务向自己注册的原因,不用理会

此时查看控制台发现三个服务均注册上了server2

如果三个服务都注册自己,则三个均注册上来,贴出其中一个图看看

这时,eureka的高可用服务其实已经配置好了,我们进行一个注册服务,还是之前的client服务,配置文件修改后如下:

1 spring:2 application:3 name: client4 server:5   port: 8889
6 eureka:7 client:8     eureka-server-port: 8889
9     register-with-eureka: true
10     service-url:11       defaultZone: http://127.0.0.1:8880/eureka/,http://127.0.0.1:8881/eureka/,http://127.0.0.1:8882/eureka/

启动服务,三台服务均注册上

然后我们请求服务方地址,成功

此时验证高可用性,我们停掉其中的1~2台服务,再次访问,仍然OK,说明高可用配置的成功,接下来我们把client的yml文件注册地址只保留一个8880,再次测试,发现只注册一个三个都会同步,当宕掉8880和其他任意一个,仍然可以成功调用接口,可见其高可用性能得到了较好保证。

springCloud 之 Eureka高可用配置相关推荐

  1. springcloud之Eureka高可用和用户认证

    Eureka进阶 一.Eureka Server的高可用 因为单节点Eureka Server并不适合线上生产环境,Eureka Client会定时连接Eureka Server,获取服务注册列表中到 ...

  2. SpringCloud Eureka Client和Server侧配置及Eureka高可用配置

    一.Eureka注册中心和客户端配置Demo. 1.Server端 a.使用Idea创建Spring项目,如下所示: b.相关配置 application.yaml配置文件如下: # eureka本身 ...

  3. 白话SpringCloud | 第三章:服务注册与发现-高可用配置(Eureka)-下

    2019独角兽企业重金招聘Python工程师标准>>> 前言 上一章节,讲解了在单机模式下的服务注册与发现的相关知识点及简单示例.而在实际生产或者在这种微服务架构的分布式环境中,需要 ...

  4. springcloud 入门 10 (eureka高可用)

    eureka高可用: 说白了,就是加一个实例作为原实例的备份,然后一起对外提供服务.这样可以保证在一台机器宕机的时候,整个系统不会死掉.保证其继续对外服务. eureka的集群化: 服务注册中心Eur ...

  5. SpringCloud注册中心高可用搭建

    转载自 SpringCloud注册中心高可用搭建 Spring Cloud的注册中心可以由Eureka.Consul.Zookeeper.ETCD等来实现,这里推荐使用Spring Cloud Eur ...

  6. 构建eureka高可用服务

    大家有没有注意到一个点,我们这里部署的eureka是单点的,就一台,我们只有一个实例,我们之前学过eureka的高可用,那如何在rancher上部署eureka高可用呢,如何在java -jar做到高 ...

  7. 搭建Eureka高可用集群

    做的快哭了已经 文章目录 Eureka可用高集群的搭建 一.Eureka的工作原理 二.Eureka中服务提供者与服务消费者的关系 三.搭建Eureka-Server和Eureka-Client 四. ...

  8. linux集群架构(一),集群概述、高可用配置

    2019独角兽企业重金招聘Python工程师标准>>> linux集群概述 根据功能划分为两大类:高可用和负载均衡 高可用集群通常为两台服务器,一台工作,另外一台作为冗余,当提供服务 ...

  9. 2008r2文件服务器高可用,Windows Server 2012 R2 文件服务器安装与配置07 之文件服务器高可用配置DFS...

    今天和大家分享的是关于文件服务器高可用配置,简单一点说就是当一台机宕机的时候,另一台文件服务器可以继续为你提供文件服务,以保证业务的正常使用. 分布式文件系统是作为文件服务角色的一种角色服务而实现的. ...

  10. Nginx+keepalived高可用配置实战

    1.整体架构图如下 2.环境准备 今天所配置的是keepalived+nginx 的负载均衡 下载keepalived软件 [root@LB01 tools]# wget http://www.kee ...

最新文章

  1. 目标板挂载NFS方法及错误解决
  2. 笔记本电脑键盘切换_全球首款折叠屏笔记本电脑ThinkPad X1 Fold:5G高速互联拥抱PC场景融合时代...
  3. 抽象工厂和工厂方法示例_抽象工厂设计模式示例
  4. django默认缓存是多大_半个月搞定Django绝不是空话
  5. Spring 配置文件加载原理
  6. 学校计算机实验室实践心得,实验室实践心得体会
  7. 设置元素的高度为百分比,结果不起作用的解决方法
  8. 最大报销额(HDU 1864)
  9. spring-第十八篇之spring AOP基于XML配置文件的管理方式
  10. 【2021】15天通过阿里云云计算架构师认证考试(ACE)- 经验分享
  11. 浅析NDI 5(一)基于NDI 5如何打造全球NDI演播室?
  12. 电气工程类期刊最新数据+2019年电气工程领域的中文期刊(EI期刊+中文核期刊)
  13. 【持续更新】机器学习特征工程实用技巧大全
  14. Android与uni-app 互相通信案例(包含源代码)
  15. pyhon——进程线程、与协程基础概述(同步异步)
  16. springboot打包时提示There are test failures.解决方法
  17. 山寨不了你,就要使出混身解数置你于死地,某多只是马前卒
  18. English Learning - L2-16 英音地道语音语调 语调 2023.04.20 周四
  19. Splart-Allmaras湍流模型及MATLAB编程~
  20. 怎么把url(网址)转为二维码?

热门文章

  1. 技术分享 | 基于人工势场法的无人机,机间避撞实现
  2. Unity--初识Live2D Cubism以及通过代码来实现Live2D模型的基本功能(二)
  3. fh 幅频特性曲线怎么画fl_数学老师用“函数曲线”绘出美图 学生舍不得擦黑板。唉,这样的老师我没有遇到!...
  4. java web外文文献_JAVAWeb外文文献毕业设计.doc
  5. 计算机显示器出现黑屏分析
  6. MicroSip客户端编译、运行
  7. 高级与低级编程语言的解释,哪一种更容易上手?
  8. AI 机器视觉/计算机视觉系统在行业中的应用
  9. java详细教程_java超详细教程适合初学者深入掌握Java知识.ppt
  10. 天宇物流公司创业计划书