溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

ubuntu單機(jī)版搭建storm環(huán)境的示例分析

發(fā)布時間:2021-11-15 17:20:27 來源:億速云 閱讀:117 作者:小新 欄目:云計算

這篇文章將為大家詳細(xì)講解有關(guān)ubuntu單機(jī)版搭建storm環(huán)境的示例分析,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

1 參考博文

http://www.makaidong.com/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E6%8E%92%E8%A1%8C/5364.shtml

http://jingpin.jikexueyuan.com/article/36537.html

http://my.oschina.net/mingdongcheng/blog/43009?fromerr=Mni4Cbek

http://stackoverflow.com/questions/22216433/java-home-not-set-when-install-storm

http://www.xuebuyuan.com/1932716.html

2 Storm簡介

storm的集群跟hadoop的集群非常像。但是在hadoop上面你運行的是mapreduce的job, 而在storm上面你運行的是topology。

在storm的集群里面有兩種節(jié)點: 控制節(jié)點(master node)和工作節(jié)點(worker node)。控制節(jié)點 上面運行一個后臺程序: nimbus, 它的作用類似hadoop里面的jobtracker。nimbus負(fù)責(zé)在集群里面分布代碼,分配工作給機(jī) 器, 并且監(jiān)控狀態(tài)。

 每一個工作節(jié)點上面運行一個叫做supervisor的節(jié)點。supervisor會監(jiān)聽分配給它那臺機(jī)器的工作,根據(jù)需要 啟動/關(guān)閉工作進(jìn)程。每一個工作進(jìn)程執(zhí)行一個topology的一個子集;一個運行的topology由運行在很多機(jī)器上的很多工作進(jìn)程組成。

ubuntu單機(jī)版搭建storm環(huán)境的示例分析

nimbus和supervisor之間的所有協(xié)調(diào)工作都是通過一個zookeeper集群來完成。

stream是storm里面的關(guān)鍵抽象。一個stream是一個沒有邊界的tuple序列。storm提供一些原語來分布式地、可靠地把一個stream傳輸進(jìn)一個新的stream。比如: 你可以把一個tweets流傳輸?shù)綗衢T話題的流。

storm提供的最基本的處理stream的原語是spout和bolt。你可以實現(xiàn)spout和bolt對應(yīng)的接口以處理你的應(yīng)用的邏輯。

spout的流的源頭。比如一個spout可能從kestrel隊列里面讀取消息并且把這些消息發(fā)射成一個流。

bolt可以接收任意多個輸入stream,作一些處理, 有些bolt可能還會發(fā)射一些新的stream。一些復(fù)雜的流轉(zhuǎn)換, 比如從一些tweet里面計算出熱門話題, 需要多個步驟, 從而也就需要多個bolt。 bolt可以做任何事情: 運行函數(shù), 過濾 tuple, 做一些聚合, 做一些合并以及訪問數(shù)據(jù)庫等等。

spout和bolt所組成一個網(wǎng)絡(luò)會被打包成topology, topology是storm里面最高一級的抽象,相當(dāng)于hadoop的mapreduce,你可以把topology提交給storm的集群來運行。

ubuntu單機(jī)版搭建storm環(huán)境的示例分析

在整個數(shù)據(jù)流之間有一個zeromq組件,它主要負(fù)責(zé)消息傳遞工作的,通過

此文來自: 馬開東博客  轉(zhuǎn)載請注明出處 網(wǎng)址:  http://www.makaidong.com  

協(xié)調(diào)可以避免數(shù)據(jù)傳輸中的排隊阻塞現(xiàn)象。

topology里面的每一個節(jié)點都是并行運行的。 在你的topology里面, 你可以指定每個節(jié)點的并行度,storm則會在集群里面分配那么多線程來同時計算。

3 安裝準(zhǔn)備

1.     Ubuntu 14.04

2.     JDK 版本 1.7

3.     Python 2.7

4.     zookeeper 3.4.7

5.     ZeroMQ 2.1.7

6.     jzmq

7.     storm 0.10.0

4 安裝步驟

4.1 Linux 安裝

  因為設(shè)備數(shù)量有限,所以在本地使用的是VMware Workstation虛擬機(jī)搭建的一個Ubuntu 64位Server版本。網(wǎng)上資料很多就不多做詳述,需要花費些時間。

4.2 JDK安裝

4.2.1 JDK下載

  本地選擇的是 JDK  1.7下在地址為:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

4.2.2 JDK安裝

  下載好后放入指定位置(如/home/geyg/storm/install),使用如下命令安裝

tar zxvf jdk-7u79-linux-x64.tar.gz

為了方便管理,可將解壓后的文件移至另一個文件夾。

sudo mv jdk1.7.0_79/ /usr/lib/jdk1.7/

4.2.3 JDK配置

  1.進(jìn)入/etc目錄

  2.將JDK配置信息加入profile文件

# The following configuration is for Java
export JAVA_HOME=/usr/lib/jdk1.7
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib

  3.使用下面組合命令使配置生效

chmod +x profile (這條命令需要超級權(quán)限)  
source profile

  4.使用下面,驗證JDK安裝

java -version

  如果安裝版本信息顯示則安裝成功

備注:JDK配置也可在~/.bashrc中進(jìn)行配置,配置后source ~/.bashrc使其生效

4.3 Python安裝

Ubuntu系統(tǒng)默認(rèn)已安裝,可通過下面shell命令查看版本號:

python -V

若系統(tǒng)中尚未安裝Python,可按下面步驟安裝:

4.3.1 Python下載

wget  http://www.python.org/ftp/python/2.7.2/python-2.7.2.tgz

4.3.2 Python安裝

tar zxvf python-2.7.2.tgz
cd python-2.7.2 
./configure   //配置依賴之類的,生成makefile
make       //編譯makefile
make install  //安裝

4.3.3 Python配置

vi /etc/ld.so.conf

在該文件最后/usr/local/lib/

執(zhí)行下面命令使Python生效

sudo ldconfig

至此,Python安裝完畢。

4.4 zookeeper 安裝

目的:協(xié)調(diào)整個集群,主要是做nimbus和supervisor的聯(lián)系中介,管理集群中的組件的作用

4.4.1 zookeeper下載

wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//zookeeper/zookeeper-3.4.7/zookeeper-3.4.7.tar.gz

4.4.2 zookeeper安裝

tar zxvf zookeeper-3.4.7.tar.gz
cp -r zookeeper-3.4.7 /usr/local/
cd /usr/local
mv zookeeper-3.4.7 zookeeper

4.4.3 zookeeper配置

vi ~/.bashrc

該文件末尾追加下面代碼

export ZOOKEEPER_HOME=/usr/local/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bi

修改zoo.cfg文件內(nèi)容

cp /usr/local/zookeeper/conf/zoo_sample.cfg  /usr/local/zookeeper/conf/zoo.cfg

該文件內(nèi)dataDir為:

dataDir=/usr/local/zookeeper/zookeeperdir/zookeeper-data

創(chuàng)建目錄/usr/local/zookeeper/zookeeperdir/zookeeper-data

cd /usr/local/zookeeper
mkdir zookeeperdir
cd zookeeperdir
mkdir zookeeper-data

至此,zookeeper的單機(jī)安裝已經(jīng)完成了。

4.5 ZeroMQ安裝

zeromq是用來做底層通信的

zeromq是網(wǎng)絡(luò)棧中新的一層,它是個可伸縮層,分散在分布式系統(tǒng)間。因此,它可支持任意大的應(yīng)用程序。zeromq不是簡單的點對點交互,相反,它定義了分布式系統(tǒng)的全局拓?fù)洹eromq應(yīng)用程序沒有鎖,可并行運行。此外,它可在多個線程、內(nèi)核和主機(jī)盒之間彈性伸縮。

4.5.1 ZeroMQ下載

wget http://download.zeromq.org/zeromq-2.1.7.tar.gz

4.5.2 ZeroMQ安裝

tar zxvf zeromq-2.1.7.tar.gz
cd zeromq-2.1.7
./configure
make
make install
sudo ldconfig (更新ld_library_path)

備注:

這里要說一下在./configure中可能會遇到的問題:

configure:error:in '/usr/local/download/zeromq-2.1.7':

congifure:error:no acceptable c compiler found in $path 

see 'config.log' for more details

這是因為沒有安裝c編譯器。

解決方法是:# apt-get install gcc*

之后遇到的問題是:error:cannot link with -luuid, install uuid-dev

這是因為沒有安裝uuid相關(guān)的package。

解決方法是:# apt-get install uuid*

# apt-get install e2fsprogs*

# apt-get install libuuid*

本人遇到的問題是出現(xiàn)了c++編譯問題

解決辦法

#apt-get install g++

#./configure

問題解決了以后就可以make和make install了,如此這般,zeromq就安裝好了,接下來即可安裝jzmq。

4.6 jzmq安裝

4.6.1 jzmq下載

git clone git://github.com/nathanmarz/jzmq.git

//如果沒有g(shù)it,安裝即可:sudo apt-get install git

4.6.2 jzmq安裝

./autogen.sh

  //可能會報缺包,首先安裝: sudo apt-get install libtool auto-make

可能會報缺少:pkg-config工具

wget  http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz

 tar  zxf  pkg-config-0.23.tar.gz

 cd  pkg-config-0.23

./configure --prefix=/usr/local/pkg-config-0.23 --datarootdir=/usr/share

 make

 sudo make install

安裝完成后設(shè)置PATH:(后面要用到pkg-config)

 export  PATH=.:/usr/local/pkg-config-0.23/bin:$PATH

(注意:請選擇pkg-config-0.23.tar.gz或之前版本安裝,我選擇了0.25或0.26最新版本make是折騰了很久通不過,請不要再重復(fù)掉到這個坑里,pkg-config-0.23之前版本的安裝也是有些小陷阱的,請參閱下面)

小陷阱——安裝 pkg-config<=0.23需要注意的地方:

./configure  --prefix=/usr/local/pkg-config-0.23  --datarootdir=/usr/share

--prefix=/usr/local/pkg-config-0.23指定pkg-config安裝路徑,這不是重點;

重點是--datarootdir=/usr/share它直接關(guān)系到你后面能否成功編譯jzmq.它指明了pkg.m4將要存放 的位置,jzmq在編譯的過程中需要調(diào)用 PKG_CHECK_MODULES() 宏(Macro),這個Macro是pkg-config和Autoconf/Automake/aclocal交互的主要接口

參閱英文資料:

The main interface between autoconf and pkg-config is the PKG_CHECK_MODULES macro, which provides a very basic and easy way to check for the presence of a given package in the system. Nonetheless, there are some caveats that require attention when using the macro.

大概意思就是:

autoconf和pkg-config的之間的主要的交互接口是通過PKG_CHECK_MODULES宏,它提供了一個非常基本的和簡單的方法來檢查系統(tǒng)中的一個給定的包是否存在。然而使用宏時,也有一些需要注意的事項。

語法:

PKG_CHECK_MODULES(prefix, list-of-modules, action-if-found, action-if-not-found)

參數(shù)的意思參閱:

prefix
Each call to PKG_CHECK_MODULES should have a different prefix value (with a few exceptions discussed later on). This value, usually provided in uppercase, is used as prefix to the variables holding the compiler flags and libraries reported by pkg-config.
 
For instance, if your prefix was to be FOO you'll be provided two variables FOO_CFLAGS and FOO_LIBS.
 
This will also be used as message during the configure checks: checking for FOO....
 
list-of-modules
A single call to the macro can check for the presence of one or more packages; you'll see later how to make good use of this feature. Each entry in the list can have a version comparison specifier, with the same syntax as the Requires keyword in the data files themselves.
 
action-if-found, action-if-not-found
As most of the original autoconf macros, there are boolean values provided, for the cases when the check succeeded or failed. In contrast with almost all of the original macros, though, the default action-if-not-fault will end the execution with an error for not having found the dependency.

本例中生成的pkg.m4文件應(yīng)該存在于 /usr/share/aclocal下。這個關(guān)系到autoconf和pkg-config的之間通過CALL PKG_CHECK_MODULES宏來檢查給定依賴包是否存在,否則在編譯JZMQ時將會報告”Syntax error  ./configure: line 15272:  PKG_CHECK_MODULES(' ` ".

cd   ~/jzmq
 
./configure 
 
$ ........ chechking  for  .......
 
ok,success!
 
$ make
 
...
 
make[1]: *** No rule to make target `classdist_noinst.stamp', needed by `org/zeromq/ZMQ.class'.  Stop.
 
make: *** [all-recursive] Error 1


 然后,touch “classdist_noinst.stamp”:

$ touch src/classdist_noinst.stamp
$ make
...
make[1]: *** No rule to make target `org/zeromq/ZMQException.class, needed by `all'.  Stop.
make: *** [all-recursive] Error 1
 然后, 編譯class:

 然后, 編譯class:

$ cd src/org/zeromq/
$ /jzmq/src/org/zeromq]$ javac  *.java
$ cd ..
$ make
...  success!
$ sudo make install

so then jzmq has installed  successfully and enjoy  it yourself!

4.7 Storm安裝

4.7.1 storm下載

wget http://apache.fayea.com/storm/apache-storm-0.10.0/apache-storm-0.10.0.zip

4.7.2 storm安裝

unzip apache-storm-0.10.0.zip
mv -r apache-storm-0.10.0 /usr/local/

4.7.3 storm配置

vi ~/.bashrc

該配置文件末尾追加如下內(nèi)容:

export storm_home=/usr/local/apache-storm-0.10.0
export PATH=$PATH:$storm_home/bin
vi /etc/hosts

在127.0.0.1 后面加上本機(jī)名(ubuntu),如果不加上去的話可能導(dǎo)致supervisor啟動失敗

到此為止單機(jī)版的storm就安裝完畢了。

5 啟動

5.1 啟動zookeeper

bin/zkserver.sh start

5.2 啟動storm

#bin/storm nimbus
#bin/storm supervisor
#bin/storm ui

啟動完成后,我們可以使用jps來查看進(jìn)程狀態(tài):

#jps

在沒有運行任務(wù)時,我們必須應(yīng)該要看到5個進(jìn)程:QuorumPeerMain、nimbus、core、Jps、supervisor。否則就需要 檢查是否正確地啟動,如果啟動之后沒有過多久就停止了,我們就需要查看~/apache-storm-0.10.0/logs下面的對應(yīng)的log文件,查看引起異常的原因是什么,然后解決后再次啟動。

同時,我們可以在瀏覽器中輸入http://127.0.0.1:8080來進(jìn)入Storm UI的界面,可以查看Storm運行期間的相關(guān)信息。

6 Test

7 備注

整個平臺插件安裝系統(tǒng)配置在~/.bashrc中進(jìn)行配置,最終配置如下(供參考):

export JAVA_HOME=/usr/lib/jdk1.7

export PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH

export ZOOKEEPER_HOME=/usr/local/zookeeper

export CLASSPATH=${JAVA_HOME}/lib

export storm_home=/usr/local/apache-storm-0.10.0

export PATH=$PATH:$storm_home/bin

關(guān)于“ubuntu單機(jī)版搭建storm環(huán)境的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI