Flume+kafka+zookeeper Building Big Data Log acquisition framework

Source: Internet
Author: User
Tags zookeeper

1.  Jdkthe installation

refer to the installation of the JDK here.

2.  installationZookeeper

refer to my The "Fully distributed" section of the Zookeeper installation tutorial.

3.  installationKafka

refer to my The "Fully distributed Build" section of the Kafka installation tutorial.

4.  installationFlume

refer to my Flume Installation Tutorial.

5.  ConfigurationFlume5.1.  ConfigurationKafka-s.cfg

$ cd/software/flume/conf/# Switch to Kafka configuration file directory

$ cp flume-conf.properties.template Kafka-s.cfg # copy Flume profile template to kafka-s.cfg

kafka-s.cfg The details are as follows:

    # Configuration Flume Agent of the Source , Channel , Sink

A1.sources = R1

A1.channels = C1

A1.sinks=k1

    # Configuration Source

A1.sources.r1.type = Exec

A1.sources.r1.command=tail-f/tmp/logs/kafka.log

    # Configuration Channel

A1.channels.c1.type = Memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100

    # Configuration Sink

A1.sinks.k1.channel = C1

A1.sinks.k1.type =org.apache.flume.sink.kafka.kafkasink

    # Set Kafka of the Topic

A1.sinks.k1.kafka.topic = MyTest

    # Set Kafka of the Broker address and port number

A1.sinks.k1.kafka.bootstrap.servers = s201:9092,s202:9092,s203:9092

    # Configure the number of batch submissions

A1.sinks.k1.kafka.flumeBatchSize = 20

A1.sinks.k1.kafka.producer.acks = 1

a1.sinks.k1.kafka.producer.linger.ms = 1

A1.sinks.ki.kafka.producer.compression.type= Snappy

    # binding Source and the Sink to the Channel

A1.sources.r1.channels = C1

A1.sinks.k1.channel=c1

3 Notes on the above configuration file points:

A,a1.sources.r1.command=tail-f/tmp/logs/kafka.log

b,a1.sinks.k1.kafka.bootstrap.servers= s201:9092,s202:9092,s203:9092

C,a1.sinks.k1.topic= mytest

From the configuration file we can learn:

1), we need to build a kafka.log file under the/tmp/logs , and output the content to the file (said below);

2),flume connection to Kafka address is s201:9092,s202:9092,s203:9092, pay attention to not configure the error;

3),Flume will be collected after the content output to kafkatopic for mytest , so we start ZK,Kafka After you need to open a terminal consumption topic mytest content, so you can see flume and Kafka play up.

5.2.  Create/tmp/logs/kafka.logfile directories and files

Create an empty file under /tmp/logs kafka.log; if there is no logs directory under the/tmp directory , you will need to start by creating a logs directory.

5.3.  Create build log dataShellScript

Create a kafkaoutput.sh script under the Hadoop User directory and give Execute permissions to output content to/tmp/logs/kafka.log.

the specific contents of the kafkaoutput.sh script are as follows:

For ((i=0;i<=1000;i++));

Do echo "kafka_test-" + $i >>/tmp/logs/kafka.log;

Done

5.4.  StartZookeeper

to start the ZK service on a ZK -installed server , command the following:

$ zkserver.sh Start

5.5.  StartKafka

Launch Kafka cluster on each server to deploy Kafka

$ kafka-server-start.sh/software/kafka/config/server.properties &

5.6.  CreateKafka Topic

$ kafka-topics.sh--create--zookeeper s201:2181--replication-factor 3--partitions 3--topic mytest

5.7.  Start ConsumptionTopic

$ kafka-console-consumer.sh--bootstrap-server s201:9092,s202:9092,s203:9092--zookeepers201:2181,s202:2181,s203 : 2181--topic mytest--from-beginning

5.8.  StartFlume

$ flume-ng Agent--conf/software/flume/conf/--conf-file kafka-s.cfg--name a1-dflume.root.logger=info,console

5.9.  Executionkafkaoutput.shscript generates log data

$./kafkaoutput.sh

View the contents of the log file as follows:

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201710/30/76a970664489a515905967dcd26a13a7.png-wh_500x0-wm_3 -wmp_4-s_2740149386.png "title=" 1.png "alt=" 76a970664489a515905967dcd26a13a7.png-wh_ "/>

Consumer Information viewed in Kafka:

650) this.width=650; "Src=" Https://s4.51cto.com/oss/201710/30/073ad41aafb576a009fb01b6e198bd07.png-wh_500x0-wm_3 -wmp_4-s_3964389749.png "title=" 2.png "alt=" 073ad41aafb576a009fb01b6e198bd07.png-wh_ "/>


Flume+kafka+zookeeper Building Big Data Log acquisition framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.