简介
consul是HashiCorp 公司基于Go语音开发的微服务工具。基于它Http API方式可以十分方便在系统中实现服务注册于发现,分布式配置中心。支持集群CP模式,一致性算法是Raft。
常见解决方案:
SpringBoot + Consul 实现注册中心、配置中心。
Nginx + Upsync + Consul 实现动态负载均衡。
Centos7安装Consul
下载地址:https://releases.hashicorp.com/consul/
1.命令行下载
wget https://releases.hashicorp.com/consul/1.12.0/consul_1.12.0_linux_amd64.zip --no-check-certificate
2.解压
unzip consul_1.12.0_linux_amd64.zip
提示错误:unzip 未找到
解决:yum -y install unzip
3.安装验证
./consul
Usage: consul [--version] [--help] <command> [<args>]Available commands are:acl Interact with Consul's ACLsagent Runs a Consul agentcatalog Interact with the catalogconfig Interact with Consul's Centralized Configurationsconnect Interact with Consul Connectdebug Records a debugging archive for operatorsevent Fire a new eventexec Executes a command on Consul nodesforce-leave Forces a member of the cluster to enter the "left" stateinfo Provides debugging information for operators.intention Interact with Connect service intentionsjoin Tell Consul agent to join clusterkeygen Generates a new encryption keykeyring Manages gossip layer encryption keyskv Interact with the key-value storeleave Gracefully leaves the Consul cluster and shuts downlock Execute a command holding a locklogin Login to Consul using an auth methodlogout Destroy a Consul token created with loginmaint Controls node or service maintenance modemembers Lists the members of a Consul clustermonitor Stream logs from a Consul agentoperator Provides cluster-level tools for Consul operatorsreload Triggers the agent to reload configuration filesrtt Estimates network round trip time between nodesservices Interact with servicessnapshot Saves, restores and inspects snapshots of Consul server statetls Builtin helpers for creating CAs and certificatesvalidate Validate config files/directoriesversion Prints the Consul versionwatch Watch for changes in Consul
4.启动
./consul agent -dev -ui -node=consul-dev -client=192.168.126.156
5.浏览器访问 192.168.126.156:8500