使用Consul

Consul集群的每个节点都必须先安装Consul.安装非常容易,Consul发布为所支持的平台和架构的二进制包.这个指南不包含从源代码编译Consul的内容.

安装Consul

安装Consul,找到适合你系统的包下载他.Consul打包为一个’Zip’文件.

下载后解开压缩包.拷贝Consul到你的PATH路径中,在Unix系统中~/bin/usr/local/bin是通常的安装目录.根据你是想为单个用户安装还是给整个系统安装来选择.在Windows系统中有可以安装到%PATH%的路径中.

OS X

如果你使用homebrew作为包管理器,你可以使用命令

  1. brew install consul

来进行安装.

验证安装

完成安装后,通过打开一个新终端窗口检查consul安装是否成功.通过执行 consul你应该看到类似下面的输出

  1. [root@hdp2 ~]# consul
  2. usage: consul [--version] [--help] <command> [<args>]
  3. Available commands are:
  4. agent Runs a Consul agent
  5. configtest Validate config file
  6. event Fire a new event
  7. exec Executes a command on Consul nodes
  8. force-leave Forces a member of the cluster to enter the "left" state
  9. info Provides debugging information for operators
  10. join Tell Consul agent to join cluster
  11. keygen Generates a new encryption key
  12. keyring Manages gossip layer encryption keys
  13. leave Gracefully leaves the Consul cluster and shuts down
  14. lock Execute a command holding a lock
  15. maint Controls node or service maintenance mode
  16. members Lists the members of a Consul cluster
  17. monitor Stream logs from a Consul agent
  18. reload Triggers the agent to reload configuration files
  19. rtt Estimates network round trip time between nodes
  20. version Prints the Consul version
  21. watch Watch for changes in Consul

如果你得到一个consul not be found的错误,你的PATH可能没有正确设置.请返回检查你的consul的安装路径是否包含在PATH中.