Win10本地啟動(dòng)Zookeeper注意事項(xiàng)

本文主要記錄一下, 自己在Win10環(huán)境下啟動(dòng)Zookeeper遇到的幾點(diǎn)小問題.
從官網(wǎng)下載ZK之后, 解壓, 拷貝conf/zoo_sample.cfg文件,命名為zoo.cfg

圖片.png

zoo.cfg具體內(nèi)容如下(非生產(chǎn)環(huán)境配置,僅為了測試)

# 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=D:/Soft/apache-zookeeper-3.6.1-bin/data
logDir=D:/Soft/apache-zookeeper-3.6.1-bin/data/logs
# the port at which the clients will connect
clientPort=2182
# 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

# 將默認(rèn)的8080端口改成38080(任意), 防止端口沖突
admin.serverPort=38080


server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:4888:5888
server.3=127.0.0.1:6888:7888
server.4=127.0.0.1:8888:9888

以上配置中主要關(guān)注下dataDir路徑的寫法問題(當(dāng)然,其他的配置項(xiàng)也一樣重要, 廢話)

圖片.png

如果你在zoo.cfg文件中配置dataDir目錄值的時(shí)候,是通過上面截圖上直接復(fù)制出來的目錄值,然后拷貝到zoo.cfg里, 最后形成

圖片.png

在Win系統(tǒng)中目錄分隔符是反斜杠(\), 那么如果你通過zkServer.cmd啟動(dòng)的時(shí)候,會(huì)出現(xiàn)一閃而過(輕輕地我來了,沒留下一點(diǎn)痕跡)

圖片.png

那么如何讓它不一閃而過,而是要查看下出錯(cuò)原因, 那么這個(gè)時(shí)候, 需要通過文本的方式,打開zkServer.cmd 并在最后一行加一個(gè)pause

圖片.png

保存,再次點(diǎn)擊執(zhí)行zkServer.cmd

圖片.png

報(bào)錯(cuò)信息如上, 可是已經(jīng)創(chuàng)建了myid文件,咋還找不到呢, 原因就在于dataDir目錄值不對.

圖片.png

需要把反斜杠改成斜杠才可以, 這樣ZK就可以正確的讀取目錄,找到myid文件

【總結(jié)】
1.當(dāng)在Win系統(tǒng)執(zhí)行.cmd文件一閃而過的時(shí)候, 編輯.cmd文件,在最下面添加一個(gè)pause指令, 再次執(zhí)行.cmd文件,就可以看到錯(cuò)誤信息了.
2.zoo.cfg文件里面的目錄分隔符使用斜杠(/), 而不用使用反斜杠(\)

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

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

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