Centos7下zookeeper-3.4.9安裝(單機版)

Zookeeper的安裝和配置十分簡單, 既能夠配置成單機模式, 也能夠配置成集羣模式. 下面介紹單機版的安裝。bash

一、[官網][1]下載zookeeper,我這裏選擇的是3.4.9版本

二、經過FTP(WinSCP,FileZilla等)工具上傳到「/usr/local/zookeeper

三、使用解壓命令解壓到當前目錄

tar -zvxf zookeeper-3.4.9.tar.gz

四、在/usr/local/zookeeper/zookeeper-3.4.9目錄下使用如下命令建立data和logs目錄留做下一步配置所用

mkdir data
mkdir logs

五、進入zookeeper目錄下的conf子目錄,使用如下命令,將配置文件模板拷貝一份,命名爲zoo.cfg

cp zoo_sample.cfg zoo.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=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
dataDir=/usr/local/zookeeper/zookeeper-3.4.9/data
dataLogDir=/usr/local/zookeeper/zookeeper-3.4.9/logs

配置說明:網絡

  • tickTime

時長單位爲毫秒,爲zk使用的基本時間度量單位。例如,1 * tickTime是客戶端與zk服務端的心跳時間,2 * tickTime是客戶端會話的超時時間。 tickTime的默認值爲2000毫秒,更低的tickTime值能夠更快地發現超時問題,但也會致使更高的網絡流量(心跳消息)和更高的CPU使用率(會話的跟蹤處理)。工具

  • clientPort

zk服務進程監聽的TCP端口,默認狀況下,服務端會監聽2181端口。code

  • dataDir

無默認配置,必須配置,用於配置存儲快照文件的目錄。進程

  • dataLogDir

log目錄, 能夠是任意目錄. 若是沒有設置該參數, 將使用和dataDir相同的設置。get

  • clientPort

監聽client鏈接的端口號。it

七、啓動zookeeper

bin/zkServer.sh start

八、查看zookeeper狀態

bin/zkServer.sh status

九、中止zookeeper

bin/zkServer.sh stop

十、設置開機啓動

  • 使用如下命令設置開機啓動:
chkconfig --add zookeeper
  • 或在在/etc/rc.local文件中追加:
su - root -c '/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh start'
相關文章
相關標籤/搜索