当前位置: 首页 > article >正文

kafka单机配置

kafka单机配置

    • 1. 下载kafka和zookeeper
    • 2. 上传服务器解压
    • 3. 创建数据保存的目录
    • 4. 部署JDK
    • 5. 部署zookeeper
      • 5.1 配置zookeeper配置文件
      • 5.2 运行zookeeper
      • 5.3 查看zookeeper进程
      • 5.4 使用zookeeper客户端连接
    • 6. 部署kafka
      • 6.1 配置kafka配置文件
      • 6.2 启动kafka
      • 6.3 查看kafka进程

1. 下载kafka和zookeeper

下载kafka链接:
https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz
下载zookeeper链接:
https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz

2. 上传服务器解压

tar xf apache-zookeeper-3.7.1-bin.tar.gz
tar xf kafka_2.13-3.4.0

[root@kafka1 ~]# ll
总用量 116160
drwxr-xr-x  7 root root       145 51 12:43 apache-zookeeper-3.7.1-bin
-rw-r--r--  1 root root  12649765 51 12:37 apache-zookeeper-3.7.1-bin.tar.gz
drwxr-xr-x  8 root root       117 51 13:09 kafka_2.13-3.4.0
-rw-r--r--  1 root root 106290956 51 13:06 kafka_2.13-3.4.0.tgz

3. 创建数据保存的目录

mkdir /data/zookeeper
mkdir -p /data/kafka

4. 部署JDK

服务运行需要JDK环境
此处使用阿里云的yum源安装JDK,JDK的安装包很多选择一个即可

[root@kafka1 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0   5934      0 --:--:-- --:--:-- --:--:--  5936
[root@kafka1 ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@kafka1 ~]#
[root@kafka1 ~]#
[root@kafka1 ~]# yum makecache

[root@kafka1 ~]# yum provides java
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com

.......

选择其中一个安装即可

[root@kafka1 ~]# yum -y install java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64

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

kafka运行需要zookeeper,因此需要先部署并运行zookeeper

5. 部署zookeeper

cd apache-zookeeper-3.7.1-bin/conf/
cp zoo_sample.cfg zoo.cfg

5.1 配置zookeeper配置文件

vim zoo.cfg
#修改数据目录
dataDir=/data/zookeeper

zoo.cfg完整文件

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

5.2 运行zookeeper

[root@kafka1 apache-zookeeper-3.7.1-bin]# bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /root/apache-zookeeper-3.7.1-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

5.3 查看zookeeper进程


[root@kafka1 apache-zookeeper-3.7.1-bin]# ps -ef | grep zookeeper
root       1862      1  4 12:54 pts/0    00:00:00 java -Dzookeeper.log.dir=/root/apache-zookeeper-3.7.1-bin/bin/../logs -Dzookeeper.log.file=zookeeper-root-server-kafka1.log -Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -cp /root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/classes:/root/apache-zookeeper-3.7.1-bin/bin/../build/classes:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../build/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-jute-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/snappy-java-1.1.7.7.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-reload4j-1.7.35.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-api-1.7.35.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_common-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/reload4j-1.2.19.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-unix-common-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-epoll-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-classes-epoll-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-resolver-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-handler-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-common-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-codec-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-buffer-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/metrics-core-4.1.12.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jline-2.14.6.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-ajax-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-servlet-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-server-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-security-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-io-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-http-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-databind-2.13.2.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-core-2.13.2.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-annotations-2.13.2.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/commons-cli-1.4.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/audience-annotations-0.12.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../conf: -Xmx1000m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /root/apache-zookeeper-3.7.1-bin/bin/../conf/zoo.cfg
root       1895   1287  0 12:54 pts/0    00:00:00 grep --color=auto zookeeper

5.4 使用zookeeper客户端连接

客户端连接需指定服务器的ip地址和端口号

[root@kafka1 apache-zookeeper-3.7.1-bin]# bin/zkCli.sh -server 192.168.44.180:2181
/usr/bin/java
Connecting to 192.168.44.180:2181
2023-05-01 12:56:36,054 [myid:] - INFO  [main:Environment@98] - Client environment:zookeeper.version=3.7.1-a2fb57c55f8e59cdd76c34b357ad5181df1258d5, built on 2022-05-07 06:45 UTC
2023-05-01 12:56:36,056 [myid:] - INFO  [main:Environment@98] - Client environment:host.name=kafka1
2023-05-01 12:56:36,056 [myid:] - INFO  [main:Environment@98] - Client environment:java.version=1.8.0_362
2023-05-01 12:56:36,056 [myid:] - INFO  [main:Environment@98] - Client environment:java.vendor=Red Hat, Inc.
2023-05-01 12:56:36,056 [myid:] - INFO  [main:Environment@98] - Client environment:java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64/jre
2023-05-01 12:56:36,056 [myid:] - INFO  [main:Environment@98] - Client environment:java.class.path=/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/classes:/root/apache-zookeeper-3.7.1-bin/bin/../build/classes:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../build/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-jute-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/snappy-java-1.1.7.7.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-reload4j-1.7.35.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-api-1.7.35.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_common-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/reload4j-1.2.19.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-unix-common-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-epoll-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-classes-epoll-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-resolver-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-handler-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-common-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-codec-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-buffer-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/metrics-core-4.1.12.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jline-2.14.6.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-ajax-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-servlet-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-server-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-security-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-io-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-http-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-databind-2.13.2.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-core-2.13.2.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-annotations-2.13.2.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/commons-cli-1.4.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/audience-annotations-0.12.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../conf:
2023-05-01 12:56:36,056 [myid:] - INFO  [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2023-05-01 12:56:36,056 [myid:] - INFO  [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:java.compiler=<NA>
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:os.name=Linux
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:os.arch=amd64
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:os.version=3.10.0-862.el7.x86_64
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:user.name=root
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:user.home=/root
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:user.dir=/root/apache-zookeeper-3.7.1-bin
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.free=11MB
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.max=247MB
2023-05-01 12:56:36,057 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.total=15MB
2023-05-01 12:56:36,060 [myid:] - INFO  [main:ZooKeeper@657] - Initiating client connection, connectString=192.168.44.180:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@65e579dc
2023-05-01 12:56:36,063 [myid:] - INFO  [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2023-05-01 12:56:36,073 [myid:] - INFO  [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2023-05-01 12:56:36,082 [myid:] - INFO  [main:ClientCnxn@1735] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
JLine support is enabled
2023-05-01 12:56:36,119 [myid:192.168.44.180:2181] - INFO  [main-SendThread(192.168.44.180:2181):ClientCnxn$SendThread@1171] - Opening socket connection to server kafka1/192.168.44.180:2181.
2023-05-01 12:56:36,119 [myid:192.168.44.180:2181] - INFO  [main-SendThread(192.168.44.180:2181):ClientCnxn$SendThread@1173] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2023-05-01 12:56:36,125 [myid:192.168.44.180:2181] - INFO  [main-SendThread(192.168.44.180:2181):ClientCnxn$SendThread@1005] - Socket connection established, initiating session, client: /192.168.44.180:54196, server: kafka1/192.168.44.180:2181
2023-05-01 12:56:36,176 [myid:192.168.44.180:2181] - INFO  [main-SendThread(192.168.44.180:2181):ClientCnxn$SendThread@1446] - Session establishment complete on server kafka1/192.168.44.180:2181, session id = 0x1000015a5e40000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: 192.168.44.180:2181(CONNECTED) 0]
[zk: 192.168.44.180:2181(CONNECTED) 0]

6. 部署kafka

cd /root/kafka_2.13-3.4.0/config/
[root@kafka1 config]# mv server.properties server.properties.bak

6.1 配置kafka配置文件

[root@kafka1 config]# vim server.properties

#broker.id在kafka集群内必须唯一
broker.id=0
#kafka服务的ip地址和端口
listeners=PLAINTEXT://192.168.44.180:9092
#kafka消息存储文件
log.dirs=/data/kafka/kafka-logs
#kafka连接的zookeeper的地址
zookeeper.connect=192.168.44.180:2181

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
#
#    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.

#
# This configuration file is intended for use in ZK-based mode, where Apache ZooKeeper is required.
# 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. If not configured, the host name will be equal to the value of
# java.net.InetAddress.getCanonicalHostName(), with PLAINTEXT listener name, and port 9092.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
#listeners=PLAINTEXT://:9092
listeners=PLAINTEXT://192.168.44.180:9092

# Listener name, hostname and port the broker will advertise to clients.
# If not set, it uses the value for "listeners".
#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=/data/kafka/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 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=192.168.44.180:2181

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


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

6.2 启动kafka

[root@kafka1 bin]# ./kafka-server-start.sh -daemon ../config/server.properties

6.3 查看kafka进程


[root@kafka1 bin]# ps -ef | grep kafka
root       2015      1  0 12:58 pts/0    00:00:01 java -Dzookeeper.log.dir=/root/apache-zookeeper-3.7.1-bin/bin/../logs -Dzookeeper.log.file=zookeeper-root-server-kafka1.log -Dzookeeper.root.logger=INFO,CONSOLE -XX:+HeapDumpOnOutOfMemoryError -XX:OnOutOfMemoryError=kill -9 %p -cp /root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/classes:/root/apache-zookeeper-3.7.1-bin/bin/../build/classes:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../build/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-jute-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-3.7.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/snappy-java-1.1.7.7.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-reload4j-1.7.35.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-api-1.7.35.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_common-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient-0.9.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/reload4j-1.2.19.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-unix-common-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-epoll-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-classes-epoll-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-resolver-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-handler-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-common-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-codec-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/netty-buffer-4.1.76.Final.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/metrics-core-4.1.12.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jline-2.14.6.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-ajax-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-servlet-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-server-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-security-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-io-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-http-9.4.43.v20210629.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-databind-2.13.2.1.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-core-2.13.2.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-annotations-2.13.2.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/commons-cli-1.4.jar:/root/apache-zookeeper-3.7.1-bin/bin/../lib/audience-annotations-0.12.0.jar:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/root/apache-zookeeper-3.7.1-bin/bin/../conf: -Xmx1000m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /root/apache-zookeeper-3.7.1-bin/bin/../conf/zoo.cfg
root       2519      1 52 13:09 pts/0    00:00:04 java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -XX:MaxInlineLevel=15 -Djava.awt.headless=true -Xloggc:/root/kafka_2.13-3.4.0/bin/../logs/kafkaServer-gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dkafka.logs.dir=/root/kafka_2.13-3.4.0/bin/../logs -Dlog4j.configuration=file:./../config/log4j.properties -cp /root/kafka_2.13-3.4.0/bin/../libs/activation-1.1.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/aopalliance-repackaged-2.6.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/argparse4j-0.7.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/audience-annotations-0.5.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/commons-cli-1.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/commons-lang3-3.8.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/connect-api-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/connect-basic-auth-extension-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/connect-json-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/connect-mirror-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/connect-mirror-client-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/connect-runtime-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/connect-transforms-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/hk2-api-2.6.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/hk2-locator-2.6.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/hk2-utils-2.6.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-annotations-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-core-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-databind-2.13.4.2.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-dataformat-csv-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-datatype-jdk8-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-jaxrs-base-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-jaxrs-json-provider-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-module-jaxb-annotations-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jackson-module-scala_2.13-2.13.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jakarta.activation-api-1.2.2.jar:/root/kafka_2.13-3.4.0/bin/../libs/jakarta.annotation-api-1.3.5.jar:/root/kafka_2.13-3.4.0/bin/../libs/jakarta.inject-2.6.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/jakarta.validation-api-2.0.2.jar:/root/kafka_2.13-3.4.0/bin/../libs/jakarta.ws.rs-api-2.1.6.jar:/root/kafka_2.13-3.4.0/bin/../libs/jakarta.xml.bind-api-2.3.3.jar:/root/kafka_2.13-3.4.0/bin/../libs/javassist-3.27.0-GA.jar:/root/kafka_2.13-3.4.0/bin/../libs/javax.annotation-api-1.3.2.jar:/root/kafka_2.13-3.4.0/bin/../libs/javax.servlet-api-3.1.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/javax.ws.rs-api-2.1.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/jaxb-api-2.3.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/jersey-client-2.34.jar:/root/kafka_2.13-3.4.0/bin/../libs/jersey-common-2.34.jar:/root/kafka_2.13-3.4.0/bin/../libs/jersey-container-servlet-2.34.jar:/root/kafka_2.13-3.4.0/bin/../libs/jersey-container-servlet-core-2.34.jar:/root/kafka_2.13-3.4.0/bin/../libs/jersey-hk2-2.34.jar:/root/kafka_2.13-3.4.0/bin/../libs/jersey-server-2.34.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-client-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-continuation-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-http-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-io-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-security-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-server-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-servlet-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-servlets-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-util-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jetty-util-ajax-9.4.48.v20220622.jar:/root/kafka_2.13-3.4.0/bin/../libs/jline-3.21.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/jopt-simple-5.0.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/jose4j-0.7.9.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka_2.13-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-clients-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-group-coordinator-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-log4j-appender-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-metadata-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-raft-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-server-common-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-shell-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-storage-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-storage-api-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-streams-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-streams-examples-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-streams-scala_2.13-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-streams-test-utils-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/kafka-tools-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/lz4-java-1.8.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/maven-artifact-3.8.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/metrics-core-2.2.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/metrics-core-4.1.12.1.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-buffer-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-codec-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-common-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-handler-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-resolver-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-transport-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-transport-classes-epoll-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-transport-native-epoll-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/netty-transport-native-unix-common-4.1.78.Final.jar:/root/kafka_2.13-3.4.0/bin/../libs/osgi-resource-locator-1.0.3.jar:/root/kafka_2.13-3.4.0/bin/../libs/paranamer-2.8.jar:/root/kafka_2.13-3.4.0/bin/../libs/plexus-utils-3.3.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/reflections-0.9.12.jar:/root/kafka_2.13-3.4.0/bin/../libs/reload4j-1.2.19.jar:/root/kafka_2.13-3.4.0/bin/../libs/rocksdbjni-7.1.2.jar:/root/kafka_2.13-3.4.0/bin/../libs/scala-collection-compat_2.13-2.6.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/scala-java8-compat_2.13-1.0.2.jar:/root/kafka_2.13-3.4.0/bin/../libs/scala-library-2.13.10.jar:/root/kafka_2.13-3.4.0/bin/../libs/scala-logging_2.13-3.9.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/scala-reflect-2.13.10.jar:/root/kafka_2.13-3.4.0/bin/../libs/slf4j-api-1.7.36.jar:/root/kafka_2.13-3.4.0/bin/../libs/slf4j-reload4j-1.7.36.jar:/root/kafka_2.13-3.4.0/bin/../libs/snappy-java-1.1.8.4.jar:/root/kafka_2.13-3.4.0/bin/../libs/swagger-annotations-2.2.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/trogdor-3.4.0.jar:/root/kafka_2.13-3.4.0/bin/../libs/zookeeper-3.6.3.jar:/root/kafka_2.13-3.4.0/bin/../libs/zookeeper-jute-3.6.3.jar:/root/kafka_2.13-3.4.0/bin/../libs/zstd-jni-1.5.2-1.jar kafka.Kafka ../config/server.properties
root       2587   1287  0 13:09 pts/0    00:00:00 grep --color=auto kafka

http://www.kler.cn/a/16776.html

相关文章:

  • 解决 Redis 报错:`(error) NOAUTH Authentication required`
  • Objection
  • 机器学习——损失函数、代价函数、KL散度
  • Spark 核心概念与宽窄依赖的详细解析
  • Mysql 8迁移到达梦DM8遇到的报错
  • 探索 JNI - Rust 与 Java 互调实战
  • 探索三维世界【3】:Three.js 的 Geometry 几何体 与 Material 材质
  • 《QDebug 2023年4月》
  • 烟火识别智能监测系统 yolov5
  • 生物信息学中---数据集不平衡的处理方法
  • 小红书违禁词有哪些,小红书违禁词汇总分享
  • 来上海一个月的记录、思考和感悟
  • ffmpeg-mov-metadate不识别Bug修复
  • JUC多并发编程 Synchronized与锁升级
  • Spring的创建与使用
  • 两分钟成为 ChatGPT 国内高手【不要再拿ChatGPT当百度用了】
  • 武忠祥老师每日一题||定积分基础训练(三)
  • markdown二元运算符
  • Msfconsole使用永恒之蓝入侵Win7并上传执行可执行文件
  • 【学习心得】Python多版本控制
  • 常用半导体器件
  • 数字孪生可视化平台开发 打通现实与虚拟世界
  • springboot第12集:DAO功能代码
  • vue基本语法
  • 通关MyBatis(上)
  • 二本做程序员有出路吗