Zookeeper windows系統安裝

1.下載Zookeeper

    Zookeeper下載地址:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/

    上面地址是apache zookeeper網站上的下載地址,進入後選擇你需要的版本,點擊下載就可以了,我這裏選擇3.4.10。

    

2.解壓zookeeper包

   將下載的zookeeper-3.4.10.tar.gz利用壓縮軟件解壓到本地磁盤,我解壓路徑是E:\zookeeper目錄下。

3.修改配置

   進入zookeeper解壓目錄E:\zookeeper\zookeeper-3.4.10,修改conf下的zoo_sample.cfg配置文件,先將文件名稱修改爲zoo.cfg,或者新建一個zoo.cfg的文件,

   如果是修改文件的話,需要修改以下配置,如果是新建文件的話,需要在文件中增加如下配置(其中tickTime,clientPort,dataDir,dataLogDir):

#
# 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=E:\zookeeper\data
dataLogDir=E:\zookeeper\logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# 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

參數說明:
   tickTime:zookeeper中的時間單元,以毫秒爲單位,默認超時時間設置2*tickTime;
   initLimit:leader允許follower在啓動後多少個心跳時間內,允許其同步初始化數據,如果ZooKeeper管理的數據較大,則應相應增大這個值;
   syncLimit:zookeeper的leader通過心跳檢測機制來檢測節點的存活狀態,如果leader發送請求,在syncLimit次數後還沒有收到返回消息,就會認爲該節點不存在了;
   dataDir:數據的快照存儲目錄,默認情況下,如果沒有配置dataLogDir目錄的話,數據事物日誌文件也會存在這個目錄下,如果是集羣的話,myid文件也會存在這個目錄下;
   dataLogDir:事物日誌存儲的目錄,建議配置這個參數並和dataDir路徑分開,事務日誌的寫會影響ZK的性能;
   clientPort:客戶端連接server的端口,即對外服務的端口;
   maxClientCnxns:單個客戶端與單臺服務器之間的連接數的限制,是ip級別的,默認是60,如果設置爲0,那麼表明不作任何限制;
   autopurge.snapRetainCount:快照文件保留的數目;
   autopurge.purgeInterval:3.4.0版本之後,ZK提供了自動清理事務日誌和快照文件的功能,這個參數指定了清理頻率,單位是小時,0表示不開啓自動清理功能。

4.啓動zookeeper服務

  進入到E:\zookeeper\zookeeper-3.4.10\bin目錄下,啓動zkServer.cmd,這個腳本中會啓動一個java進程。

  E:\zookeeper\zookeeper-3.4.10\bin> zkServer.cmd

  另起一個命令窗口,啓動客戶端連接試一下,

  E:\zookeeper\zookeeper-3.4.10\bin> zkCli.cmd -server 127.0.0.1:2181,能看到連接的信息。

  這時zookeeper單機節點的已經就安裝完了。

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章