Installation of kafka under Linux (Centos7) cluster

Download the installation package

  • scala -version: Check the version of scala

insert image description here

  • Download the corresponding installation package from the official website: DOWNLOAD

insert image description here

Upload the installation package to Linux

This step will be much more convenient with Xftp7

  • /usr/localCreate a new kafka directory under the directory
[root@master ~]# cd /usr/local
[root@master local]# mkdir kafka
  • kafka-logsCreate a new folder in the kafka directory
[root@master local]# cd kafka
[root@master kafka]# mkdir kafka-logs
  • Upload the installation package in the kafka directory kafka_2.12-3.3.1.tgz(I use Xftp7 to drag and drop directly)

insert image description here

Unzip the installation package

[root@master kafka]# cd /usr/local
[root@master kafka]# tar -zxvf kafka_2.12-3.3.1.tgz

insert image description here

Configure server.properties

  • Enter the config folder in the unzipped folder
[root@master kafka]# cd kafka_2.12-3.3.1/config
  • Edit server.properties
[root@master config]# vi server.properties

Change the following places to the ip address of your own virtual machine
insert image description here
insert image description here
Press i to modify, press Esc after modification: wq to save and exit

open kafka

  • Start zookeeper first ( open another terminal )
[root@master kafka_2.12-3.3.1]# bin/zookeeper-server-start.sh config/zookeeper.properties  &
  • Open kafka again ( open another terminal )
[root@master kafka_2.12-3.3.1]# bin/kafka-server-start.sh config/server.properties &
  • jpsView progress with
    insert image description here

topic-related

  • Create a new topic: topictest (Note: master is the name of the cluster host, try replacing the error with localhost)
[root@master kafka_2.12-3.3.1]#   bin/kafka-topics.sh --create --bootstrap-server master:9092 --replication-factor 1 --partitions 1 --topic topictest
  • View topic list
[root@master kafka_2.12-3.3.1]# bin/kafka-topics.sh --list --bootstrap-server master:9092

insert image description here

  • Start the command line producer program (test) ( open another terminal )
[root@master kafka_2.12-3.3.1]# bin/kafka-console-producer.sh  --broker-list  master:9092  --topic  topictest

Type some words:
insert image description here

  • Start the command line consumer program (test) ( open another terminal )
[root@master kafka_2.12-3.3.1]# bin/kafka-console-consumer.sh  --bootstrap-server   master:9092  --topic  topictest  --from-beginning

Successfully received message:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_54218079/article/details/127261985