来源:腾讯云
(相关资料图)
配置中心如何解决的呢?配置中心的思路是把项目中的配置参数全部放在一个集中的地方来管理,并提供一套标准的接口,当各个服务需要获取配置的时候就来拉取信息,当配置中心有更新的时候,也能通知其他服务,实时同步最新消息。
1.添加配置信息
2.获取配置信息
GET http://192.168.88.144:8500/v1/kv/mic/pro/pro[ { "LockIndex":0, "Key":"mic/pro/pro", "Flags":0, "Value":"ewoJImhvc3QiOiIxMjcuMC4wLjEiLAogICJwcm90IjogMzMwNiwKICAidXNlciI6InRlc3QiLAogICJwd2QiOiIxMjcuMC4wLjEiCn0=", "CreateIndex":473, "ModifyIndex":473 }]
补充一下单点服务器Consul集群的步骤,我的虚拟机ip 192.168.88.144
,配置3个节点, Consul v1.12.1
server01@server01-virtual-machine:~$ consul versionConsul v1.12.1
wget https://releases.hashicorp.com/consul/1.12.1/consul_1.12.1_darwin_arm64.zipunzip consul_1.12.1_darwin_arm64.zipmv consul /usr/local/bin/consul
目录:
├── client1├── client2├── condifg├── data├── server1│ ├── basic.json│ ├── data│ ├── log│ └── nohup.out├── server2│ ├── basic.json│ ├── data│ ├── log│ └── nohup.out└── server3 ├── basic.json ├── data ├── log └── nohup.out
server1 basic.json详细参数,执行命令consul agent -config-dir=/home/server01/soft/consul/server1/basic.json
{ "bind_addr":"127.0.0.1", "client_addr":"0.0.0.0", "ports":{ "http":8500, "dns":8600, "serf_lan":8011, "serf_wan":8002, "server":8700 }, "datacenter":"dc1", "data_dir":"/home/server01/soft/consul/server1/data", "log_level":"INFO", "log_file":"/home/server01/soft/consul/server1/log/consul.log", "node_name":"consul-server-1", "disable_host_node_id":true, "server":true, "ui":true, "bootstrap_expect":3, "rejoin_after_leave":true, "retry_join":[ "127.0.0.1:8011", "127.0.0.1:8101", "127.0.0.1:8201" ]}
server2 basic.json详细参数,执行命令consul agent -config-dir=/home/server01/soft/consul/server2/basic.json
{ "bind_addr":"127.0.0.1", "client_addr":"0.0.0.0", "ports":{ "http":8501, "dns":8601, "serf_lan":8111, "serf_wan":8102, "server":8701 }, "datacenter":"dc1", "data_dir":"/home/server01/soft/consul/server2/data", "log_level":"INFO", "log_file":"/home/server01/soft/consul/server2/log/consul.log", "node_name":"consul-server-2", "disable_host_node_id":true, "server":true, "ui":true, "bootstrap_expect":3, "rejoin_after_leave":true, "retry_join":[ "127.0.0.1:8011", "127.0.0.1:8111", "127.0.0.1:8211" ]}
server3 basic.json详细参数,执行命令consul agent -config-dir=/home/server01/soft/consul/server3/basic.json
{ "bind_addr":"127.0.0.1", "client_addr":"0.0.0.0", "ports":{ "http":8502, "dns":8602, "serf_lan":8211, "serf_wan":8202, "server":8702 }, "datacenter":"dc1", "data_dir":"/home/server01/soft/consul/server3/data", "log_level":"INFO", "log_file":"/home/server01/soft/consul/server3/log/consul.log", "node_name":"consul-server-3", "disable_host_node_id":true, "server":true, "ui":true, "bootstrap_expect":3, "rejoin_after_leave":true, "retry_join":[ "127.0.0.1:8011", "127.0.0.1:8111", "127.0.0.1:8211" ]}
关键词:
还在苦苦寻找优秀经典的名言吗?为大家整理的关于法律的名言警句
关于法律的名言警句(精选220句)在日常学习、工作或生活中,大家都有令自己印象深刻的名言吧,巧用名言有助于我们正确对待学习、生活、成长
怎样写方案才更能起到其作用呢?整理的项目合作实施方案
项目合作实施方案5篇为保证事情或工作高起点、高质量、高水平开展,往往需要预先进行方案制定工作,方案指的是为某一次行动所制定的计划类
楚辞影响最大的作品 《离骚》全文对照翻译
《离骚》全文对照翻译《离骚》是屈原的代表作,创作于楚怀王时期屈原遭谗被疏之时,是楚辞影响最大的作品。下面是《离骚》全文对照翻译...
写申请书时理由总是不够充分?为大家整理的退学申请书
退学申请书(精选12篇)在一步步向前发展的社会中,申请书在现实生活中使用广泛,申请书不同于其他书信,是一种专用书信。写申请书时理由总是
都有哪些类型的话语呢?为大家收集的感恩老师的话精选150句
感恩老师的话在生活、工作和学习中,越来越多人喜欢发表话语,话语是特定社会语境中人与人之间从事沟通的具体言语行为。那么都有哪些类...
关于我们 加入我们 联系我们 商务合作 粤ICP备18023326号-32
中国创氪网 www.chuanganwang.cn 版权所有
投稿投诉联系邮箱:85 572 98@qq.com