Consul集群搭建
轉載自??Consul集群搭建
概述
作為服務發現的幾種產品,比較可以查看這里。Consul官方也提供了幾種產品之間的比較,點擊查看。
服務發現產品
Consul有很多組件,但總體來說,它是一個發現和配置服務工具,特性:
服務發現 Service Discovery: Clients of Consul can provide a service, such as api or mysql, and other clients can use Consul to discover providers of a given service. Using either DNS or HTTP, applications can easily find the services they depend upon.
健康檢查 Health Checking: Consul clients can provide any number of health checks, either associated with a given service (“is the webserver returning 200 OK”), or with the local node (“is memory utilization below 90%”). This information can be used by an operator to monitor cluster health, and it is used by the service discovery components to route traffic away from unhealthy hosts.
key-value存儲 KV Store: Applications can make use of Consul’s hierarchical key/value store for any number of purposes, including dynamic configuration, feature flagging, coordination, leader election, and more. The simple HTTP API makes it easy to use.
多數據中心 Multi Datacenter: Consul supports multiple datacenters out of the box. This means users of Consul do not have to worry about building additional layers of abstraction to grow to multiple regions.
更詳細的信息可以查看官網。
選擇了三臺服務器,ip地址分別為192.168.1.12、192.168.1.13、192.168.1.14。
安裝Consul
下載地址是:https://www.consul.io/downloads.html
從里面選擇系統對應的版本,我使用了Linux 64-bit,Consul版本為1.1.0。下載完成后解壓縮,只有一個文件,將文件添加到環境變量或者移動到已有環境變量的目錄中。
三臺服務器上都完成上述相同的步驟。
如果是Mac,可以使用Homebrew進行安裝
brew install consul啟動Consul
192.168.1.12上運行
192.168.1.13上運行
consul agent -server -bind=0.0.0.0 -client=192.168.1.13 -data-dir=/home/ubuntu/data -ui -node=s13 -join 192.168.1.12192.168.1.14上運行
consul agent -server -bind=0.0.0.0 -client=192.168.1.14 -data-dir=/home/ubuntu/data -ui -node=s14 -join 192.168.1.12參數說明:
server: 以server身份啟動。
data-dir:data存放的目錄
node:節點id,在同一集群不能重復。
bind:監聽的ip地址。
client 客戶端的ip地址
其他參數見consul官方說明: https://www.consul.io/docs/agent/options.html
?
查看
網頁查看:http://192.168.1.12:8500/
查看Leader: http://192.168.1.12:8500/v1/status/leader
查看Peers: http://192.168.1.12:8500/v1/status/peers
版本信息:
consul -v使用命令有
consul members:查看集群成員
consul info:查看當前服務器的狀況
consul leave:退出當前服務集群
其他信息也可以點擊查看這里。
總結
以上是生活随笔為你收集整理的Consul集群搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 详解proxy_pass、upstrea
- 下一篇: 中国最宽的瀑布 中国最宽瀑布介绍