1. Create kafka folder in root (service1, service2, service3)
[root@localhost /]# mkdir kafka
2. Upload files to the Service1 server using Xshell: upload kafka_2.9.2-0.8.1.1. TGZ to the /software folder
3. Remote copy Transfers /software/kafka_2.9.2-0.8.1.1. TGZ in Service1 to service2 and service3
[root@localhost software]# scp -r /software/kafka_2.9.2-0.8.1.1.tgz [email protected]:/software/
[root@localhost software]# scp -r /software/kafka_2.9.2-0.8.1.1.tgz [email protected]:/software/
Copy /software/kafka_2.9.2-0.8.1.1. TGZ to /kafka/ (service1, service2, service3)
[root@localhost software]# cp /software/kafka_2.9.2-0.8.1.1. TGZ /kafka/
Kafka_2.9.2-0.8.1.1. TGZ (service1, service2, service3)
[root@localhost /]# cd /kafka/
[root@localhost kafka]# tar -zxvf kafka_2.9.2-0.8.1.1.tgz
5. Create kafka message catalog (service2 service1, service3 create)
[root@localhost kafka]# mkdir kafkaLogs
6. Modify the configuration files of the kafka (service1, service2, service3 configuration)
[root @ localhost /] # CD/kafka/kafka_2. 9.2 0.8.1.1 /
9.2 0.8.1.1] [root @ localhost kafka_2. # config/CD
[root@localhost config]# ls
consumer.properties log4j.properties producer.properties server.properties test-log4j.properties tools-log4j.properties zookeeper.properties
[root@localhost config]# vi server.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the “License”); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# www.apache.org/licenses/LI…
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an “AS IS” BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# see kafka.server.KafkaConfig for additional details and defaults
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker.
Broker.id =0 — Unique identifier
############################# Socket Server Settings #############################
# The port the socket server listens on
Port =19092 — TCP port currently provided by the broker. Default: 9092
# Hostname the broker will bind to. If not set, the server will bind to all interfaces
Host. Name =192.168.2.213 — if kafka fails DNS resolution, the file handle will be released. If kafka fails DNS resolution, the file handle will be released. It can process more than one hundred thousand data per second. Even if the failure rate is one in ten thousand, 10 file handles will be leaked every second. Soon, the number of handles will be leaked out, and it will exceed the number of open files in Linux
# Hostname the broker will advertise to producers and consumers. If not set, it uses the
# value for “host.name” if configured. Otherwise, it will use the value returned from
# java.net.InetAddress.getCanonicalHostName().
#advertised.host.name=
# The port to publish to ZooKeeper for clients to use. If this is not set,
# it will publish the same port that the broker binds to.
#advertised.port=
# The number of threads handling network requests
Num.net work.threads=2 — The number of threads that the broker processes, normally without processing
# The number of threads doing disk I/O
Num.io. Threads =8 — The number of threads that broker IO processes must be greater than the number of directories in log.dirs
# The send buffer (SO_SNDBUF) used by the socket server
Socket.sess.buffer. Bytes =1048576 — Put the sent message into the buffer and send it once when a certain amount has been reached
# The receive buffer (SO_RCVBUF) used by the socket server
Socket, the receive buffer. Bytes = 1048576 — — kafka accept message buffer, as acceptable number reaches a certain amount of time and then written to disk
# The maximum size of a request that the socket server will accept (protection against OOM)
Socket.request.max. bytes=104857600 — The maximum number of messages that Kafka can send or request cannot exceed the Size of the Java stack
############################# Log Basics #############################
# A comma seperated list of directories under which to store log files
Log. dirs=/kafka/kafkaLogs — Multiple directories can be used, separated
# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
Num. Partitions =2 — The number of default partitions for a topic
############################# Log Flush Policy #############################
# Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
# 1. Durability: Unflushed data may be lost if you are not using replication.
# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.
# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000
# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000
############################# Log Retention Policy #############################
# The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.
# The minimum age of a log file to be eligible for deletion
log.retention.hours=168
Message.max. byte=5048576 — Maximum kafka size for each message
Default. The replication. Factor = 2 – the default replicator, only a copy of the default message is not very safe, so set to 2, if the news of a partition fails, we can use another message service
Replica.fetch. Max. byte=5048576 — Maximum size of a kafka message
# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
# segments don’t drop below log.retention.bytes.
#log.retention.bytes=1073741824
# The maximum size of a log segment file. When this size is reached a new log segment will be created.
Log.segment. bytes=536870912 — Maximum size for message persistence
# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=60000
# By default the log cleaner is disabled and the log retention policy will default to just delete segments after their retention expires.
# If log.cleaner.enable=true is set the cleaner will be enabled and individual logs can then be marked for log compaction.
Log.cleaner. enable=false — do not use log compression
############################# Zookeeper #############################
# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. “127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002”.
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
Zookeeper. Connect = 192.168.2.211:2181192168 2.212:2181192168 2.213:2181 – zk address
# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=1000000
7. Start the Kafka service
[root@localhost bin]# ./kafka-server-start.sh -daemon .. /config/server.properties
[root@localhost bin]# jps
27413 Kafka
27450 Jps
17884 QuorumPeerMain
8. Verify the Kafka cluster
[root@localhost bin]# ./kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 2 –partitions 1 –topic test
Created topic “test”.
9. Start producer on Service1
Sh –broker-list 192.168.2.211:9092 –topic test./kafka-console-producer
[root@localhost bin]#./kafka-console-producer.sh –broker-list 192.168.2.211:9092 –topic test
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: Seewww.slf4j.org/codes.html#… for further details.
10. Start the Consumer program on Service2
[root@localhost bin]# ./kafka-console-consumer.sh –zookeeper localhost:2181 –topic test –from-beginning
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: Seewww.slf4j.org/codes.html#… for further details.
11. Sending the message hello Jeesz from producer
[root@localhost bin]# ./kafka-console-consumer.sh –zookeeper localhost:2181 –topic test –from-beginning
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: Seewww.slf4j.org/codes.html#… for further details.
hello jeesz
12. Received the message from the Consumer
[root@localhost bin]# ./kafka-console-consumer.sh –zookeeper localhost:2181 –topic test –from-beginning
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: Seewww.slf4j.org/codes.html#… for further details.
hello jeesz
Willing to understand the framework technology or source code friends directly please: 2042849237