装置

version: "3.1"services:  consul:    image: consul    restart: always    container_name: consul    ports:      - 8500:8500      - 8300:8300      - 8301:8301      - 8302:8302      - 8600:8600/udp    volumes:      - ./data:/consul/data      - ./data:/consul/config    command: agent -dev -client=0.0.0.0

测试是否装置胜利

1.UI界面

关上HOSTNAME:8500能够进入到consul的UI页面

2.shell测试端口

$ dig @HOSTNAME -p 8600 consul.service.consul SRV# linux/mac下间接应用dig命令测试consul是否正确装置, HOSTNAMET替换对应地址

应用

服务注册

接口(PUT): http://192.168.4.5:8500/v1/ag...
参数:

{    "Name": "order-server", // 服务名称    "ID": "order", // 服务ID    "Tags": ["mxshop", "Felix", "good"], // 标签    "Address": "192.168.4.5",    "Port": 50051}

服务登记

接口(PUT): http://192.168.4.5:8500/v1/ag...
("order是服务ID")

健康检查