Eureka realize service registration and discovery, plays a key role in the micro-Spring Cloud services must ensure their high availability, cluster achieved by nothing more than the conventional scheme. Here the local machine set up a pseudo-cluster environment, registered by means of two nodes with each other, and by the high availability standby synchronization data, actual production environment may have a plurality of nodes, the same principle. Simple steps as follows:
[step1]: Eureka profile follows
Spring:
file application:
name: Eureka-Cluster
---
Spring:
Profiles: Master
Server:
Port: 8761
Eureka:
instance:
hostname: Master
Client:
registerWithEureka: to false
fetchRegistry: to false
the serviceUrl :
defaultzone: HTTP: // Backup: 8762 / Eureka
---
the Spring:
Profiles: Backup
Server:
Port: 8762
Eureka:
instance:
hostname: Backup
Client:
registerWithEureka: to false
fetchRegistry: to false
the serviceUrl:
defaultzone: HTTP: // Master: 8761 / Eureka
NOTE: The difference here implemented by an analog port, and the need to configure the host machine information:
192.168.31.11 Master
192.168.31.11 Backup
[] step2: Packing deployment, and start
by mvn install packing, respectively, and then start,
Java -jar eureka.jar --spring.profiles.active = Master
Java -jar eureka.jar --spring.profiles.active = Backup
specifies spring.profiles startup. active standby analog achieved.
[Step3]: to access the test
access http://192.168.31.11:8761/ as follows:
Access http://192.168.31.11:8762/ as follows:
[] step4: Modify the client, the client test start
Eureka client modifies the registered address: eureka.client.serviceUrl.defaultZone: http: // master: 8761 / eureka /, http: // backup: 8762 / eureka /, start the client, and then were Eureka access to view, already registered to each node.
Eureka stopped one of these nodes, and then start again to see, you will find service information from the available nodes synchronized to the current node.
More Java learning materials may be concerned about: gzitcast