Eureka Server多节点部署
1.pom文件
springboot版本不要太高会报错,我这里用的2.0.1的版本
2.配置文件
---
spring:
application:
name: ad-eureka
profiles: server1
server:
port: 8000
eureka:
instance:
hostname: server1
prefer-ip-address: false
client:
service-url:
defaultZone: http://server2:8001/eureka/,http://server3:8002/eureka/
---
spring:
application:
name: ad-eureka
profiles: server2
server:
port: 8001
eureka:
instance:
hostname: server2
prefer-ip-address: false
client:
service-url:
defaultZone: http://server1:8000/eureka/,http://server3:8002/eureka/
---
spring:
application:
name: ad-eureka
profiles: server3
server:
port: 8002
eureka:
instance:
hostname: server3
prefer-ip-address: false
client:
service-url:
defaultZone: http://server1:8000/eureka/,http://server2:8001/eureka/
3.修改host文件
4.简单的项目打包
先进入项目文件下启动cmd
执行命令
mvn clean package -Dmaven.test.skip=true -U
启动第一个服务,这里会报错,这时候不存在servr2和server3
当然可以以相同的方式启动server2,把最后的server1改成server2或server3
java -jar ad-eureka-1.0-SNAPSHOT.jar --spring.profiles.active=server1
不过还是能进入服务注册中心就是了
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 时间海!
评论