1. 程式人生 > >[大資料]Zookeeper 配置

[大資料]Zookeeper 配置

Zookeeper 環境配置

1 版本選擇

因為要和後面的hive kafka整合 所以選擇了 zookeeper-3.4.5-cdh5.10.0

2 檔案配置

  1. 複製並修改配置檔案:
cp conf/zoo_sample.cfg conf/zoo.cfg
vi conf/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=/opt/modules/zookeeper-3.4
.5-cdh5.10.0/zkData # the port at which the clients will connect clientPort=2181 # # 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 #叢集環境 id 及埠設定 server.1=bigdata01.com:2888:3888 server.2=bigdata02.com:2888:3888 server.3=bigdata03.com:2888:3888
  1. 建立資料儲存目錄:
mkdir /opt/modules/zookeeper-3.4.5-cdh5.10.0/zkData
  1. 在儲存目錄中建立myid 檔案 並修改檔案:
touch zkData/myid
vi zkData/myid
----------------------------------
#在這裡寫在剛才的叢集環境中的id
1

3 執行

要兩臺機器的Server啟動才能使用Zookeeper 因為它的是2N+1 N是可損壞的數量

bin/zkServer.sh start

4 測試

bin/zkServer.sh status 

出現一下資訊說明此節點是follower節點

JMX enabled by default
Using config: /opt/modules/zookeeper-3.4.5-cdh5.10.0/bin/../conf/zoo.cfg
Mode: follower

使用這個命令進入Client 端

bin/zkCli.sh 

可使用的命令有ls,get,create,delete,set