Qkyrie/modern-java-tutorials

how can I setup a eureka server cluster?

aximo opened this issue · 6 comments

aximo commented

assume the case:

there are 12 app run on a vm:
4 eureka server instance,8761/8762/8763/8764
4 eureka client,service provider 8080/8081/8082/8083
4 enreka client,service consume 8180/8181/8182/8183

I want to make 8761/8762 become a eureka sever cluster A,and 8763/8764 become to another cluster B
8080/8081, 8180/8181 connect to cluster A,
and 8082/8083,8182/8183 connect to cluster B

How can i config them?

thanks!

I'd do about the same thing as here, creating your 4 instances with @EnableEurekaServer on the ports you suggested, making your servers which are clustered point to the same dns resolution.

I suggest you follow this tutorial:
http://www.todaysoftmag.com/article/1429/micro-service-discovery-using-netflix-eureka

Make sure you use different local dns-names for your 2 clusters which both resolve to localhost. Two different ports won't suffice.

aximo commented

@Qkyrie , your article is very useful,thanks

I don't want to use dns(as we can't change dns of customer ) for eureka sever cluster,i want to use server list,i do it like this:

Node A

server:
  port: 8761
spring:
  application:
    name: Discovery-Server

eureka:
  instance:
    appname: ${spring.application.name}

  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://127.0.0.1:8761/eureka/,http://127.0.0.1:8762/eureka/

Node B

server:
  port: 8762
spring:
  application:
    name: Discovery-Server

eureka:
  instance:
    appname: ${spring.application.name}

  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://127.0.0.1:8761/eureka/,http://127.0.0.1:8762/eureka/

I run two nodes in my local vm. And I check the dashboard:

registered-replicas http://127.0.0.1:8761/eureka/, http://127.0.0.1:8762/eureka/
unavailable-replicas    http://127.0.0.1:8761/eureka/,http://127.0.0.1:8762/eureka/,
available-replicas  

Why it display two nodes in unavailable-replicas?

I use springboot 1.3.5-RELEASE and spring-eureka 1.2.2

I think you should initialize hostname of Eureka on each instance and implement H.A on local will be hard cause hostname will be no different, so Eureka can't detect it. It is so better to test it on 2 different machines.

Node A:

eureka.instance.hostname=[host's name of Node A]

Node B:

eureka.instance.hostname=[host's name of Node B]

with different hostname ,it will be ok

Hi guys. Thanks for the messages. Now let us consider a real scenario, when a services, which are exposed as Eurika server also are started on virtual nodes in, let us say AWS EC-2. An instance can be stopped and restarted for update or because of any cause. What would be eurika.client.service-url.defaultZone:... in Spring?