集群
下载consul包
https://www.consul.io/downloads.html
测试consul版本1.5.3
创建配置文件
自定义端口-可用于单机测试 生产环境不建议修改端口 集群开3-5个
配置1
{ "datacenter": "us-east-1", "data_dir": "./data1/", "node_name": "dc1", "bootstrap_expect": 2, "bind_addr": "0.0.0.0", "retry_join":["127.0.0.1:9301"], "retry_interval": "10s", "retry_max": 0, "server": true, "addresses": { "http": "0.0.0.0" }, "client_addr":"0.0.0.0", "ui":true, "ports": { "http": 9500, "gRPC": 9502, "DNS": 9600, "server": 9300 , "serf_lan": 9301, "serf_wan": 9302 }, "acl" : { "enabled": false, "default_policy": "deny", "down_policy": "extend-cache", "tokens" : { "master" : "b1gs33cr3t" } } }
|
配置2
{ "datacenter": "us-east-1", "data_dir": "./data2/", "node_name": "dc2", "bootstrap_expect": 2, "bind_addr": "0.0.0.0", "retry_join":["127.0.0.1:9301"], "retry_interval": "10s", "retry_max": 0, "server": true, "addresses": { "http": "0.0.0.0" }, "client_addr":"0.0.0.0", "ui":true, "ports": { "http": 10500, "gRPC": 10502, "DNS": 10600, "server": 10300 , "serf_lan": 10301, "serf_wan": 10302 }, "acl" : { "enabled": false, "default_policy": "deny", "down_policy": "extend-cache", "tokens" : { "master" : "b1gs33cr3t" } } }
|
配置3
{ "datacenter": "us-east-1", "data_dir": "./data3/", "node_name": "dc3", "bootstrap_expect": 2, "bind_addr": "0.0.0.0", "retry_join":["127.0.0.1:9301"], "retry_interval": "10s", "retry_max": 0, "server": true, "addresses": { "http": "0.0.0.0" }, "client_addr":"0.0.0.0", "ui":true, "ports": { "http": 11500, "gRPC": 11502, "DNS": 11600, "server": 11300 , "serf_lan": 11301, "serf_wan": 11302 }, "acl" : { "enabled": false, "default_policy": "deny", "down_policy": "extend-cache", "tokens" : { "master" : "b1gs33cr3t" } } }
|
启动命令
consul agent -config-file=consul1.json
|
访问地址 http://127.0.0.1:9500
多数据中心
配置1
{ "datacenter": "china", "data_dir": "./data5/", "node_name": "chinadc1", "bootstrap_expect": 2, "bind_addr": "0.0.0.0", "retry_join":["127.0.0.1:12301"], "retry_join_wan":["127.0.0.1:9302"], "retry_interval": "10s", "retry_max": 0, "server": true, "addresses": { "http": "0.0.0.0" }, "client_addr":"0.0.0.0", "ui":true, "ports": { "http": 12500, "gRPC": 12502, "DNS": 12600, "server": 12300 , "serf_lan": 12301, "serf_wan": 12302 }, "acl" : { "enabled": false, "default_policy": "deny", "down_policy": "extend-cache", "tokens" : { "master" : "b1gs33cr3t" } } }
|
配置2
{ "datacenter": "china", "data_dir": "./data6/", "node_name": "chinadc2", "bootstrap_expect": 2, "bind_addr": "0.0.0.0", "retry_join":["127.0.0.1:12301"], "retry_join_wan":["127.0.0.1:9302"], "retry_interval": "10s", "retry_max": 0, "server": true, "addresses": { "http": "0.0.0.0" }, "client_addr":"0.0.0.0", "ui":true, "ports": { "http": 14500, "gRPC": 14502, "DNS": 14600, "server": 14300 , "serf_lan": 14301, "serf_wan": 14302 }, "acl" : { "enabled": false, "default_policy": "deny", "down_policy": "extend-cache", "tokens" : { "master" : "b1gs33cr3t" } } }
|
配置3
{ "datacenter": "china", "data_dir": "./data7/", "node_name": "chinadc3", "bootstrap_expect": 2, "bind_addr": "0.0.0.0", "retry_join":["127.0.0.1:12301"], "retry_join_wan":["127.0.0.1:9302"], "retry_interval": "10s", "retry_max": 0, "server": true, "addresses": { "http": "0.0.0.0" }, "client_addr":"0.0.0.0", "ui":true, "ports": { "http": 15500, "gRPC": 15502, "DNS": 15600, "server": 15300 , "serf_lan": 15301, "serf_wan": 15302 }, "acl" : { "enabled": false, "default_policy": "deny", "down_policy": "extend-cache", "tokens" : { "master" : "b1gs33cr3t" } } }
|
启动命令
consul agent -config-file=consul1.json
|