application.yml:
eureka:
client:
service-url:
defaultZone: http://114.55.229.69:8761/eureka
register-with-eureka: false #自身不在eureka上注册
server:
enable-self-preservation: false #关闭自我保护(客户端跟服务端长时间连不上,eureka控制台上有红色警告,开发环境设置成false,线上为true)
instance:
hostname: localhost #跳转地址
spring:
application:
name: eureka-server
server:
port: 8761
EurekaApplication:
package com.wangfajun;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer //Eureka服务端
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
Tip:Eureka服务端高可用,生产上建议至少两台以上,相互注册即可
服务端:机器:114.55.229.69,端口:8761机器上,defaultZone: http://118.178.144.64:8762/eureka,http://114.55.88.126:8763/eureka
机器:118.178.144.64,端口:8762机器上,defaultZone: http://114.55.229.69:8761/eureka,http://114.55.88.126:8763/eureka
机器:114.55.88.126,端口:8763机器上,defaultZone: http://114.55.229.69:8761/eureka,http://118.178.144.64:8762/eureka
客户端:http://114.55.229.69:8761/eureka,http://118.178.144.64:8762/eureka,http://114.55.88.126:8763/eureka