1 Windows安裝和使用zookeeper

2021-07-07 09:26:20 字數 2202 閱讀 3756

本文介紹的 zookeeper 是以 3.4.5 這個穩定版本為基礎,最新的版本可以通過官網來獲取,zookeeper 的安裝非常簡單,下面將從單機模式和集群模式兩個方面介紹 zookeeper 的windows安裝和配置.

單機模式

單機安裝非常簡單,只要獲取到 zookeeper 的壓縮包並解壓到某個目錄如:c:\zookeeper-3.4.5\下,zookeeper 的啟動指令碼在 bin 目錄下,windows 下的啟動指令碼是 zkserver.cmd。

在你執行啟動指令碼之前,還有幾個基本的配置項需要配置一下,zookeeper 的配置檔案在 conf 目錄下,這個目錄下有 zoo_sample.cfg 和 log4j.properties,你需要做的就是將 zoo_sample.cfg 改名為 zoo.cfg,因為 zookeeper 在啟動時會找這個檔案作為預設配置檔案。下面詳細介紹一下,這個配置檔案中各個配置項的意義。

# the number of milliseconds of each tick

ticktime=2000

# the number of ticks that the initial

# synchronization phase can take

initlimit=10

# the number of ticks that can pass between

# sending a request and getting an acknowledgement

synclimit=5

# the directory where the snapshot is stored.

# do not use /tmp for storage, /tmp here is just

# example sakes.

datadir=c:\\zookeeper-3.4.5\\data

datalogdir=c:\\zookeeper-3.4.5\\log

# the port at which the clients will connect

clientport=2181

## be sure to read the maintenance section of the

# administrator guide before turning on autopurge.

## ## the number of snapshots to retain in datadir

#autopurge.snapretaincount=3

# purge task interval in hours

# set to "0" to disable auto purge feature

#autopurge.purgeinterval=1

當這些配置項配置好後,你現在就可以啟動 zookeeper 了,啟動後要檢查 zookeeper 是否已經在服務,可以通過 netstat – ano 命令檢視是否有你配置的 clientport 埠號在監聽服務。

集群模式

zookeeper 不僅可以單機提供服務,同時也支援多機組成集群來提供服務。實際上 zookeeper 還支援另外一種偽集群的方式,也就是可以在一台物理機上執行多個 zookeeper 例項,下面將介紹集群模式的安裝和配置。

zookeeper 的集群模式的安裝和配置也不是很複雜,所要做的就是增加幾個配置項。集群模式除了上面的三個配置項還要增加下面幾個配置項:

initlimit=5  

synclimit=2  

server.1=192.168.211.1:2888:3888  

server.2=192.168.211.2:2888:3888

資料模型

zookeeper 會維護乙個具有層次關係的資料結構,它非常類似於乙個標準的檔案系統,如圖 1 所示:

zookeeper 這種資料結構有如下這些特點:

如何使用

zookeeper 作為乙個分布式的服務框架,主要用來解決分布式集群中應用系統的一致性問題,它能提供基於類似於檔案系統的目錄節點樹方式的資料儲存,但是 zookeeper 並不是用來專門儲存資料的,它的作用主要是用來維護和監控你儲存的資料的狀態變化。通過監控這些資料狀態的變化,從而可以達到基於資料的集群管理.

1 Windows 下 MySQL 的安裝和啟動

複製安裝根目錄下的 my default.ini 為 my.ini,在其 mysqld 部分新增如下內容 character set server utf8 設定資料庫預設字符集為 utf8 用管理員開啟 cmd.exe,進入到安裝目錄,執行如下命令 mysqld.exe initialize us...

1 windows下安裝redis單機版

一 redis單機搭建過程 2 解壓 3 cmd中切換到解壓的redis目錄 cd c cd redis x64 3.2.100 4 啟動redis伺服器 5 以上伺服器視窗不關閉,開乙個新視窗,啟動redis客戶端。用ping命令來測試是否連線到服務端,返回pong代表成功連線,這裡的6379是r...

滲透測試學習1 Windows篇

一些dos命令 ping t l 6550 ip位址 死亡之ping 傳送大於64k的檔案並一直ping net use k 對方的ip位址 c 將對方的c盤複製到本地取名為k net use k ip位址 c del 刪除k盤映像 簡單的整人 shutdown s t 60 c hacked by...