flume+kafka

系統版本:Ubuntu 16.04 LTS

內核:4.4.0-42-generic
JDK:1.8.0_101

 

zookeeper:3.4.9

flume:1.6.0

kafka:2.11-0.10.0.1

 

安裝目錄:/opt/bigdata/

一:zookeeper

下載tar包,解壓到/opt/bigdata/zookeeper-3.4.9

創建配置文件:sudo cp zoo_sample.cfg zoo.cfg

修改dataDir爲dataDir=/opt/bigdata/zookeeper-3.4.9/data

啓動zookeeper:sudo bin/zkServer.sh start

查看zookpeeper狀態: sudo bin/zkServer.sh status

cxh@ubuntu:/opt/bigdata/zookeeper-3.4.9$ sudo bin/zkServer.sh status
[sudo] password for cxh:
ZooKeeper JMX enabled by default
Using config: /opt/bigdata/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone

啓動日誌輸出在zookeeper.out裏

 

二:flume

下載解壓到/opt/bigdata/flume-1.6.0

創建配置文件:cp flume-conf.properties.template flume-conf.properties

修改:

a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = exec
#a1.sources.r1.type = netcat
#a1.sources.r1.bind = localhost
#a1.sources.r1.port = 44444

#從文件中讀取
a1.sources.r1.command = tail -f n+1 /opt/bigdata/flume-1.6.0/logs/flume.log

# Describe the sink
a1.sinks.k1.type = logger

# 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

a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.topic = test
a1.sinks.k1.brokerList = localhost:9092
a1.sinks.k1.requiredAcks = 1
a1.sinks.k1.batchSize = 20
a1.sinks.k1.channel = c1

啓動flume:

sudo bin/flume-ng agent --conf conf --conf-file conf/flume-conf.properties --name a1 -Dflume.root.logger=INFO,console

 

三:kafka

下載解壓到/opt/bigdata/kafka_2.11-0.10.0.1

修改配置文件:conf/server.properties

listeners=PLAINTEXT://localhost:9092

 

log.dirs=/opt/bigdata/kafka_2.11-0.10.0.1/logs

  啓動服務  sudo bin/kafka-server-start.sh config/server.properties &
  查看topic bin/kafka-topics.sh --list --zookeeper localhost:2181
  創建test topic  bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

查看again  sudo bin/kafka-topics.sh --list --zookeeper localhost:2181
模擬生產者  sudo bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
消費者  sudo bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章