consul - yaokun123/php-wiki GitHub Wiki
consul的使用
一、安装consul
yum install consul
二、搭建集群
2.1、启动命令 consul_start.sh
#!/bin/bash
nohup consul agent -config-dir=/etc/consul.d/ > /tmp/consul-server.log 2>&1 &
2.2、配置文件 /etc/consul.d/server.json
{
"data_dir": "/etc/consul",
"ui": true,
"server": true,
"bootstrap": false,
"node_name": "consul-23",
"client_addr": "0.0.0.0",
"bind_addr": "10.8.8.23",
"watches":[
{
"type": "key",
"key": "common",
"handler_type": "script",
"args": ["/home/www/release-script/sync_configure_center.sh", "common"]
},
{
"type": "key",
"key": "database",
"handler_type": "script",
"args": ["/home/www/release-script/sync_configure_center.sh", "database"]
},
{
"type": "key",
"key": "pay",
"handler_type": "script",
"args": ["/home/www/release-script/sync_configure_center.sh", "pay"]
}
]
}
2.3、加入集群
consul members # 在已经启动的结点上执行该命令。打印出集群结点,随便复制Address的结点
consul join 10.8.8.23:8301 # 加入集群