鲲鹏服务器安装Kafka

news2024/11/25 6:39:52

由于项目需求,需要在鲲鹏云主机上安装Kafka,并且要求安装的版本为2.3.X。下面主要从以下几个步骤说明如何安装:
1、下载kafka的安装文件
2、上传到服务器
3、修改配置
4、启动
5、使用工具测试

服务器信息

CPU信息

[root@ecs02 ~]# lscpu
Architecture:                    aarch64
CPU op-mode(s):                  64-bit
Byte Order:                      Little Endian
CPU(s):                          32
On-line CPU(s) list:             0-31
Thread(s) per core:              1
Core(s) per socket:              16
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       HiSilicon
Model:                           0
Model name:                      Kunpeng-920
Stepping:                        0x1
CPU max MHz:                     2400.0000
CPU min MHz:                     2400.0000
BogoMIPS:                        200.00
L1d cache:                       2 MiB
L1i cache:                       2 MiB
L2 cache:                        16 MiB
L3 cache:                        64 MiB
NUMA node0 CPU(s):               0-15
NUMA node1 CPU(s):               16-31
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Not affected
Vulnerability Spectre v1:        Mitigation; __user pointer sanitization
Vulnerability Spectre v2:        Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma dcpop asimd
                                 dp asimdfhm

操作系统信息

[root@ecs02 ~]# cat /etc/kylin-release 
Kylin Linux Advanced Server release V10 (Tercel)

Java版本信息

[root@ecs02 ~]# java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

下载Kafka安装文件

访问apache官网,找到kafka下载主页https://kafka.apache.org/downloads,下载完成后得到文件kafka_2.12-2.3.1.tgz。这里可以根据自己的需求下载对应的版本即可,如果需要下载Zookeeper,注意版本需要和Kafka的版本对应,可以从下载的Kafka包中找到对应的Zookeeper版本,比如这里使用的Zookeeper对应的版本为3.4.14
在这里插入图片描述

上传到服务器

将该文件上传到服务器目录/data/public/,远程登录服务器,执行如下命令

cd /data/public/

解压文件,执行如下命令

tar -xvf kafka_2.12-2.3.1.tgz

修改配置

解压后得到/data/public/kafka_2.12-2.3.1/,进入该目录,修改server.properties,搜索关键字listeners=PLAINTEXT,将该行修改为:

listeners=PLAINTEXT://192.168.1.100:9092

注意这里的192.168.1.100为该鲲鹏主机的IP地址,也就是后面应用可以访问到的地址,不要配置为内网无法访问到的地址。完整配置文件为:

# 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
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# 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

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://10.16.39.14:9092

# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092

# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL

# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3

# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8

# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400

# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400

# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600


############################# Log Basics #############################

# A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs

# 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=1

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1

############################# Internal Topic Settings  #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1

############################# 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 excessive 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 due to age
log.retention.hours=168

# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#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=1073741824

# 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=300000

############################# 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=localhost:2181

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000


############################# Group Coordinator Settings #############################

# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=0

启动

启动Kafka,需先启动Zookeeper,然后启动Kafka,这里使用Kafka自带的Zookeeper,执行如下命令

nohup /data/public/kafka_2.12-2.3.1/bin/zookeeper-server-start.sh /data/public/kafka_2.12-2.3.1/config/zookeeper.properties > /dev/null 2>&1 &

然后启动Kafka,执行如下命令:

nohup /data/public/kafka_2.12-2.3.1/bin/kafka-server-start.sh /data/public/kafka_2.12-2.3.1/config/server.properties > /dev/null 2>&1 &

启动完成后,通过netstat命令检查端口是否开启

[root@test public]# netstat -nltp | grep 9092
tcp6       0      0 10.16.39.14:9092        :::*                    LISTEN      1569191/java        
[root@test public]# netstat -nltp | grep 2181
tcp6       0      0 :::2181                 :::*                    LISTEN      1568749/java          

或者执行

[root@test public]# netstat -nltp | grep '2181\|9092'
tcp6       0      0 10.16.39.14:9092        :::*                    LISTEN      1569191/java        
tcp6       0      0 :::2181                 :::*                    LISTEN      1568749/java        

以上表名Kafa已经成功启动。

开启远程访问

开启端口访问,执行如下命令即可:

firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=9092/tcp --permanent
firewall-cmd --reload

远程访问

Kafka客户端工具可以使用OffsetExplorer2

Java端访问可以参看:https://support.huaweicloud.com/usermanual-kafka/kafka-ug-0010.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2058202.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

[数据集][目标检测]瞳孔虹膜检测数据集VOC+YOLO格式8768张2类别

数据集格式:Pascal VOC格式YOLO格式(不包含分割路径的txt文件,仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数):8768 标注数量(xml文件个数):8768 标注数量(txt文件个数):8768 标注…

24款保时捷帕拉梅拉升级原厂360全景影像案例

24款保时捷帕拉梅拉升级原厂360全景影像后,车辆的前后左右都能被清晰地拍摄下来,并通过车载屏幕实时显示。这可以帮助驾驶员更好地了解车辆周围的环境,从而提高驾驶安全性和便利性。以下是一些可能的效果展示: • 全景视图&#…

wincc报警如何通过短信发送给手机

单位使用WINCC上位机监控现场,需要把报警信息发送到指定手机上,能否实现?通过巨控GRMOPC系列远程智能控制终端,简单配置即可实现wincc报警短信传送到手机。配置过程无需任何通讯程序,也不要写任何触发脚本。 GRMOPC模…

Vue的遍历(列表、对象、字符串、数字)、key的原理

目录 1 遍历(列表、对象、字符串、数字)2. key的原理2.1 key使用index2.1 key使用数据的唯一id2.3 key的原理 3. 列表过滤4. 列表排序 1 遍历(列表、对象、字符串、数字) key可以使用数据的唯一字段(最好)&#xff0c;也可以使用index(默认) 使用示例: <!DOCTYPE html>…

数据科学已死?

既然有了人工智能&#xff0c;训练自己的机器学习模型是否还值得&#xff1f; 既然有了人工智能&#xff0c;学习 Python 是否还值得&#xff1f; 既然有了人工智能&#xff0c;KNIME 还在营业吗&#xff1f; 既然有了人工智能&#xff0c;数据科学是否仍然需要&#xff1f;…

【深度学习与NLP】——Transformer架构解析

目录 第一章:Transformer背景介绍 1.1 Transformer的诞生 1.2 Transformer的优势 1.3 Transformer的市场 第二章:Transformer架构解析 2.1 认识Transformer架构 2.1.1 Transformer模型的作用 2.1.2 Transformer总体架构图 2.2 输入部分实现 2.2.1 文本嵌入层的作用 …

维护和升级LabVIEW程序

在维护和升级LabVIEW程序时&#xff0c;需要全面考虑代码的现状和未来的需求。以下是各个方面的详细注意事项&#xff0c;以确保程序能够在稳定性和性能方面得到提升。 1. 理解现有代码: 深入代码分析: 仔细阅读现有的代码&#xff0c;了解其逻辑结构、数据流、和控制流程。关注…

众善慈善机构:帮助贫困地区的人们提高自身的就业能力和创业能力

众善慈善机构是一家致力于帮扶和脱贫的慈善机构&#xff0c;主要致力于帮助贫困地区的人们改善生活条件&#xff0c;提高生活质量。 众善慈善机构的主要帮扶对象是贫困地区的儿童、老人和残疾人。他们通过开展各种救助项目&#xff0c;为这些人群提供生活物资、教育、医疗等方面…

【附源码】Python :PYQT界面点击按钮随机变色

系列文章目录 Python 界面学习&#xff1a;PYQT界面点击按钮随机变色 文章目录 系列文章目录一、项目需求二、源代码三、代码分析3.1 导入模块&#xff1a;3.2 定义App类&#xff1a;3.3 构造函数&#xff1a;3.4 初始化用户界面&#xff1a;3.5 设置窗口属性&#xff1a;3.6 …

GDB的基本使用

我有话说 因为时间和精力原因&#xff0c;本文写的虎头蛇尾了&#xff0c;除了启动调试与程序执行以外只有少量截图演示&#xff0c;只是简单的说明。如果有需要可以联系我&#xff0c;我有时间的话会把演示补上&#xff0c;谢谢理解。 启动调试与程序执行 启动调试并传递参数…

哈啰出行Java开发工程师一面面经(校招)

牛客网最新面经分享面试过程&#xff1a; 小编为参加校招、秋招、金九银十面试季的小伙伴们准备了一份很全很详细的java面试宝典&#xff08;包含各个大厂真题以及最常见的八股文含答案&#xff09;&#xff0c;由于平台篇幅原因&#xff0c;就不在这里一一展示了&#xff0c;…

企业高性能web服务器之nginx篇

文章目录 Nginx核心配置location 使用详情location之精确匹配location之区分大小写location之不区分大小写location之文件名后缀 Nginx账户认证功能自定义错误页面自定义错误日志检测文件是否存在长连接下载服务器 Nginx高级配置Nginx的状态页Nginx 压缩功能Nginx 变量使用Ngin…

5G+智慧农业大数据解决方案

1. 5G智慧农业大数据概述 5G智慧农业大数据方案融合5G网络、大数据等技术&#xff0c;推动农业向智能化、信息化发展。方案包含农产品质量追溯、农业物联网、电子商务、休闲农业等多个平台&#xff0c;全面支撑乡村振兴战略。 2. 乡村振兴战略的政策背景 2022年中央一号文件…

什么是黄金期权?黄金期权合约详解

想要了解什么是黄金期权首先要了解一下黄金期货。黄金期货是以现货黄金为标的物的期货品种&#xff0c;其交易代码通常为Au。而黄金期权&#xff0c;又称为黄金期货期权&#xff0c;是一种期权合约&#xff0c;其标的物是黄金期货合约本身&#xff0c;而非黄金现货。这意味着期…

词向量(One-Hot Encoding、Word Embedding、Word2Vec)

词向量&#xff0c;顾名思义&#xff0c;用向量表示单词。 1、One-Hot Encoding One-Hot编码&#xff0c;又称为一位有效编码&#xff0c;主要是采用N位状态寄存器来对N个状态进行编码&#xff0c;每个状态都由他独立的寄存器位&#xff0c;并且在任意时候只有一位有效。 One…

回归预测|基于雪消融优化相关向量机的数据回归预测Matlab程序SAO-RVM 多特征输入单输出 SAO-RVM

回归预测|基于雪消融优化相关向量机的数据回归预测Matlab程序SAO-RVM 多特征输入单输出 SAO-RVM 文章目录 前言回归预测|基于雪消融优化相关向量机的数据回归预测Matlab程序SAO-RVM 多特征输入单输出 SAO-RVM 一、SAO-RVM模型1. 基本模型原理2. 贝叶斯框架3. 模型优化流程4. 总…

AI 智能体:从普通人到《黑神话:悟空》,保姆级教程让你瞬间变身!

大家好&#xff0c;我是木川 今天还没下班&#xff0c;就看到一款名为《黑神话:悟空》的游戏火爆全网&#xff0c;唤醒了无数玩家对大圣孙悟空的崇拜与向往。游戏中&#xff0c;悟空的七十二变让人叹为观止&#xff0c;但你是否想过&#xff0c;借助AI的力量&#xff0c;我们也…

Kimi + 小爱音箱,我家宝贝的新聊天伙伴。

给儿子制作了一个特别版的小爱音箱&#xff0c;它集成了 Kimi 大模型&#xff0c;他对这个聪明的音箱简直着迷到不行&#xff0c;整天跟它聊天&#xff0c;问东问西。 希望这个玩具不仅能激发起他对 AI 的浓厚兴趣&#xff0c;最好还能让他对我这个老爸有那么一点点的崇拜&…

函数进阶—python

一、函数如何返回多个返回值 如果想让一个函数有多个返回值&#xff0c;该怎么办&#xff1f; 返回多个数据&#xff0c;按照返回值的顺序&#xff0c;用对应顺序的多个变量接收即可&#xff0c;变量之间用逗号隔开&#xff0c;支持不同类型的数据return&#xff0c;如下列代…

GATK SampleList接口介绍

在 GATK 中&#xff0c;SampleList 是一个接口&#xff0c;用于表示一个样本列表。这些样本通常是在基因组分析过程中被处理的不同生物样本。SampleList 接口提供了访问这些样本的一些基本方法&#xff0c;通常用于多样本分析任务&#xff0c;比如变异检测或基因组重测序。 Sa…