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

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

8880

 #本项目端口
server:
port: 8880
#定义应用名称为order
spring:
application:
name: server
#服务注册中心实例主机名
eureka:
instance:
hostname: host
client:
#是否向注册中心注册自己
register-with-eureka: false
#是否获取注册表
fetch-registry: false
service-url:
defaultZone: http://127.0.0.1:8881/eureka/,http://127.0.0.1:8882/eureka/

8881

 #本项目端口
server:
port: 8881
#定义应用名称为order
spring:
application:
name: server1
#服务注册中心实例主机名
eureka:
instance:
hostname: host1
client:
#是否向注册中心注册自己
register-with-eureka: false
#是否获取注册表
fetch-registry: false
service-url:
defaultZone: http://127.0.0.1:8880/eureka/,http://127.0.0.1:8882/eureka/

8882

 server:
port: 8882
#定义应用名称为order
spring:
application:
name: server2
#服务注册中心实例主机名
eureka:
instance:
hostname: host2
client:
#是否向注册中心注册自己
register-with-eureka: true
#是否获取注册表
fetch-registry: false
#服务地址
service-url:
defaultZone: http://127.0.0.1:8880/eureka/,http://127.0.0.1:8881/eureka/

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

 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 hierarchy
2018-09-20 10:16:13.286 INFO 7944 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
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) . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE) 2018-09-20 10:16:13.560 INFO 7944 --- [ main] c.sharp.forward.EurekaServerApplication : No active profile set, falling back to default profiles: default
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@4ec4f3a0
2018-09-20 10:16:14.384 INFO 7944 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=86aa96a4-8d41-33fd-af49-92950d537d77
2018-09-20 10:16:14.399 INFO 7944 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
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)
2018-09-20 10:16:14.932 INFO 7944 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8880 (http)
2018-09-20 10:16:14.951 INFO 7944 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-09-20 10:16:14.951 INFO 7944 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
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;;.]
2018-09-20 10:16:15.067 INFO 7944 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-09-20 10:16:15.067 INFO 7944 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1493 ms
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.
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.
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@7443d25a
2018-09-20 10:16:16.136 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-20 10:16:16.136 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2018-09-20 10:16:16.136 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-20 10:16:16.136 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-09-20 10:16:16.136 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-20 10:16:16.137 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpTraceFilter' to: [/*]
2018-09-20 10:16:16.137 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'servletContainer' to urls: [/eureka/*]
2018-09-20 10:16:16.137 INFO 7944 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
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'
2018-09-20 10:16:16.251 INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-09-20 10:16:16.252 INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-09-20 10:16:16.348 INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-09-20 10:16:16.348 INFO 7944 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-09-20 10:16:16.561 WARN 7944 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
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.
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 [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
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@4ec4f3a0
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)
2018-09-20 10:16:16.823 INFO 7944 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
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>)
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>)
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]
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]
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/]
2018-09-20 10:16:17.167 INFO 7944 --- [ main] o.s.w.s.v.f.FreeMarkerConfigurer : ClassTemplateLoader for Spring macros added to FreeMarker configuration
2018-09-20 10:16:17.321 INFO 7944 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2018-09-20 10:16:17.353 INFO 7944 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2018-09-20 10:16:17.353 INFO 7944 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2018-09-20 10:16:17.362 INFO 7944 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1537409777361 with initial instances count: 0
2018-09-20 10:16:17.409 INFO 7944 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...
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/]
2018-09-20 10:16:17.612 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-09-20 10:16:17.612 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-09-20 10:16:17.612 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-09-20 10:16:17.612 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-09-20 10:16:17.696 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-09-20 10:16:17.696 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-09-20 10:16:17.696 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-09-20 10:16:17.696 INFO 7944 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
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/
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/
2018-09-20 10:16:17.762 INFO 7944 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []
2018-09-20 10:16:17.763 INFO 7944 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized
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'
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>)
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>)
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)
2018-09-20 10:16:17.831 INFO 7944 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
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 exposure
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 exposure
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 exposure
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]
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]
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]
2018-09-20 10:16:17.863 INFO 7944 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2018-09-20 10:16:17.867 INFO 7944 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application server with eureka with status UP
2018-09-20 10:16:17.881 INFO 7944 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..
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 default
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 test
2018-09-20 10:16:17.892 INFO 7944 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false
2018-09-20 10:16:17.892 INFO 7944 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context
2018-09-20 10:16:17.892 INFO 7944 --- [ Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2018-09-20 10:16:17.892 INFO 7944 --- [ Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2018-09-20 10:16:17.892 INFO 7944 --- [ Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
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 ''
2018-09-20 10:16:17.909 INFO 7944 --- [ Thread-13] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2018-09-20 10:16:17.910 INFO 7944 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8880
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)
2018-09-20 10:16:21.748 INFO 7944 --- [nio-8880-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-09-20 10:16:21.748 INFO 7944 --- [nio-8880-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-09-20 10:16:21.766 INFO 7944 --- [nio-8880-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
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)
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 value com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.9.3.jar:1.9.3]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.9.3.jar:1.9.3]
at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116) ~[eureka-core-1.9.3.jar:1.9.3]
at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:80) ~[eureka-core-1.9.3.jar:1.9.3]
at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187) [eureka-core-1.9.3.jar:1.9.3]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_171]
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_171]
at java.net.SocketInputStream.socketRead(Unknown Source) ~[na:1.8.0_171]
at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]
at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:161) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:278) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:286) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:230) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.6.jar:4.5.6]
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
... 10 common frames omitted 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 value com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48) ~[eureka-core-1.9.3.jar:1.9.3]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.9.3.jar:1.9.3]
at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116) ~[eureka-core-1.9.3.jar:1.9.3]
at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:80) ~[eureka-core-1.9.3.jar:1.9.3]
at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187) [eureka-core-1.9.3.jar:1.9.3]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_171]
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_171]
at java.net.SocketInputStream.socketRead(Unknown Source) ~[na:1.8.0_171]
at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]
at java.net.SocketInputStream.read(Unknown Source) ~[na:1.8.0_171]
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:161) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:278) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:286) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:230) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.10.jar:4.4.10]
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.6.jar:4.5.6]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.6.jar:4.5.6]
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
... 10 common frames omitted 2018-09-20 10:17:17.897 INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2018-09-20 10:18:17.897 INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2018-09-20 10:19:17.898 INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2018-09-20 10:20:17.898 INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2018-09-20 10:21:17.899 INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms
2018-09-20 10:22:17.899 INFO 7944 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 0ms

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

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

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

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

 spring:
application:
name: client
server:
port: 8889
eureka:
client:
eureka-server-port: 8889
register-with-eureka: true
service-url:
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. Spring Cloud(Dalston.SR5)--Eureka 注册中心高可用-服务提供和消费

    由于 Eureka 注册中心只是在内存中保存服务注册实例,并且没有将服务注册实例进行同步,因此我们需要对服务提供和消费进行调整,需要指定服务提供和消费的注册.服务发现的具体Eureka 注册中心配置, ...

  2. Eureka注册中心高可用集群配置

    Eureka高可用集群配置 当注册中心扛不住高并发的时候,这时候 要用集群来扛: 我们再新建两个module  microservice-eureka-server-2002  microservic ...

  3. Spring Cloud(Dalston.SR5)--Eureka 注册中心高可用搭建

    高可用集群 在微服务架构这样的分布式环境中,我们需要充分考虑发生故障的情况,所以在生产环境中必须对各个组件进行高可用部署,对与微服务和服务注册中心都需要高可用部署,Eureka 高可用实际上就是将自己 ...

  4. Eureka注册中心高可用及常用配置项

    一.前言 前面已经简单的介绍了 Eureka 注册中心的使用以及查看.下面将继续进行 Eureka 的说明以及应用. 二.Eureka 的高可用搭建 在实际生产项目中,为了保证服务的可用性,连续性,一 ...

  5. Spring Cloud Eureka 注册中心高可用机制

    一.Eureka 正常工作流程 Service 服务作为 Eureka Client 客户端需要在启动的时候就要向 Eureka Server 注册中心进行注册,并获取最新的服务列表数据. Eurek ...

  6. Spring Cloud 之服务注册中心高可用

    服务注册中心高可用 服务注册中心 eureka-server 高可用实施 版本 Spring Boot 版本 # Spring Boot 版本: <parent> <groupId& ...

  7. SpringCloud微服务实战一:Spring Cloud Eureka 服务发现与注册中心(高可用实列为两个注册中心)

    微服务架构: 微服务架构的核心思想是,一个应用是由多个小的.相互独立的.微服务组成,这些服务运行在自己的进程中,开发和发布都没有依赖.不同服务通过一些轻量级交互机制来通信,例如 RPC.HTTP 等, ...

  8. Spring cloud之Eureka(二)注册中心高可用

    背景 在实际的生产环境中,注册中心如果只有一个,是很危险的,当这个注册中心由于各种原因不能提供正常服务或者挂掉时,整个系统都会崩溃,这是很致命的的,所以在Spring cloud 设计之初就考虑到了注 ...

  9. springcloud之Eureka注册中心

    参考博客:https://www.cnblogs.com/ityouknow/p/6854805.html 背景: Eureka是Netflix开源的一款提供服务注册和发现的产品,它提供了完整的Ser ...

随机推荐

  1. MySQL 远程连接问题 (Linux Server)

    Mysql Workbench 连接Ubuntu上的Mysql时报如下错误: 原因:查看  /etc/mysql/mysql.conf.d/mysqld.cnf # # Instead of skip ...

  2. Thread的join方法

    一个线程在执行的过程中,可能调用另一个线程,前者可以称为调用线程,后者成为被调用线程. Thread.Join方法的使用场景:调用线程挂起,等待被调用线程执行完毕后,继续执行. 如下案列: 当NewT ...

  3. 解决idea创建maven项目无java

    在idea上创建maven-archetype-webapp项目后发现无法创建java文件然后参考此博客得以解决 https://www.cnblogs.com/mywangpingan/p/9448 ...

  4. selenium webdriver 实例化浏览器对象

    public static FirefoxDriver FFSetting() { System.setProperty("webdriver.firefox.bin", &quo ...

  5. Hibernate框架报错:org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.mikey.hibernate.domain.Person.pid

    报错信息 org nate.PropertyAccessException:IllegalArgumentException在调用com.mikey.Hibernate.domain.Person.p ...

  6. PPT页面切换动画

    想要自己的PPT更加炫酷一些的话,可以再给每个页面的切换,加上动画效果. 第一步,按住ctrl键,鼠标点击选择想要增加切换动画的页面,然后点击菜单栏的“切换” 第二步,在切换菜单下面选择具体的切换效果 ...

  7. spring boot 中容器 Jetty、Tomcat、Undertow

    spring boot 中依赖tomcat <dependency> <groupId>org.springframework.boot</groupId> < ...

  8. 【PAT甲级】1031 Hello World for U (20 分)

    题意: 输入一个字符串长度为5~80,以'U'型输出,使得底端一行字符数量不小于侧面一列,左右两列长度相等. trick: 不把输出的数组全部赋值为空格为全部答案错误,可能不赋值数组里值为0,赋值后是 ...

  9. #P2341 [HAOI2006]受欢迎的牛 题解

    题目描述 每头奶牛都梦想成为牛棚里的明星.被所有奶牛喜欢的奶牛就是一头明星奶牛.所有奶 牛都是自恋狂,每头奶牛总是喜欢自己的.奶牛之间的“喜欢”是可以传递的——如果A喜 欢B,B喜欢C,那么A也喜欢C ...

  10. [经验] 关于 Java 中的非空判断

    在写项目的时候, 遇到一个问题 假设有一个控制层接口为: @ResponseBody @RequestMapping(value = "test", method = Reques ...