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

 

 

你可能感兴趣的:(flume+kafka)