Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install kafka environment in CentOS7

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to install the kafka environment in CentOS7. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Step 1: install the zookeeper environment

1. Download the zookeeper package zookeeper-3.4.5.tar.gz2, extract it to / usr/local/zookeeper-3.4.53, and create two folders in / usr/local/zookeeper-3.4.5 # mkdir data # data file save directory # mkdir logs # log file save directory

4. Add a new zoo.cfg configuration file under the conf directory as follows

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use / tmp for storage, / tmp here is just # example sakes.dataDir=/usr/local/zookeeper-3.4.5/datadataLogDir=/usr/local/zookeeper-3.4.5/logs# the port at which the clients will connectclientPort=2181

5. Register zookeeper as a centos service

# create a zookeeper.service file in the / usr/lib/systemd/system directory # vim / usr/lib/systemd/system/ zookeeper.service [Unit] Description=zookeeper serviceAfter= network.target [service] Type=forkingExecStart=/usr/local/zookeeper-3.4.5/bin/zkServer.sh startExecReload=/usr/local/zookeeper-3.4.5/bin/zkServer.sh restartExecStop=/usr/local/zookeeper-3.4.5/bin/zkServer.sh stopPrivateTmp= true [install] WantedBy=multi-user.target

6. Insert the JAVA environment path at the beginning of the file / zookeeper/apache-zookeeper-3.5.6-bin/bin/zkEnv.sh:

JAVA_HOME= "/ usr/java/jdk1.8.0_231"

II. Kafka installation

1. Extract the file to / usr/local/kafka_2.12-1.0.2

2. Modify the configuration file / usr/local/kafka_2.12-1.0.2/config/server.properties

Broker.id=1 # unique ID broker.id in the same cluster cannot repeat listeners=PLAINTEXT://localhost:9092 # listening address log.dirs=/opt/kafka_2.11-1.0.1/data # data directory log.retention.hours=168 # kafka data retention time unit is hour default 168h, i.e. 7 days log.retention.bytes=1073741824 # (maximum amount of kafka data, automatic cleaning out of range, used in conjunction with log.retention.hours Note that the maximum value is set not to exceed the disk size) zookeeper.connect:192.168.8.13:2181 # (zookeeper connects ip and port, multiple separated by commas)

3. Register kafka as a service

# create a kafka.service file in the / etc/systemd/system directory # vim / etc/systemd/system/ kafka.service [Unit] Description=kafka serviceAfter= network.target [service] Type=forkingExecStart=/usr/local/kafka_2.12-1.0.2/bin/kafka-server-start.sh-daemon / usr/local/kafka_2.12-1.0.2/config/server.propertiesExecStop=/usr/local/kafka_2.12-1.0.2/bin/kafka-server-stop.shPrivateTmp=true [Install] WantedBy=multi-user.target

4. Set sasl encryption

# 1. The content of the new configuration file vi. / config/kafka_server_jaas.conf# file # username defines a common user name for communication between nodes. User_xxxx is mainly used by the client to connect to kafka, the equal sign is followed by a password, and xxxxx is the user name. Here no word can be different between case and case. Except for the username and password KafkaServer {org.apache.kafka.common.security.plain.PlainLoginModule required username= "admin" password= "admin-sec" user_admin= "admin-sec" user_producer= "prod-sec" user_consumer= "cons-sec" }; # 2. To modify the configuration file when kafka starts, server.properties# my approach is to copy a copy of cp. / config/server.properties. / config/server_sasl.properties# to modify as follows, and add the following at the end of the article: # Note: 192.168.8.13 is my current host ip,9092 is the kafka communication port Other places are consistent with listeners=SASL_PLAINTEXT://192.168.8.13:9092security.inter.broker.protocol=SASL_PLAINTEXTsasl.enabled.mechanisms=PLAINsasl.mechanism.inter.broker.protocol=PLAINauthorizer.class.name=kafka.security.auth.SimpleAclAuthorizerallow.everyone.if.no.acl.found=true# 3. Modify the startup script vi. / bin/kafka-server-start.sh# and find the export KAFKA_HEAP_OPTS# to add the jvm parameter. Note that the kafka_server_jaas.conf file is the security authentication file #-Djava.security.auth.login.config=/usr/local/software/kafka/config/kafka_server_jaas.confif created in the first step before ["x$KAFKA_HEAP_OPTS" = "x"] Then export KAFKA_HEAP_OPTS= "- Xmx1G-Xms1G-Djava.security.auth.login.config=/usr/local/software/kafka/config/kafka_server_jaas.conf" fi on how to install the kafka environment in CentOS7 to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report