http://172.16.24.72/index/cloudscale/deploy/register-center/
# 单节点部署
下载地址
https://www.consul.io/downloads.html
# 下载
wget http://172.16.24.72/tool/consul_0.9.3_linux_amd64.zip
yum install -y unzip zip
unzipconsul_0.9.3_linux_amd64.zip
# 安装
server类型的agent
vi consul.json
```
{
"acl_replication_token":"ThisisaclToken",
"acl_datacenter":"dc1",
"datacenter":"dc1",
"acl_default_policy":"deny",
"data_dir":"./consul-data",
"acl_master_token":"ThisismasterToken",
"log_level":"INFO",
"node_name": "node-172.16.24.162",
"http_config": {
"response_headers":{
"Access-Control-Allow-Origin":"*"
}
},
"advertise_addr":"172.16.24.162",
"bind_addr": "172.16.24.162",
"server": true,
"acl_ttl":"120s",
"disable_update_check":true,
"client_addr":"172.16.24.162",
"ui": true,
"advertise_addr_wan":"172.16.24.162",
"bootstrap": true,
"enable_syslog":true
}
```
替换IP
sed -i's/172.16.24.162/172.16.24.44/' consul.json
启动
./consul agent -config-file=consul.json
启动之后,看见有leader 选举出来了,再 ctrl c,然后去掉这个配置,再运行一下
sed -i '/bootstrap.*/d'consul.json
看日志,只有 acl 没有配置好了(设置token、配置acl、配置文件添加agent-token)
172.16.24.44:8500
设置token
ThisismasterToken
点击 CLOSE
配置acl
service "" {
policy = "read"
}
node "" {
policy = "read"
}
agent "" {
policy = "read"
}
service-register
node "" {
policy = "write"
}
node "" {
policy = "read"
}
service "" {
policy = "read"
}
service "" {
policy = "write"
}
agent "" {
policy = "write"
}
agent-token
node "" { policy ="write" }
service "" { policy= "read" }
配置文件添加acl-agent-token
"acl_agent_token":"74aa5ae2-a776-76bf-c1ca-7b8aa6d418ca",
重新启动,就ok了
./consul agent-config-file=consul.json
Stopping anAgent
https://www.consul.io/docs/agent/basics.html
ps -ef | grep consul
kill -9 pid
日志在系统日志中
/var/log/message
注销(service-register)
token:service-register
浏览器GET方法不行的情况下可以用PUT方法
来自 <https://note.youdao.com/share/iframe.html>