1. 程式人生 > >Zoookeeper及視覺化UI的部署

Zoookeeper及視覺化UI的部署

首先介紹一下Zookeeper,Zookeeper作為一個分散式的服務框架,主要用來解決分散式叢集中應用系統的一致性問題,它能提供基於類似於檔案系統的目錄節點樹方式的資料儲存.

Zookeeper的安裝

①Zookeeper下載

選擇合適的版本進行下載即可
[root@node-33 zookeeper]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz

②解壓縮

直接解壓縮到當前目錄中
tar -zxvf zookeeper-3.3.6.tar.gz

③增加配置檔案

切換到conf目錄下可以發現有zoo_sample.cfg,這個其實是給出的樣例配置檔案,只需要將其改名或者複製為zoo.cfg即可
[[email protected]33 zookeeper]# ls
zookeeper-3.3.6  zookeeper-3.3.6.tar.gz
[[email protected]33 zookeeper]# cd zookeeper-3.3.6/
[[email protected]33 zookeeper-3.3.6]# ls
bin  build.xml  CHANGES.txt  conf  contrib  dist-maven  docs  ivysettings.xml
ivy.xml lib LICENSE.txt NOTICE.txt README.txt recipes src zookeeper-3.3.6.jar zookeeper-3.3.6.jar.asc zookeeper-3.3.6.jar.md5 zookeeper-3.3.6.jar.sha1 [[email protected]33 zookeeper-3.3.6]# cd conf [[email protected]33 conf]# ls configuration.xsl log4j.properties zoo_sample.cfg
[[email protected]33 conf]# cp zoo_sample.cfg zoo.cfg

④更改配置檔案

只需要在最後一行增加,更換為你當前伺服器的IP
server.1=192.168.17.128:2888:3888

⑤設定環境變數

PATH中增加bin目錄的路徑
[root@node-33 conf]# export ZOOKEEPER_INSTALL=/opt/deploy/zookeeper-3.3.6 
[root@node-33 conf]#  export PATH=$PATH:$ZOOKEEPER_INSTALL/bin

⑥啟動

[[email protected]33 zookeeper-3.3.6]# cd bin/
[[email protected]33 bin]# ls
README.txt  zkCleanup.sh  zkCli.cmd  zkCli.sh  zkEnv.cmd  zkEnv.sh  zkServer.cmd  zkServer.sh
[[email protected]33 bin]# ./zkServer.sh start
JMX enabled by default
Using config: /root/zookeeper/zookeeper-3.3.6/bin/../conf/zoo.cfg
Starting zookeeper ... ./zkServer.sh:行103: /tmp/zookeeper/zookeeper_server.pid: 沒有那個檔案或目錄
FAILED TO WRITE PID
==出現上述情況只需要建立指定目錄和檔案即可==
[[email protected]33 bin]# mkdir -p /tmp/zookeeper
[[email protected]33 bin]# touch /tmp/zookeeper/zookeeper_server.pid
[[email protected]33 bin]# ./zkServer.sh start
JMX enabled by default
Using config: /root/zookeeper/zookeeper-3.3.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

⑦驗證

啟動客戶端,啟動本地的直接執行zkCli.sh即可,也可以通過-server顯式指定連線的伺服器地址
[[email protected]33 bin]# ./zkCli.sh
出現如下兩行則代表連線成功
Welcome to ZooKeeper!
JLine support is enabled
接下來可通過help檢視可用命令進行測試

ZkUI的安裝

①下載

到https://github.com/DeemOpen/zkui頁面download,下載成功的檔案為zkui-master.zip

②解壓縮並編譯

以下是在window上操作的,直接解壓縮,cmd啟動命令列視窗,切換到解壓縮完成的主目錄zkui-master,執行mvn clean install命令後,將編譯完成的jar包與zkui-master目錄下的config.cfg一起復制到虛擬機器的相同目錄下
[root@node-33 zkui]# pwd
/root/zookeeper/zkui
[root@node-33 zkui]# ls
config.cfg  zkui-2.0-SNAPSHOT-jar-with-dependencies.jar

③更改配置檔案

[root@node-33 zkui]# vi config.cfg 
更改zkServer為伺服器i地址:2181
更改userSet裡的登陸賬戶或者密碼,這個隨意

④啟動

[root@node-33 zkui]# nohup java -jar zkui-2.0-SNAPSHOT-jar-with-dependencies.jar &
[1] 2830
[root@node-33 zkui]# nohup: 忽略輸入並把輸出追加到"nohup.out"

⑤驗證

瀏覽器中輸入http://http://192.168.17.128:9090/login 可正常看到登入介面及代表啟動正常,否則啟動有誤