centos下安裝ZooKeeper

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   io   strong   ar   for   

 

1.需求

安裝ZooKeeper,metaQ

2.下載

http://zookeeper.apache.org/releases.html

當前stable版是zookeeper-3.4.6

3.解壓

tar –xf zookeeper-3.4.6.tar.gz

解壓檔案到"/usr/local/zookeeper-3.4.6".

4.複製conf目錄下的zoo_sample.cfg,並命名為zoo.cfg

5.修改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=/datatmp/zookeeper/data
dataLogDir=/datatmp/zookeeper/logs
# 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


#2888,3888 are election port
server.1=zookeeper:2888:38888

其中,2888連接埠號碼是服務之間通訊的連接埠,而3888是;zookeeper與其他應用程式通訊的連接埠.而zookeeper是在hosts中已映射了原生IP.

initLimit:這個配置項是用來配置Zookeeper接受用戶端(這裡所說的用戶端不是使用者串連Zookeeper伺服器的用戶端,而是Zookeeper伺服器叢集中串連到 Leader 的 Follower 伺服器)初始化串連時最長能忍受多少個心跳時間間隔數。當已經超過 10 個心跳的時間(也就是 tickTime)長度後 Zookeeper 伺服器還沒有收到用戶端的返回資訊,那麼表明這個用戶端串連失敗。總的時間長度就是 5*2000=10 秒。
syncLimit:這個配置項標識 Leader 與 Follower 之間發送訊息,請求和應答時間長度,最長不能超過多少個 tickTime 的時間長度,總的時間長度就是 2*2000=4 秒。
server.A=B:C:D:其中 A 是一個數字,表示這個是第幾號伺服器;B 是這個伺服器的 ip 地址;C 表示的是這個伺服器與叢集中的 Leader 伺服器交換資訊的連接埠;D 表示的是萬一叢集中的 Leader 伺服器掛了,需要一個連接埠來重新進行選舉,選出一個新的 Leader,而這個連接埠就是用來執行選舉時伺服器相互連信的連接埠。如果是偽叢集的配置方式,由於 B 都是一樣,所以不同的 Zookeeper 執行個體通訊連接埠號不能一樣,所以要給它們分配不同的連接埠號碼。

6.建立dataDir參數指定的目錄(這裡指的是“ /datatmp/zookeeper/data”),並在目錄下建立檔案,命名為“myid”。

7.編輯“myid”檔案,並在對應的IP的機器上輸入對應的編號。如在zookeeper上,“myid”檔案內容就是1。由於本次只在單點上進行安裝配置,所以只有一個server.1。若還有其他伺服器,比如地址為192.168.1.102,則在zoo.cfg檔案中還需加入server.2=192.168.1.102:2888:3888。那麼myid檔案在192.168.1.102伺服器上的內容就是2。至此,如果是多伺服器配置,就需要將zookeeper-3.4.3目錄拷貝到其他伺服器,然後按照上述的方法修改myid。

8.在/etc/profile檔案中設定PATH
修改profile檔案:
sudo vi /etc/profile

export ZOOKEEPER_HOME=/home/hadooptest/zookeeper-3.4.3export PATH=$ZOOKEEPER_HOME/bin:$PATHexport PATH

OH YEAH!!! 安裝完畢!

安裝好了,啟動搞搞.

1.啟動

zookeeper-3.4.6/bin/zkServer.sh start
2.輸入jps命令查看進程
1573 QuorumPeerMain1654 Jps

其中,QuorumPeerMain是zookeeper進程,啟動正常。

3、查看狀態:zookeeper-3.4.3/bin/zkServer.sh status

-JMX enabled by defaultUsing config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfgMode: standalone

4、啟動用戶端指令碼:zookeeper-3.4.3/bin/zkCli.sh -server zookeeper:2181

5、停止zookeeper進程:zookeeper-3.4.3/bin/zkServer.sh stop

參與:

http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html

centos下安裝ZooKeeper

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.