zookeeper入門簡介

1、安裝(Linux,集群,3臺機(jī)器

  1. java環(huán)境,安裝jdk,至少需要1.6版本
  2. 下載zookeeper,進(jìn)入zookeeper/conf目錄,拷貝zoo_sample.cfg,重命名為zoo.cfg,配置如下
# 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=/usr/local/zookeeper-3.4.6/data
dataLogDir=/usr/local/zookeeper-3.4.6/dataLog
# 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
server.1=192.168.236.128:2888:3888
server.3=192.168.236.130:2888:3888
server.5=192.168.236.137:2888:3888

然后在dataDir對應(yīng)的目錄中,新建myid文件填入ID值,對應(yīng)如下圖server后面的數(shù)字

完了之后通過bin目錄下面的zkServer.sh腳本可以開啟和關(guān)閉服務(wù),通過ps命令可以驗證zk開啟成功,通過bin目錄下面的zkCli.sh腳本可以開啟zk的命令終端,然后使用zk命令操作

Java API操作

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容