Some miscellaneous instructions for spring cloud+docker

1. The registration problem of the eureka client with the same port number on different hosts of springcloud. I can only register the previous one here, and I have not found a particularly good way. In order to avoid repeated compilation, this is the only way to deal with it.

The configuration file of peer1 is as follows:

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

The configuration file of peer2 is as follows:

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

Add this --spring.profiles.active=peer1 or peer2 when starting

These two are config files for different ports, if anyone has a solution for the same port, please let me know, thanks!

2. In addition, I loaded it by docker, the log file is placed in /var/log, and spring.log will be automatically generated

When starting with docker, use a volume such as -v /home/log:/var/log so that the spring.log file can be directly obtained in the original system without entering the docker.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325474936&siteId=291194637