Zookeeper集羣安裝教程

引言

好久沒有安裝這些東西,在此處記錄一下

========================教程開始============================

1、獲取安裝包

[root@acs soft]# wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

2、解壓

[root@acs soft]# tar -zxvf zookeeper-3.4.10.tar.gz

3、在安裝路徑下面創建文件夾

[root@acs soft]# mkdir zookeeper-3.4.10

4、將解壓文件移動到安裝目錄下面

[root@acs soft]# mv zookeeper-3.4.10 /data/app/zookeeper-3.4.10/zookeeper1

5、在zk1下面創建文件夾data

mkdir /data/app/zookeeper-3.4.10/zookeeper1/data

6、創建 識別文件

   在目錄/data/app/zookeeper-3.4.10/zookeeper1/data下創建標識文件myid,在 myid 文件中設置標識(數字),在配置文件中要用到,集羣中各個節點不能重 復

echo 1 > myid

7、修改配置文件

主要配置文件位置在:/data/app/zookeeper-3.4.10/zookeeper1/conf   

複製出一個 配置文件 cp 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=/data/app/zookeeper-3.4.10/zookeeper1/data
# 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=172.21.64.17:2881:3881
server.2=172.21.64.17:2882:3882
server.3=172.21.64.17:2883:3883

8、修改日誌配置文件

日誌配置文件位置在:/data/app/zookeeper-3.4.10/zookeeper1/conf 路徑下log4j.properties

主要修改下面這幾個配置項

zookeeper.root.logger=INFO, CONSOLE
zookeeper.console.threshold=INFO
zookeeper.log.dir=/data/logs/zookeeper
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=/data/logs/zookeeper
zookeeper.tracelog.file=zookeeper_trace.log

9、啓動服務

/data/app/zookeeper-3.4.10/zookeeper1/bin/zkServer.sh start

10、配置 節點2 和 節點3

  同理配置zookeeper2和zookeeper3,其中myid不同,zoo.cfg中的clientPort值不同,修改配置文件 中的端口。

至此,整個 集羣的安裝完成

附錄:zk配置文件的主要配置項介紹

#節點數據、日誌路徑
dataDir=/opt/zookeeper/zk1/data
#dataLogDir=/opt/zookeeper-3.4.10/zk1/logs
# 服務器與客戶端之間交互的基本時間單元(ms)
tickTime=2000
# zookeeper所能接受的客戶端數量
initLimit=10
# Leader服務器與follower服務器之間信息同步允許的最大時間間隔,如果超過次間隔,默認follower服務器與leader服務器之間斷開鏈接
syncLimit=5
#節點監聽端口
clientPort=2181
#集羣中各個節點地址和監聽端口
server.1=zk1.zhiqingfin.com:2881:3881
server.2= zk2.zhiqingfin.com:2882:3882
server.3= zk3.zhiqingfin.com:2883:3883
#限制連接到zookeeper服務器客戶端的數量
#maxClientCnxns=60

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章