Kafka is a high-throughput distributed publish-subscribe messaging system that has the following features:
Provides persistence of messages through the disk data structure of O (1), a structure that maintains long-lasting performance even with terabytes of message storage. High throughput: Even very common hardware Kafka can support hundreds of thousands of messages per second. Support for partitioning messages through Kafka servers and consumer clusters. Supports Hadoop parallel data loading. The purpose of Kafka is to provide a publishing subscription solution that can handle all the action flow data in a consumer-scale website. This kind of action (web browsing, search and other user actions) is a key factor in many social functions on modern networks. This data is usually resolved by processing logs and log aggregations due to throughput requirements. This is a viable solution for the same log data and offline analysis system as Hadoop, but requires real-time processing constraints. The purpose of Kafka is to unify online and offline message processing through Hadoop's parallel loading mechanism, and also to provide real-time consumption through the cluster machine.
The following figure is the architecture diagram for Kafka:
1. Download Kafka bin Package
Download Address: https://www.apache.org/dyn/closer.cgi?path=/kafka/0.8.0/kafka_2.8.0-0.8.0.tar.gz
> Tar xzf kafka-<version>.tgz
> CD kafka-<version>
> SBT update
> SBT Package
& Gt SBT assembly-package-dependency
There may be many children's shoes in the execution of SBT will not be able to find this command
No command ' SBT ' found, did your mean:
command ' Skt ' from the package ' Latex-sanskrit ' (main)
command ' SB2 ' from Packag E ' Scratchbox2 ' (universe)
command ' SBD ' from the package ' Cluster-glue ' (main) command ' MBT ' from the package
' MBT ' (Univ erse)
command ' SBMT ' from the package ' ATFs ' (universe)
command ' LBT ' from the package ' LBT ' (universe)
Command ' St ' F Rom package ' Suckless-tools ' (universe)
Command ' SB ' from the package ' Lrzsz ' (universe)
Sbt:command not found
This is to be installed on your own, the installation package can be downloaded to the SBT website. My side uses the Ubuntu system, so I downloaded a Deb package, official address: http://www.scala-sbt.org/
Deb Package Address: Http://repo.scala-sbt.org/scalasbt/sbt-native-packages/org/scala-sbt/sbt/0.13.1/sbt.deb
RPM Package Address: http://repo.scala-sbt.org/scalasbt/sbt-native-packages/org/scala-sbt/sbt/0.13.1/sbt.rpm
2. Start the service
The official website of the tutorial has started zookeeper this one, to start zookeeper before the configuration is good zookeeper.properties
> bin/zookeeper-server-start.sh config/zookeeper.properties
[2013-04-22 15:01:37,495] INFO Reading Configuration from:config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig) ...
Since my side uses a separate zookeeper, there is no need to perform the above steps;
If you want to know zookeeper stand-alone installation steps, you can view my blog http://blog.csdn.net/weijonathan/article/details/8591117
With Zookeeper we start the Kafka service, but before we do, we need to configure the Kafka server.properties file first.
Configure Zookeeper.connect in Server.properties as your zookeeper cluster address
zookeeper.connect=nutch1:2181
Next Start Kafka
> bin/kafka-server-start.sh config/server.properties
3. Create Topic
Create a topic named "Test" with only one partition and only one copy:
> bin/kafka-create-topic.sh--zookeeper nutch1:2181--replica 1--partition 1--topic test
To run the list topic command, you can see the topic listing
> bin/kafka-list-topic.sh--zookeeper nutch1:2181
4. Send a message
Kafka comes with a command-line client that can enter a message after it is run, and Kafka sends it to the Kafka into the group for message consumption. By default, each row of data is sent as a message.
Next we run producer try
> bin/kafka-console-producer.sh--broker-list nutch1:9092--topic Test this was
a message this is
another Messa Ge
Enter this is a message and this is another message
5. Start the consumer (consumer)
We entered two lines of messages from the command line Kafka, so we now start the consumer to see if it will be received.
> bin/kafka-console-consumer.sh--zookeeper nutch1:2181--topic test--from-beginning This was
a message
this is another message
We can see that consumers have processed the data we have entered above;