Eureka 集群之间的不能同步

2021-02-23 18:38发布

最近在学习 Spring Cloud,学到 Eureka 的时候遇到一个问题,在搭建集群的时候,两个 Eureka 服务之间不能同步。

配置如下:

Eureka 7001 服务端 配置:

server: port: 7001 eureka: instance: hostname: eureka7001.com client: register-with-eureka: false fetch-registry: false serviceUrl: defaultZone: http://eureka7002.com:7002/erueka/

Eureka 7002 服务端 配置:

 

server: port: 7002 eureka: instance: hostname: eureka7002.com client: register-with-eureka: false fetch-registry: false serviceUrl: defaultZone: http://eureka7001.com:7001/erueka/

客户端服务配置:

 

server: port: 8001 spring: application: name: cloud-payment-service datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/db2020?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai username: root password: Cxy666$#21 mybatis: type-aliases-package: com.cxy.springcloud.entities configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl eureka: client: register-with-eureka: true fetch-registry: true serviceUrl: defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/ #defaultZone: http://eureka7002.com:7002/eureka instance: instance-id: payment8001 prefer-ip-address: true logging: level: com.cxy.springboot: debug

现象 :

 1. 两个Eureka服务端启动正常,没有报错。 并且在页面上可以看见相互指向另外一个Eureka服务端。

 2. 8001 服务只能在 Eureka 7001 上面注册,在 Eureka 7002 上看不到 8001 服务。

 1.2 现象如下图

 3. 在启动了 8001 服务之后,Eureka 7001 会一直报错,错误信息如下:

2021-02-23 13:48:13.953 WARN 14472 --- [reka7002.com-18] c.n.eureka.util.batcher.TaskExecutors : Discarding 1 tasks of TaskBatchingWorker-target_eureka7002.com-18 due to permanent error 2021-02-23 13:48:43.960 ERROR 14472 --- [reka7002.com-18] c.n.e.cluster.ReplicationTaskProcessor : Batch update failure with HTTP status code 404; discarding 1 replication tasks

 

这个问题已经困扰我几天了,期间一直在寻找答案,自己也思考了很久,就是不知道原因,望各位大神指定迷津,感激不尽!!!

1条回答
Remote Sensing_
1楼-- · 2021-02-23 19:00

检查一下 8001 服务里面的,defaultZone 地址配置里 【eureka】配置拼写