- Eureka Server high availability (HA) for Production
mvn clean install
mvn clean package -DskipTests=true
java -jar target/eureka-server-0.0.1-SNAPSHOT.jar
java -jar -Dspring.profiles.active=DEV-PRIMARY target/eureka-server-0.0.1-SNAPSHOT.jar
java -jar -Dspring.profiles.active=DEV-SECONDARY target/eureka-server-0.0.1-SNAPSHOT.jar
java -jar -Dspring.profiles.active=DEV-TERTIARY target/eureka-server-0.0.1-SNAPSHOT.jar
Create docker layered image using the following command
mvn package
chmod -R 777 target/
mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
chmod -R 777 target/
docker build -t eureka-server .
Run the image (with desired)
docker run --name primary --restart always -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" eureka-server
docker run --name secondary --restart always -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" eureka-server
docker run --name tertiary --restart always -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" eureka-server
# With local log
docker run --name primary --restart always --log-driver local --log-opt max-size=10m -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" eureka-server
docker run --name secondary --restart always --log-driver local --log-opt max-size=10m -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" eureka-server
docker run --name tertiary --restart always --log-driver local --log-opt max-size=10m -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" eureka-server
# Without log
docker run --name primary --restart always --log-driver none -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" eureka-server
docker run --name secondary --restart always --log-driver none -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" eureka-server
docker run --name tertiary --restart always --log-driver none -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" eureka-server
# If we use ${"HOST"} for ip-address
docker run --name primary --restart always -d -p 8761:8761 -e "SPRING_PROFILES_ACTIVE=DEV-PRIMARY" -e "HOST=172.19.250.7" eureka-server
docker run --name secondary --restart always -d -p 8762:8762 -e "SPRING_PROFILES_ACTIVE=DEV-SECONDARY" -e "HOST=172.19.250.8" eureka-server
docker run --name tertiary --restart always -d -p 8763:8763 -e "SPRING_PROFILES_ACTIVE=DEV-TERTIARY" -e "HOST=172.19.250.9" eureka-server
Add the below line in crontab -e
@reboot /{path-to-eureka-server-script}/eureka-server.sh {ENV}
Example:
@reboot /home/thirumal/git/eureka-server/eureka-server.sh DEV-PRIMARY
Note: Add cd /path-to-repo
to the shell script (1'st line)
- Make sure
eureka.instance.hostname:
is same aseureka.client.serviceUrl.defaultZone
. Check how it's configured inPRO environment
- If you want some of cluster to be independent set
eureka.client.fetchRegistry
isfalse
. That is, don't want to fetch details from other cluster. CheckUDEV
environmentUDEV-SECONDARY
http://localhost:8761/swagger-ui/index.html http://localhost:8761/api-docs
thirumal:thirumal
[http://localhost:8761/actuator/prometheus](Prometheus actuator endpoint)
docker run -d -p 9090:9090 -v /Users/thirumal/git/eureka-server/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
- Client registering with
Public IP address
instead of private.-
Solution: Need to hard code the IP address. Example
eureka: instance: prefer-ip-address : true ip-address : xx.xx.xx.xx
-