consul 操作

常见命令

consul agent -dev 该模式下,数据不会持久化
consul agent -dev -ui 会伴随开启一个ui,在localhost:8500
consul members 查看运行中的consul节点
consul join x.x.x.x:y 在另一台服务器开启服务节点后,再join到主服务
consul leave 另一台服务器consul离开主节点
consul force-leave 主节点挂了时,强退
consul reload 重载consul服务,需要在consul未停止时运行

consul agent -dev -config-dir=./consul.d 监控配置文件,开启服务,测试模式
配置文件样例:
helloworld.json

{
    "service": {
	    "name": "web", 
		"tags": ["golang"], 
		"port": 8088
	}
}

正式下

consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -node=agent-one -bind=172.20.20.10 -enable-script-checks=true -config-dir=/etc/consul.d

参数解析

-dev 声明为测试模式,不会持久化数据,即不需要设定data-dir
-server 声明为server节点,一个集群只能有1个server,不能多也不能少,其他的都为client,不带-server tag即可
-config-dir 绑定一些业务服务,该路径下,存在类似helloworld.json服务配置config-dir=/etc/consul.d
-node 节点名称,默认为机器名,可以手动指定 -node=agent-1
-bootstrap-expect server节点还需要等待几个子节点加入,-bootstrap-expect=1
-data-dir 在非测试模式下,需要持久化数据,会存放在该路径,-data-dir=/tmp/consul
-enable-script-checks=true 据说是用来跑脚本,达到健康查询之类的效果,不明0 0

你可能感兴趣的:(go)