日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Consul集群搭建

發布時間:2023/12/3 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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。下載完成后解壓縮,只有一個文件,將文件添加到環境變量或者移動到已有環境變量的目錄中。

sudo wget https://releases.hashicorp.com/consul/1.1.0/consul_1.1.0_linux_amd64.zip sudo apt-get install unzip unzip consul_1.1.0_linux_amd64.zip sudo cp consul /usr/local/sbin/

三臺服務器上都完成上述相同的步驟。

如果是Mac,可以使用Homebrew進行安裝

brew install consul

啟動Consul
192.168.1.12上運行

consul agent -server -bootstrap -bind=0.0.0.0 -client=192.168.1.12 -data-dir=/home/ubuntu/data -ui -node=s12

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.12

192.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集群搭建的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。