記錄一次zookeeper叢集搭建遇到的問題
阿新 • • 發佈:2018-12-16
使用VMware+centos7,clone了3臺虛機,然後分別裝上zookeeper。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/zookeeper # 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.131.128:2188:3181 server.2=192.168.131.131:2188:3181 server.3=192.168.131.132:2188:3181
這裡有三個埠,一個是clientPort,一個是IP後面的第一個埠:第二個埠。因為我配置的埠衝突了,導致zookeeper一直啟動不了。
簡單瞭解一下各個埠的作用。
server.A=B:C:D。其中A表示是第幾臺伺服器。對應的是myid檔案中的配置。dataDir目錄下必須有一個myid檔案,裡面儲存A的值。zk啟動時讀取此檔案,與下面列表比較是哪個server
B是伺服器IP;C表示與Leader伺服器交換資訊的埠;D表示進行選舉的通訊埠。
因為我配置的clientPort和C一樣,所以埠衝突,導致服務起不了。
再此記錄一下,一面以後自己忘記。