storm集羣配置

1. 安裝配置zookeeperhtml

Storm使用Zookeeper協調集羣,因爲Zookeeper並不用於消息傳遞,因此Storm給Zookeeper帶來的壓力至關低。對於Zookeeper集羣的話,官方推薦的最小節點數爲3個。
在Zookeeper集羣的每臺機器上完成如下安裝部署步驟:
 
一、下載zookeeper
本系統使用的是 zookeeper-3.4.6
 
二、解壓
tar -xf zookeeper-3.4.6.tar.gz

將解壓後的zookeeper-3.4.6文件放在系統的/home/storm/中。java

 
三、將zookeeper-3.4.6/conf目錄下的zoo_sample.cfg文件拷貝一份,命名爲爲「zoo.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=/home/storm/zookeeper-3.4.3/zookeeperdir/zookeeper-data
dataLogDir=/home/storm/zookeeper-3.4.3/zookeeperdir/logs
 
# 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
 
# 2888,3888 are election port
server.1=zookeeper:2888:3888
其中,2888端口號是zookeeper服務之間通訊的端口,而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 實例通訊端口號不能同樣,因此要給它們分配不一樣的端口號。
 
本系統的配置以下:
# 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.
dataDir=/home/storm/zookeeper/data
# the port at which the clients will connect
clientPort=2181
server.1=192.168.1.222:2888:3888
server.2=192.168.1.223:2888:3888
server.3=192.168.1.224:2888:3888
五、建立dataDir參數指定的目錄/home/storm/zookeeper/data
並在該目錄下建立文件,命名爲「myid」的文件。
 
六、編輯「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.6目錄拷貝到其餘服務器,而後按照上述的方法修改myid。
 
七、在/etc/profile文件中設置PATH
修改profile文件:
sudo vi /etc/profile

export ZOOKEEPER_HOME=/home/storm/zookeeper-3.4.6node

PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
 
八、安裝完畢
 
九、啓動
 一、在全部服務器中執行:
zookeeper-3.4.6/bin/zkServer.sh start

注意:須要每一個節點都運行上述命令!linux

 二、輸入jps命令查看進程:
namenode上顯示爲
19361 QuorumPeerMain
其中,QuorumPeerMain是zookeeper進程,啓動正常。(HMaster和HRegionServer爲已啓動的hbase進程,其餘爲安裝hadoop後啓動的進程)
 三、查看狀態:zookeeper-3.4.6/bin/zkServer.sh status
JMX enabled by default
Using config: /home/storm/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follwer
 
2. 安裝Storm 依賴庫
   2.1 安裝zeromq (http://zeromq.org/area:download)
        安裝以前,請先安裝util-linux-2.21.1.tar.gz
tar xvf zeromq-2.1.7.tar.gz
cd zeromq-2.1.7
./configure
make
sudo make install

      

    2.2 安裝 jzmq(https://github.com/nathanmarz/jzmq)
unzip jzmq-master.zip
cd jzmq-master
./autogen.sh
./configure
make
sudo make install
 

  安裝時,可能碰到兩個錯誤:git

    (1).make[1]: *** 沒有規則能夠建立「org/zeromq/ZMQ.class」須要的目標「classdist_noinst.stamp」。 中止 修正方法,建立classdist_noinst.stamp文件:
      touch src/classdist_noinst.stamp  
    (2).錯誤:沒法訪問 org.zeromq.ZMQ 修正方法,進入src目錄,手動編譯相關java代碼:
      javac ./src/org/zeromq/*.java  
 
3. 安裝Storm 
 tar xvf storm-0.9.5.tar.gz
 cd storm-0.9.5

    修改配置文件 conf/storm.yamlgithub

 
storm.zookeeper.servers:
     - "192.168.1.222"
     - "192.168.1.223"
     - "192.168.1.224"
     - "192.168.1.225"
 nimbus.host: "192.168.2.222"
 ui.port:  9090
# 
#
# ##### These may optionally be filled in:
#    
## List of custom serializations
# topology.kryo.register:
#     - org.mycompany.MyType
#     - org.mycompany.MyType2: org.mycompany.MyType2Serializer
#
## List of custom kryo decorators
# topology.kryo.decorators:
#     - org.mycompany.MyDecorator
#
## Locations of the drpc servers
# drpc.servers:
#     - "server1"
#     - "server2"
#
 storm.local.dir: "/home/storm/storm_workdir"
 java.library.path: "/usr/local/lib:/usr/lib"
啓動 storm 
        主節點
storm nimbus &
storm ui &

        從節點apache

storm supervisor &
storm ui &(可選)

執行jps 命令瀏覽器

       在沒有運行任務時,咱們必須應該要看到4個進程:服務器

       QuorumPeerMain、nimbus、core、supervisoride

使用瀏覽器:

   http://192.168.1.222:9090/ 能夠看到Storm UI 界面

 
測試用例執行命令
storm jar stom-wordcount.jar storm.starter.WordCountTopology wordcount
相關文章
相關標籤/搜索