搭建Eureka集群
创建application-server1.yml文件
spring:
application:
name: ekuServer
---
spring:
profiles: server1
server:
port: 8761
eureka:
instance:
hostname: server1
client:
#声明自己是服务端 # 表示是否注册自身到eureka服务器
#registerWithEureka: false
# 是否从eureka上获取注册信息
#fetchRegistry: false
serviceUrl:
defaultZone: http://server2:8762/eureka/,http://server3:8763/eureka/
创建application-server2.yml文件
spring:
application:
name: ekuServer
---
spring:
profiles: server2
server:
port: 8762
eureka:
instance:
hostname: server2
client:
#声明自己是服务端
#registerWithEureka: false
#fetchRegistry: false
serviceUrl:
defaultZone: http://server1:8761/eureka/,http://server3:8763/eureka/
创建application-server3.yml文件
spring:
application:
name: ekuServer
---
spring:
profiles: server3
server:
port: 8763
eureka:
instance:
hostname: server3
client:
#声明自己是服务端
#registerWithEureka: false
#fetchRegistry: false
serviceUrl:
defaultZone: http://server1:8761/eureka/,http://server2:8762/eureka/
需要配一下host。
下面我们来看如何分别用server1,server2,server3三个配置启动三个server服务。
在idea右上角run,选择edit configrations