1. The principle of availability
Each Eureka Eureka only need to specify additional multiple addresses in the configuration can be achieved in a cluster built.
For example:
Suppose we have a master and slaveone two machines, you need to do is:
- The master register to slaveone above.
- The slaveone registered to master it.
If it is three machines, and so on:
- The master register to slaveone and slavetwo above.
- The slaveone registered to the master and slavetwo above.
- The slavetwo registered to the master and slaveone above.
2. build step
Configuration and eureka registry - to build a simple version of the same, except that an increase of more application.yml different environments.
Addition of application-master.yml:
server:
port=8761
# 指向从节点的Eureka
eureka:
client:
serviceUrl:
defaultZone: http://username:password@localhost:8762/eureka/
添加application-slaveone.yml:
server:
port=8762
# 指向从节点的Eureka
eureka:
client:
serviceUrl:
defaultZone: http://username:password@localhost:8761/eureka/
Need to be deployed on many machines, add the number of profiles
Add the application.yml follows:
spring:
profiles
active: master
After the deployment is successful, add startup parameters:
--spring.profiles.active= slaveone
3. Note
When the register has a plurality of nodes, the need to modify the configuration of the plurality of nodes eureka.client.serviceUrl.defaultZone addresses, a plurality of addresses separated by commas:
eureka:
client:
serviceUrl:
defaultZone: http://username:password@localhost:8761/eureka/,http://username:password@localhost:8762/eureka/