spring cloud+docker一些杂项说明

一、springcloud不一样主机,相同端口号的eureka client的注册问题,我这里一直只能注册上一个,没找到特别好的办法,为了不不重复编译,只能这么处理了。spring

peer1的配置文件以下:docker

spring.application.name=hello-service
server.port=8080

eureka.client.service-url.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka
eureka.instance.prefer-ip-address=true
eureka.instance.hostname= ${spring.cloud.client.ipAddress}
eureka.instance.instance-id=${eureka.instance.hostname}:${server.port}

logging.path=/var/log/
logging.level.root=info

peer2的配置文件以下:app

spring.application.name=hello-service
server.port=8081

eureka.client.service-url.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka
eureka.instance.prefer-ip-address=true
eureka.instance.hostname= ${spring.cloud.client.ipAddress}
eureka.instance.instance-id=${eureka.instance.hostname}:${server.port}

logging.path=/var/log/
logging.level.root=info

启动的时候加这个--spring.profiles.active=peer1或peer2url

这两个是不一样端口的配置文件,若是谁有同一个端口的解决方案,请告诉我,谢谢!spa

二、另外我是docker装载的,日志文件放在/var/log里面,会自动生成spring.log日志

用docker启动的时候用卷 如 -v /home/log:/var/log这样就能够在原系统中直接拿到spring.log文件,而不须要进入docker内部了。server

相关文章
相关标签/搜索