note that consumers pull data from the broker on their own initiative, and broker does not proactively send data to consumers.In practical application, the broker general cluster deployment of producer, consumer and Kafka, cooperation between multiple producer, consumer and broker, through zookeeper coordination management, constitute a high-performance distributed message publishing and subscribing system
use Kafka as the core middleware of the system to complete the production of messages and the consumption of messages.
Then: Website Tracking
We can send the Enterprise Portal, user's operation record and other information to Kafka, according to the actual business needs, can be real-time monitoring, or offline processing.
The last one is: Log collection Center
A log collection
write operations are carried in the leader, and followers is used only as a backup (only the leader manages read and write operations, and other replication only supports backup );
Follower must be able to copy leader data in a timely manner;
Increase fault tolerance and scalability.
Basic Structure of Kafka
Kafka message structure
Kafka features
Dist
is a brief introduction to the Kafka cluster construction process:
Prep environment: At least 3 Linux servers (the author is a 5 redhat version of cloud server)
First step: Install Jdk/jre
Step Two: Install Zookeeper (Kafka comes with zookeeper service, but it is recommended that you build a
Kafka's consumption model is divided into two types:1. Partitioned consumption model2. Group Consumption modelA. Partitioned consumption modelSecond, the group consumption modelProducer: PackageCn.outofmemory.kafka;Importjava.util.Properties;ImportKafka.javaapi.producer.Producer;ImportKafka.producer.KeyedMessage;ImportKafka.producer.ProducerConfig;/*** Hello world! **/ Public classKafkaproducer {Private FinalProducerproducer; Public Final StaticString TOPIC = "Test-topic"; PrivateKafkaproducer
data without worrying about where the data is stored)
PartitionPartition is a physical concept, and each topic contains one or more partition.
ProducerResponsible for publishing messages to Kafka broker
ConsumerThe message consumer, the client that reads the message to Kafka broker.
Consumer GroupEach consumer belongs to a specific consumer group (the group name can be specified for each co
. Even such consistency is hard to guarantee (refer to the original article ). Kafka is saved by the consumer, and do not confirm the status. In this way, although the consumer burden is heavier, it is actually more flexible. Message re-processing is required for any reason on the consumer, and can be obtained from the broker again.
Kafka producer has an asynchronous sending operation. This is to improve pe
Apache Kafka Series (i) StartApache Kafka Series (ii) command line tools (CLI)Apache Kafka Command Line INTERFACE,CLI, hereinafter referred to as the CLI.1. Start KafkaStarting Kafka takes two steps:1.1. Start Zookeeper[Email protected] kafka_2. -0.11. 0.0] # Bin/
elected leader must be able to provide the message. Most of the distributed systems use the majority voting law to choose the new leader, and for most voting rules, it is the choice of the most suitable as leader according to the condition of all replica nodes. Kafka does not use this method.Kafaka dynamically maintains a set of copies of a synchronous state (a set of In-sync replicas), called an ISR, in which the nodes in this set are highly consist
can specify a group name for each consumer. If this parameter is not specified, it belongs to the default group.
Kafka Topology
I can see. A Kafka cluster consists of several producers, consumer grouper, broker, and zookeeper. Kafka manages cluster configurations through zook
Original link: Kafka combat-flume to KAFKA1. OverviewIn front of you to introduce the entire Kafka project development process, today to share Kafka how to get the data source, that is, Kafka production data. Here are the directories to share today:
Data sources
Flume to
offset of the last message locally and register the offset with zookeeper intermittently. This shows that the consumer client is also lightweight.Message delivery mechanismfor JMS implementations, the message transfer guarantee is straightforward: there is only one time (exactly once). Slightly different in Kafka:1) at the most once: up to once, this is similar to the "non-persistent" message in JMS. Send
is to save several copies of each partition (Replica_factor specifies the number of replicas). Each copy is saved on a different broker. A copy of the interim is acting as a copy of leader, handling producer and consumer requests. The other replicas act as follower roles, and the Kafka Controller is responsible for ensuring synchronization with the leader. If the broker where the leader is located, Contorller will detect and then re-elect the new lea
data from the pagecache kernel cache to the NIC buffer? The sendfile system function does this. Obviously, this will greatly improve the efficiency of data transmission. In Java, the corresponding function call is
FileChannle.transferTo
In addition, Kafka further improves the throughput by compressing, transmitting, and accessing multiple data entries.The consumption status is maintained by the consumer.
The consumption status of
1. Start the Zookeeper server./zookeeper-server-start.sh/opt/cx/kafka_2.11-0.9.0.1/config/zookeeper.properties2. Modify the Broker-1,broker-2 configurationbroker.id=1listeners=plaintext://:9093 # The port the socket server listens onport=9093log.dirs=/opt/cx/kafka/ Kafka-logs-1broker.id=2listeners=plaintext://:9094# th
1.JDK 1.82.zookeeper 3.4.8 Decompression3.kafka ConfigurationIn the Kafka decompression directory under a config folder, which is placed in our configuration fileConsumer.properites consumer configuration, this profile is used to configure the consumers opened in section 2.5, where we use the defaultProducer.properties producer configuration, this configuration f
Kafka Single-Machine deploymentKafka is a high-throughput distributed publish-subscribe messaging system, Kafka is a distributed message queue for log processing by LinkedIn, with large log data capacity but low reliability requirements, and its log data mainly includes user behaviorEnvironment configuration: CentOS Release 6.3 (Final) JDK version: Jdk-6u31-linux-x64-rpm.binzookeeper version:
number of replicas). Each copy is saved on a different broker. A copy of the interim is acting as a copy of leader, handling producer and consumer requests. The other replicas act as follower roles, and the Kafka Controller is responsible for ensuring synchronization with the leader. If the broker where the leader is located, Contorller will detect and then re-elect the new leader--with the help of zookeeper
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.