`

工作随笔 springcloud + consul 集群踩坑记

 
阅读更多

一、Consul 安装及集群配置

具体安装参考以文件介绍

https://my.oschina.net/u/593517/blog/2967475

 

&表示后台运行

服务端

 

./consul agent -server -bootstrap-expect 3 -data-dir=/usr/local/consul/data -node=server3 -bind=192.168.58.203 -client=0.0.0.0 &

 

客户端

 

./consul agent -client=0.0.0.0 -data-dir=/usr/local/consul/data -node=client-1 -ui -join 192.168.58.199 &
 

二、Spring cloud 配置

  添加application.yml配置文件

spring:
  cloud:
    consul:
      host: 192.168.58.201  #集群服务器客户端ID,不是本地local
      port: 8500
      discovery:
        register: true
        healthCheckPath: /actuator/health
        healthCheckInterval: 15s
        instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
   

  启动服务异常:

   出现连接错误:提示无法连接到本地localhost,application.yml 已经配置了开发环境的地址和端口,为什么还一直连接的是本地?

 解决办法:

  经过排查调试,把application.yml 改成了 bootstrap.yml 就可以启动服务并注册成功。

   

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics