Registry Replicas

 show more

Configuring replication

Here is the Spring Cloud Netflix official documentation for configuring replication:

Standalone mode

By default, the JHipster Registry works in standalone mode: you will see one replica in this screen, which the current standalone registry: the address of the replica should be the same as the address of your server.

Peer aware mode

The JHipster Registry also works in "peer aware mode", and provides for this two pre-defined Spring profiles, named "peer1" and "peer2". Those profiles are mostly here as working examples, as you will probably want something different in production.

Those profiles trigger some specific Spring Boot configurations, which are available in your registry's src/main/resources/config folder.

Those profiles expect to have 2 different hosts, one for each replica: this is required by Eureka, which expects to have replicas on different servers. If you want to run this on your local machine, you need to point those 2 hostnames to your local address, for example on a Unix/MacOSX system, edit /etc/hosts to add those lines:

# Eureka peers
127.0.0.1	eureka-peer-1
127.0.0.1	eureka-peer-2

Running a peer-aware development cluster is then just a matter of running:

Here is a sample working configuration for "peer1". Note that its "serviceUrl" points to "peer2":

server:
    port: 8761
eureka:
    instance:
        hostname: eureka-peer-1
    server:
        enable-self-preservation: true
        registry-sync-retry-wait-ms: 500
        a-sgcache-expiry-timeout-ms: 60000
        eviction-interval-timer-in-ms: 30000
        peer-eureka-nodes-update-interval-ms: 30000
        renewal-threshold-update-interval-ms: 15000
    client:
        fetch-registry: true
        register-with-eureka: true
        serviceUrl:
            defaultZone: http://admin:admin@eureka-peer-2:8762/eureka/

Here is the same configuration for "peer2", which has a "serviceUrl" pointing to "peer1":

server:
    port: 8762
eureka:
    instance:
        hostname: eureka-peer-2
    server:
        enable-self-preservation: true
        registry-sync-retry-wait-ms: 500
        a-sgcache-expiry-timeout-ms: 60000
        eviction-interval-timer-in-ms: 30000
        peer-eureka-nodes-update-interval-ms: 30000
        renewal-threshold-update-interval-ms: 15000
    client:
        fetch-registry: true
        register-with-eureka: true
        serviceUrl:
            defaultZone: http://admin:admin@eureka-peer-1:8761/eureka/