使用 Exhibitor 監控管理 ZooKeeper

前言

Exhibitor 是 Netflix 開源的一個用於 ZooKeeper 配置監控和管理的系統。如今 Netflix Exhibitor 已經成爲社區開源公共維護項目 Soabase Exhibitor。Exhibitor 是 ZooKeeper 實例監控,備份,恢復,清理和可視化工具,是 ZooKeeper 的監控管理系統。html

使用 Exhibitor 監控管理 ZooKeeper

更新歷史

2019年01月07日 - 初稿java

閱讀原文 - https://wsgzao.github.io/post...node

擴展閱讀git

exhibitor - https://github.com/soabase/ex...github


exhibitor簡介

ZooKeeper co-process for instance monitoring, backup/recovery, cleanup and visualization.bash

Exhibitor is a Java supervisor system for ZooKeeper. It provides a number of features:服務器

  • Watches a ZK instance and makes sure it is running
  • Performs periodic backups
  • Perform periodic cleaning of ZK log directory
  • A GUI explorer for viewing ZK nodes
  • A rich REST API

https://github.com/soabase/ex...app

exhibitor特性

Exhibitor 主要包括如下特性 / 功能:

實例監控maven

Exhibitor 實例監控在同一服務器上運行的 ZooKeeper 服務器。若是 ZK 沒有運行,Exhibitor 會寫入 zoo.cfg 文件(請參閱下面的 ZK 集羣配置)並啓動它。若是 ZooKeeper 因爲某種緣由崩潰,Exhibitor 也會從新啓動它。ide

日誌清理

在 ZooKeeper 3.4.x 以前的版本中,日誌文件須要維護,Exhibitor 會負責按期維護。

備份 / 還原

ZooKeeper 集羣中的備份比傳統數據存儲(例如 RDBMS)更復雜。通常來講,ZooKeeper 中的大部分數據是短暫的。盲目恢復整個 ZooKeeper 數據集可能會形成更大危害,所以,須要選擇性的恢復以防止對數據集的子集形成意外損壞。Exhibitor 提供了這一功能。

Exhibitor 會按期備份 ZooKeeper 的事務文件,備份後,就能夠對這些事務文件創建索引。

集羣配置

Exhibitor 爲整個 Zookeeper 集羣提供了一個獨立的控制檯,經過它所作的配置更改會對整個集羣有效。如下是一些共享配置值:

Name Description
ZooKeeper Install DirPath to the ZooKeeper server installation
ZooKeeper Data Dir Path where ZooKeeper should store its data
Log Index Dir Path where indexed transaction logs should be kept
Servers List of servers/server-ids in the ensemble
Additional Config Additional fields/values to store in zoo.cfg

集羣滾動升級

Exhibitor 能夠以滾動方式更新集羣中的服務器,以便在進行更改時讓 ZooKeeper 集羣確保 Quorum 設定的最低服務能力。

自動實例管理

Exhibitor 能夠配置爲自動向集羣中添加新實例,並刪除陳舊的實例。這使得 ZooKeeper 集羣能夠實現 「無接觸交鑰匙管理」。

可視化

Exhibitor 爲 ZooKeeper 提供了 ZNode 層次結構的圖形樹視圖。

ZK 數據維護

啓用後,維護人員能夠在 ZooKeeper 的存儲層次結構中建立 / 更新 / 刪除節點。

死鎖檢測

當使用 Curator 的鎖方案(或相似)時,Exhibitor 能夠分析一組表示鎖的 ZNode,並肯定是否存在潛在的死鎖。

Curator 集成

Exhibitor 和 Curator 能夠集成工做,當集羣中的信息變動時,Curator 實例能夠同步更新。

REST API

Exhibitor 提供了一組用於程序集成的 REST API。

重要事項
  1. 使用 Exhibitor 時,不要手動編輯 Zookeeper 的 zoo.cfg 和 myid 文件,由於 Exhibitor 會覆蓋它們。
  2. 除了標準的 ZooKeeper 端口,防火牆必須打開 Exhibitor 使用的 HTTP 端口,由於每一個 Exhibitor 實例須要與其餘參與者通訊傳遞狀態。
使用

Exhibitor 的部署構件能夠從 Maven 倉庫獲取。構件分爲兩種:

GroupID/Org ArtifactID/Name Description
com.netflix.exhibitor exhibitor-standalone 自包含的,可執行的 Exhibitor 版本(能夠是獨立應用,也能夠是 War)
com.netflix.exhibitor exhibitor-core 類庫的形式,能夠嵌入到應用中

exhibitor編譯安裝

官方分享了Maven和Gradle兩種build方法,這裏以Maven爲例

https://github.com/soabase/ex...

# install maven
yum install -y maven

# build exhibitor
mkdir exhibitor
cd exhibitor/
wget https://github.com/soabase/exhibitor/archive/exhibitor-1.7.1.zip
unzip exhibitor-1.7.1.zip
cd exhibitor-exhibitor-1.7.1/exhibitor-standalone/src/main/resources/buildscripts/standalone/maven
mvn clean package

[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /root/exhibitor/exhibitor-exhibitor-1.7.1/exhibitor-standalone/src/main/resources/buildscripts/standalone/maven/target/exhibitor-1.6.0.jar with /root/exhibitor/exhibitor-exhibitor-1.7.1/exhibitor-standalone/src/main/resources/buildscripts/standalone/maven/target/exhibitor-1.6.0-shaded.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.624s
[INFO] Finished at: Tue Jan 08 11:28:59 SGT 2019
[INFO] Final Memory: 15M/94M
[INFO] ------------------------------------------------------------------------

cp target/exhibitor-1.6.0.jar /tmp

# Once built, Exhibitor is completely self-contained and can be run from the command line:
java -jar <path>/exhibitor-xxx.jar -c file

[root@localhost ~]# java -jar exhibitor-1.6.0.jar -c file
v1.6.0
INFO  com.netflix.exhibitor.core.activity.ActivityLog  Exhibitor started [main]
Jan 08, 2019 11:32:38 AM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
INFO  org.mortbay.log  Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog [main]
INFO  org.mortbay.log  jetty-1.6.0 [main]
Jan 08, 2019 11:32:38 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18.3 12/01/2014 08:23 AM'
INFO  org.mortbay.log  Started SocketConnector@0.0.0.0:8080 [main]
Jan 08, 2019 11:33:00 AM java.util.prefs.FileSystemPreferences$6 run
WARNING: Prefs file removed in background /root/.java/.userPrefs/prefs.xml
INFO  com.netflix.exhibitor.core.activity.ActivityLog  State: latent [ActivityQueue-0]

# You can test that it’s running correctly by going to this URL in a browser: 
http://localhost:8080/exhibitor/v1/ui/index.html
http://192.168.56.103:8080/exhibitor/v1/ui/index.html

管理zookeeper集羣

若是須要經過 Exhibitor 管理 zookeeper 集羣須要在集羣的每一個機器上安裝 Exhibitor

https://github.com/soabase/ex...

重點提一下Ensemble中的Servers配置:

  • 服務器IP之間用逗號分隔,有兩種類型:S表示標準類型,O表示Observer觀察者
  • S:1:192.168.56.101,S:2:192.168.56.102,S:3:192.168.56.103
相關文章
相關標籤/搜索