micro service system configuration(1)-注册中心部署

http://172.16.24.72/index/cloudscale/deploy/register-center/

# 单节点部署

下载地址

https://www.consul.io/downloads.html

# 下载

wget https://releases.hashicorp.com/consul/0.9.3/consul_0.9.3_linux_amd64.zip?_ga=2.236861953.1230862012.1505871783-1231841512.1505723315

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

http://172.16.78.111:8500/v1/agent/service/deregister/ms-product-172-16-24-44-8182?token=2767b950-0ecb-d642-861c-eb0dd290298a

tokenservice-register

http://172.16.78.229:8500/v1/agent/service/deregister/ms-product-172-16-78-78-8182?token=6280e0de-01f3-be80-4f4f-2ebd4cbf8f32

浏览器GET方法不行的情况下可以用PUT方法

curl -X PUT http://172.16.78.229:8500/v1/agent/service/deregister/ms-product-172-16-78-78-8182?token=6280e0de-01f3-be80-4f4f-2ebd4cbf8f32

 

 

来自 <https://note.youdao.com/share/iframe.html>

 

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值