1. 程式人生 > >Zookeeper之啟動常見錯誤及解決方法-yellowcong

Zookeeper之啟動常見錯誤及解決方法-yellowcong

Zookeeper啟動後,有時候沒有真正的啟動,那我們如何查詢錯誤呢,就可以檢視zookeeper目錄下面的zookeeper.out檔案,就可以檢視到錯誤了。zookeeper.out檔案比較的重要,對於錯誤的排查,是必不可少的,還有伺服器上,如果連線不通,有可能是防火牆的問題

這裡寫圖片描述

搭建的時候,資料儲存的目錄結構,每一個zookeeper裡面,需要有logs(日誌儲存)和data(資料儲存)目錄、myid檔案都是在data目錄下面的。

這裡寫圖片描述

My id 333 not in the peer list

這個問題的產生是因為服務的id,也就是myid裡面配置的,服務的id,需要和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=/tmp/zookeeper1/data #日誌檔案 dataLogDir=/tmp/zookeeper1/logs # the port at which the clients will connect clientPort=2181 #server.NUM=IP:port1:port2 NUM表示本機為第幾號伺服器;IP為本機ip地址; #port1為leader與follower通訊埠;port2為參與競選leader的通訊埠 #多個例項的埠配置不能重複 server.1=127.0.0.1:2222:2225 server.2
=127.0.0.1:3333:3335 server.3=127.0.0.1:4444:4445

server.A=B:C:D:其中 A 是一個數字,就是myid裡的那個數字,表示這個是第幾號伺服器;B 是這個伺服器的 ip 地址,C和D是兩個埠。

配置檔案 myid檔案配置有問題和zoo.cfg不統一導致的
這裡寫圖片描述

Caused by: java.lang.IllegalArgumentException: /usr/local/zookeeper/zookeeper-3.4.10/data/data/myid file is missing

出現這個問題的原因是,myid檔案配置有問題,所導致的,可能是路徑不對,也有可能是檔案沒有,需要在自己的data目錄下建立一個myid的檔案,裡面的編號需要和自己定義的路徑配置好

這裡寫圖片描述

Cannot open channel to 1 at election address /127.0.0.1:2225

導致這個問題的原因是,沒有完全啟動所有的zookeeper節點所導致的問題,所有節點都啟動,就不會有這個問題了

#獲取zookeeper啟動資訊
cat zookeeper.out

這裡寫圖片描述

只有部分節點在叢集中

在啟動的叢集中,只有 2、3兩個節點在叢集中,但是1節點卻是standalone

#檢視節點資訊
zkServer.sh status 

這裡寫圖片描述

可能導致這個問題的原因是端口占用
這裡寫圖片描述

#檢視埠
netstat -lnp|grep 2181

#殺死程序 ,然後重啟zookeeper就好了
kill 程序號 

這裡寫圖片描述