服务发现(consul)搭建
服务发现(consul)搭建
下载最新版 consul
本人使用的版本为1.5.1,操作系统:window server 2008
consul部署的时候分为客户端和服务端,本次操作服务器2台,客户端1台
服务器2台:222.222.222.8,222.222.222.16
客户端:222.222.222.15
- 222.222.222.8 服务器配置文件(server.json):
{
"datacenter":"dcl",
"data_dir":"data",
"node_name":"consul-server01",
"server":true,
"bootstrap_expect":2,
"bind_addr":"222.222.222.8",
"client_addr":"0.0.0.0",
"ui":true
}
启动服务
用bat 使用 sc 命令 设置为window server 服务自动启动
sc create "zctgroup.consulserver" binpath= "e:\consul_1.5.1_windows_amd64\consul.exe agent -config-dir e:\consul_1.5.1_windows_amd64\server.json " start= auto
sc description "zctgroup.consulserver" "服务发现"
sc start "zctgroup.consulserver"
pause
- 222.222.222.16 服务器配置文件(server.json):
{
"datacenter":"dcl",
"data_dir":"data",
"node_name":"consul-server02",
"server":true,
"bind_addr":"222.222.222.16",
"client_addr":"0.0.0.0",
"ui":true,
"retry_join":["222.222.222.8"],
"retry_interval":"30s",
"rejoin_after_leave":true,
"start_join":["222.222.222.8"]
}
启动服务
用bat 使用 sc 命令 设置为window server 服务自动启动
sc create "zctgroup.consulserver" binpath= "e:\consul_1.5.1_windows_amd64\consul.exe agent -config-dir e:\consul_1.5.1_windows_amd64\server.json " start= auto
sc description "zctgroup.consulserver" "服务发现"
sc start "zctgroup.consulserver"
pause
- 222.222.222.15 客户端配置文件
{ "datacenter":"dcl", "data_dir":"data", "node_name":"consul-client01", "server":false, "bind_addr":"222.222.222.15", "client_addr":"222.222.222.15", "ui":true, "retry_join":["222.222.222.8"], "retry_interval":"30s", "rejoin_after_leave":true, "start_join":["222.222.222.8"] }
启动服务
用bat 使用 sc 命令 设置为window server 服务自动启动
sc create "zctgroup.consulclient" binpath= "e:\consul_1.5.1_windows_amd64\consul.exe agent -config-dir e:\consul_1.5.1_windows_amd64\server.json " start= auto
sc description "zctgroup.consulclient" "服务发现"
sc start "zctgroup.consulclient"
pause
查看结果:
上一篇: WebMagic 实现爬虫入门教程