Address: http://blog.csdn.net/honglei915/article/details/37564521
Kafka is a distributed, partitioned, and reproducible message system. It provides common messaging system functions, but has its own unique design. What is this unique design?
First, let's look at several basic terms of the message system:
Kafka sends messagesTopicUnit.
The program that publishes messages to the
Kafka resolution
Www.jasongj.com/2015/01/02/Kafka Depth Analysis
Terminology:brokerThe Kafka cluster contains one or more servers, which are called broker TopicEach message published to the Kafka Cluster has a category, which is called topic. (Physically different
Kafka Quick Start, kafkaStep 1: Download the code
Step 2: Start the server
Step 3: Create a topic
Step 4: Send some messages
Step 5: Start a consumer
Step 6: Setting up a multi-broker cluster
The configurations are as follows:
The "leader" node is responsible for all read and write operations on specified partitions.
"Replicas" copies the node list of this partition log, whether or
follower to achieve load balancing and failover.
Why consumer groups are neededFirst, there are two traditional models: Queue and topic. The queue guarantees that only one consumer can consume content; topic is broadcast to all consumers and let them consume.At design time, a message can be consumed by different consumer groups and consumed only once per consumer group. This way, if there is only one
Data acquisition of Kafka and Logstash
Based on Logstash run-through Kafka still need to pay attention to a lot of things, the most important thing is to understand the principle of Kafka.
Logstash Working principleSince Kafka uses decoupled design ideas, it is not the original publication subscription, t
": {" type": "Composer", "url": "Https://packagist.phpcomposer.com" } }, "require": { "nmred/kafka-php": "v0.2.0.7"} }
Determine port and topic, view Kafka version number
I chose the local port is 9092,topic is test1, while viewing my local Kafka
data from Kafka is faster than getting data from HDFs because zero copy is the way it is.2: The actual combat sectionKafka + Spark streaming clusterPremise:Spark Installation Successful,spark 1.6.0Zookeeper Installation SuccessKafka Installation SuccessSteps:1: First start the ZK on three machines, then three machines also start Kafka,2: Create topic test on Kaf
formed a cluster: > bin/zookeeper-server-start.sh config/zookeeper.properties due to Zookee When the per cluster is started, each node tries to connect to the other nodes in the cluster, and the first boot must not be connected to the back, so the printed part of the exception is negligible. After selecting a leader, the cluster finally stabilized. Other nodes may also appear to have similar problems, which belong to normal.third, build Kafka cluste
environment variables accordingly.Install Kafka
Download the Kafka installation package from the official website, unzip the installation: official site address: http://kafka.apache.org/downloads.html
tar zxvf kafka_2.11-0.8.2.2.tgzmv kafka_2.11-0.8.2.2 kafkacd kafkaFunction verification
1. Start Zookeeper and use the script in the installation package to start a single-node Zookeeper instance:
bin/zookeep
-start.bat.. /.. /config/server1.properties
Kafka-server-start.bat.. /.. /config/server2.properties
Kafka-server-start.bat.. /.. /config/server3.properties
If you start to have an error, one is that the VM parameter is too large, another may be your port has not been modified. It's good to see the error.
And then we sign up for a topic, called Replicationtest.
: sudo tar-xvzf kafka_2.11-0.8.2.2.tgz-c/usr/local
After typing the user password, Kafka successfully unzip, continue to enter the following command:
cd/usr/local jump to/usr/local/directory;
sudo chmod 777-r kafka_2.11-0.8.2.2 Get all the execution rights of the directory; gedit ~/.bashrc Open Personal configuration end add E Xport kafka_home=/usr/local/kafka_2.11-0.8.2.2Export path= $PATH: $
kafka--Distributed Messaging SystemArchitectureApache Kafka is a December 2010 Open source project, written in the Scala language, using a variety of efficiency optimization mechanisms, the overall architecture is relatively new (push/pull), more suitable for heterogeneous clusters.Design goal:(1) The cost of data access on disk is O (1)(2) High throughput rate, hundreds of thousands of messages per second
configured, for example:
listeners=plaintext://192.168.180.128:9092. And make sure that port 9092 of the server can access3.zookeeper.connect Kafka the address of the zookeeper to be connected, the address that needs to be configured to zookeeper, because this time uses Kafka high version comes with the zookeeper, uses the default configuration tozookeeper.connect=localhost:21814. Run Zookeeper
There is a simple demo of spark-streaming, and there are examples of Kafka successful running, where the combination of both, is also commonly used one.
1. Related component versionFirst confirm the version, because it is different from the previous version, so it is necessary to record, and still do not use Scala, using Java8,spark 2.0.0,kafka 0.10.
2. Introduction of MAVEN PackageFind some examples of a c
Kafka the number of partitions is not the more the better? Advantages of multiple partitionsKafka uses partitioning to break topic messages to multiple partition distributions on different brokers, enabling high throughput of producer and consumer message processing. Kafka's producer and consumer can operate in parallel in multiple threads, and each thread is processing a partitioned data. So partitioning i
-F.Output Configuration InstanceThe following configuration enables basic use of the Kafka producer. For more detailed configuration of the producer, see the manufacturer section of the Kafka official documentation.Output { Kafka { "localhost: 9092" # producer "nginx-access-log" # setting writes to Kafka
"
Maven compilation Configuration
3. Implement Topology
The following is a simple example of Topology (Java version ).
1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637383940
Public class StormTopology {// Topology close command (message control passed through external) public static boolean shutdown = false; public static void main (String [] args) {// register ZooKeeper host BrokerHosts brokerHosts = new ZkHosts ("hd182: 2181, hd185: 2181, hd128: 218
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.