<spring-cloud.version>Dalston.SR1</spring-cloud.version> 这个版本有可能不好使,不确定,
所以我改成了 <spring-cloud.version>Edgware.SR5</spring-cloud.version>
直接贴出我好使的配置:
maven pom
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.13.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Edgware.SR5</spring-cloud.version>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
阿里云两台服务器 内网地址:176.13.0.75 176.13.0.76
1、在75配置映射 176.13.0.76 eureka76.com 这一步不懂的百度host 配置
在76 配置映射 176.13.0.75 eureka75.com
2、75机器上的bootstrap.yml
server:
port: 16375
eureka:
instance:
hostname: eureka75.com
appname: ${spring.application.name}
prefer-ip-address: false
client:
fetch-registry: true
register-with-eureka: true
serviceUrl:
defaultZone: http://${security.user.name}:${security.user.password}@eureka76.com:16376/eureka/
server:
enable-self-preservation: false #关闭自我保护
3、76机器上的bootstrap.yml
eureka:
instance:
hostname: eureka76.com
appname: ${spring.application.name}
prefer-ip-address: false
client:
fetch-registry: true
register-with-eureka: true
serviceUrl:
defaultZone: http://${security.user.name}:${security.user.password}@eureka75.com:16375/eureka/
server:
enable-self-preservation: false #关闭自我保护
4、这几个配置都很重要
网上说:
hostname 要用域名,我以前用的 ip 不好使
appname 要和 application.name 一样
prefer-ip-address 是否用ip作为注册中心地址,把他关闭 设置为 false
fetch-registry: true
register-with-eureka: true
defaultZone 这个地址设置为 其他注册中心地址,注意路径上的域名和端口
5、我查看过的博客
网上搜了很多,有几篇帮助很大,下面相关链接附上:
https://www.jianshu.com/p/59c54ccc6ba6
https://www.cnblogs.com/flying607/p/8317128.html
我采用这种配置文件方式好使了:https://blog.csdn.net/j080624/article/details/80507927