flume+kafka+storm單機部署
阿新 • • 發佈:2019-02-11
flume-1.6.0
kafka0.9.0.0
storm0.9.6一.部署flume
1.解壓
tar -xzvf apache-flume-1.6.0-bin.tar.gz -C ../app/
2.在conf目錄中新增自己的配置檔案,內容是source、sink、channel的配置
cd ../app/apache-flume-1.6.0-bin/conf
新建配置檔案flume-directory-kafka.conf,內容如下
# flume-directory-kafka.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.channels = c1
a1.sources.r1.spoolDir = /home/koushengrui/flumeDemoLog
a1.sources.r1.fileHeader = true
# Describe the sink
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = webService_log
a1.sinks.k1.brokerList = montnets:9092
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.batchSize = 20
a1.sinks.k1.channel = c1
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
3.啟動flume
必須在bin目錄以上級別目錄啟動,在bin目錄啟動無效,因為log4j.properties檔案在跟bin目錄同級的conf目錄中
./bin/flume-ng agent --conf conf --conf-file ./conf/flume-directory-kafka.conf --name a1 -Dflume.root.logger=INFO,console
二.部署zookeeper
1.解壓
tar -xzvf zookeeper-3.4.6.tar.gz -C ../app/
2.配置
2.1把conf目錄中的zoo_sample.cfg重新命名為zoo.cfg
cd ../app/zookeeper-3.4.6/conf/
mv zoo_sample.cfg zoo.cfg
3.2修改zoo.cfg配置檔案
dataDir=/home/koushengrui/app/zookeeper-3.4.6/data
server.1=montnets:2888:3888
3.3在/home/koushengrui/app/zookeeper-3.4.6中建立一個data目錄,並在data目錄中新建一個名為myid的檔案,裡面內容是server.N中的N(server.1裡面內容為1)
echo 1 > myid
4.啟動zookeeper
cd ../bin/
./zkServer.sh start
三.部署kafka
1.解壓
tar -xzvf kafka_2.11-0.9.0.0.tgz -C ../app/
2.修改conf目錄中的server.properties檔案
cd ../app/kafka_2.11-0.9.0.0/config/
vi ./server.properties
broker.id=1
zookeeper.connect=montnets:2181
3.在每一臺節點上啟動broker
cd ../bin
./kafka-server-start.sh ../config/server.properties
4.檢視現有topic的狀態
./kafka-topics.sh --list --zookeeper montnets:2181
如果之前有topic的話,此時會顯示出來
5.新建對應flume的配置檔案的topic webService_log
./kafka-topics.sh --create --zookeeper montnets:2181 --replication-factor 1 --partitions 1 --topic webService_log
6.此時就可以校驗flume與kafka是否整合成功了。用一個comsumer從webService_log中讀取資訊
./kafka-console-consumer.sh --zookeeper montnets:2181 --from-beginning --topic webService_log
在/home/koushengrui/flumeDemoLog目錄中新增一個內容如下的名為log1的檔案,觀察是否在kafka的控制檯輸出了檔案資訊。經校驗,整合成功。
<ROOT>
<EVENT>
<HOSTID>18</HOSTID>
<PROCEID>28</PROCEID>
<APPTYPE>4100</APPTYPE>
<EVTID>1501</EVTID>
<EVTTYPE>10</EVTTYPE>
<EVTTM >2015-08-31 09:08:16.979</EVTTM>
<EVTCONT>
[{
USERID:"使用者賬號1",
VALUE:"填線上狀態 0/1",
MSG:"這裡填寫xxx帳號離線等詳情"
}
,
{
USERID:"使用者賬號2",
VALUE:"填線上狀態 0/1",
MSG:"這裡填寫xxx帳號離線等詳情"
}]
</EVTCONT>
</EVENT>
<ROOT>
四.部署storm
1.解壓
tar -xzvf apache-storm-0.9.6.tar.gz -C ../app/
2.修改conf目錄下的storm.yaml檔案
cd ../app/apache-storm-0.9.6/conf/
vi ./storm.yaml
#所使用的zookeeper叢集主機
storm.zookeeper.servers:
- "montnets"
#nimbus所在的主機名
nimbus.host: "montnets"
3.啟動storm
分別要啟動nimbus及supervisor
在nimbus主機上
./storm nimbus
./storm ui 提供web頁面,通過http://montnets:8080/可以訪問Storm UI。
在supervisor主機上
./storm supervisor
五.把專案打jar包上傳,此處命名jar包為demoTopo,其中入口類(有main方法的類)為com.montnets.test.Entrance
./storm jar ../demoTopo.jar com.montnets.test.Entrance
./storm kill topologyName