Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Kafka configuration

Shulou Source: shulou.com Published: 2022-06-03 05:02:57 10月04日 Update

1. Three-node host environment:

# Red Hat Enterprise Linux Server release 7.5

192.168.154.128 my1.db.com my1

192.168.154.129 my2.db.com my2

192.168.154.130 my3.db.com my3

two。 Configure jdk:

Tar xvzf jdk-8u201-linux-x64.tar.gz

Mv jdk1.8.0_201 / usr/local/jdk

Vi .bash _ profile

JAVA_HOME=/usr/local/jdk

PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

Source .bash _ profile

3. Download zookeeper:

Http://zookeeper.apache.org/releases.html

Tar xvzf zookeeper-3.4.13.tar.gz

Mv zookeeper-3.4.13 / usr/local/zookeeper

4. Configure zookeeper:

Edit the configuration file:

Vi / usr/local/zookeeper/conf/zoo.cfg

TickTime=2000

DataDir=/usr/local/zookeeper/data

ClientPort=2181

InitLimit=5

SyncLimit=2

DataLogDir=/usr/local/zookeeper/log

Server.1=my1:2888:3888

Server.2=my2:2888:3888

Server.3=my3:2888:3888

Create a directory:

Mkdir-p / usr/local/zookeeper/data/

Mkdir-p / usr/local/zookeeper/log/

Echo 1 > / usr/local/zookeeper/data/myid

Echo 2 > / usr/local/zookeeper/data/myid

Echo 3 > / usr/local/zookeeper/data/myid

5. Start zookeeper:

/ usr/local/zookeeper/bin/zkServer.sh start / usr/local/zookeeper/conf/zoo.cfg

View status:

/ usr/local/zookeeper/bin/zkServer.sh status / usr/local/zookeeper/conf/zoo.cfg

6. Download kafka:

Http://kafka.apache.org/downloads

Tar xvzf kafka_2.12-2.0.0.tgz

Mv kafka_2.12-2.0.0 / usr/local/kafka

Mkdir-p / usr/local/kafka/data

Edit the configuration file:

Vi / usr/local/kafka/config/server.properties

Broker.id=1

Listeners=PLAINTEXT://my1:9092

Zookeeper.connect=192.168.154.128:2181192.168.154.129:2181192.168.154.130:2181

Delete.topic.enable=true

Start kafka:

/ usr/local/kafka/bin/kafka-server-start.sh-daemon / usr/local/kafka/config/server.properties

View confirmation:

Jps

7. Test kafka:

Create a test topic:

/ usr/local/kafka/bin/kafka-topics.sh-- zookeeper 192.168.154.128 partitions 2181192.168.154.129 create-- topic test-topic-- partitions 3-- replication-factor 3

View topic:

/ usr/local/kafka/bin/kafka-topics.sh-- zookeeper 192.168.154.128 list 2181192.168.154.129 list

/ usr/local/kafka/bin/kafka-topics.sh-- zookeeper 192.168.154.128 topic test-topic 2181192.168.154.129 describe-- topic test-topic

Delete topic:

/ usr/local/kafka/bin/kafka-topics.sh-- zookeeper 192.168.154.128 topic test-topic 2181192.168.154.129 delete-- topic test-topic

Producer sends a message:

/ usr/local/kafka/bin/kafka-console-producer.sh-broker-list my1:9092,my2:9092,my3:9092-topic test-topic

Consumer consumption message:

/ usr/local/kafka/bin/kafka-console-consumer.sh-bootstrap-server my1:9092,my2:9092,my3:9092-topic test-topic-from-beginning

Producer Throughput Test:

/ usr/local/kafka/bin/kafka-producer-perf-test.sh-topic test-topic-num-records 500000-record-size 500000-throughput-1-producer-props bootstrap.servers=192.168.154.128:9092192.168.154.129:9092192.168.154.130:9092 acks=1

Tags: Configuration testing files messages hosts throughput status environment producers directories nodes throughput consumption production Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MariaDB OPPO Reno Linux Apple