本篇幅主要还是根据自己在Consul实战中所遇到的问题进行的记录,当然相信问题可能不止于此,如果大家有遇到其它问题欢迎在下方留言,后续会进行汇总整理。
Consul Agent 启动报错
$ consul agent -dev -config-dir /etc/consul.d
==> Starting Consul agent...
==> Error starting agent: Failed to start Consul server: Failed to start RPC layer: listen tcp 127.0.0.1:8300: bind: address already in use
这个地址已经在使用了,说明你已经启动了。
命令ps -ef | grep consul查看使用情况
$ ps -ef | grep consul
root 16140 1 0 Jan20 ? 09:22:26 consul agent -dev
root 21018 19751 0 16:45 pts/0 00:00:00 grep --color=auto consul
如果想要关闭,执行命令kill -9 consul_pid强制杀死进程,第一个元素(上面的16140)就是进程id
查看集群成员报错
$ consul members
Error retrieving members: Get http://127.0.0.1:8500/v1/agent/members?segment=_all: dial tcp 127.0.0.1:8500: connect: connection refused
原因是由于在启动Consul时候绑定了IP地址,而默认的为127.0.0.1:8500,解决办法其实就是进行显示绑定,看以下用法:
$ consul members --http-addr 192.168.6.128:8500
N