<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>http://woodrow.cn/w/index.php?action=history&amp;feed=atom&amp;title=Kafka</id>
	<title>Kafka - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="http://woodrow.cn/w/index.php?action=history&amp;feed=atom&amp;title=Kafka"/>
	<link rel="alternate" type="text/html" href="http://woodrow.cn/w/index.php?title=Kafka&amp;action=history"/>
	<updated>2026-05-15T14:48:43Z</updated>
	<subtitle>本wiki的该页面的版本历史</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>http://woodrow.cn/w/index.php?title=Kafka&amp;diff=47&amp;oldid=prev</id>
		<title>Woodrow：建立内容为“== 静态 IP 地址 ==  &lt;syntaxhighlight lang=&quot;bash&quot;&gt; ip addr &lt;/syntaxhighlight&gt;  &lt;syntaxhighlight lang=&quot;bash&quot;&gt; vi /etc/sysconfig/network-scripts/ifcfg-ens33 &lt;/sy…”的新页面</title>
		<link rel="alternate" type="text/html" href="http://woodrow.cn/w/index.php?title=Kafka&amp;diff=47&amp;oldid=prev"/>
		<updated>2022-09-02T11:32:36Z</updated>

		<summary type="html">&lt;p&gt;建立内容为“== 静态 IP 地址 ==  &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt; ip addr &amp;lt;/syntaxhighlight&amp;gt;  &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt; vi /etc/sysconfig/network-scripts/ifcfg-ens33 &amp;lt;/sy…”的新页面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== 静态 IP 地址 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip addr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
vi /etc/sysconfig/network-scripts/ifcfg-ens33&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/sysconfig/network-scripts/ifcfg-ens33&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
TYPE=Ethernet&lt;br /&gt;
PROXY_METHOD=none&lt;br /&gt;
BROWSER_ONLY=no&lt;br /&gt;
BOOTPROTO=static&lt;br /&gt;
DEFROUTE=yes&lt;br /&gt;
IPV4_FAILURE_FATAL=no&lt;br /&gt;
IPV6INIT=yes&lt;br /&gt;
IPV6_AUTOCONF=yes&lt;br /&gt;
IPV6_DEFROUTE=yes&lt;br /&gt;
IPV6_FAILURE_FATAL=no&lt;br /&gt;
IPV6_ADDR_GEN_MODE=stable-privacy&lt;br /&gt;
NAME=ens33&lt;br /&gt;
UUID=5a91778c-356f-43ce-8133-f98b61745b1d&lt;br /&gt;
DEVICE=ens33&lt;br /&gt;
ONBOOT=yes&lt;br /&gt;
IPADDR=192.168.0.128&lt;br /&gt;
NETMASK=255.255.255.0&lt;br /&gt;
GATEWAY=192.168.0.2&lt;br /&gt;
DNS1=119.29.29.29&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl restart network.service&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ip addr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Firewall ==&lt;br /&gt;
&lt;br /&gt;
关闭防火墙&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl status firewalld&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl stop firewalld&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl disable firewalld&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl status firewalld&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== JDK ==&lt;br /&gt;
&lt;br /&gt;
=== 解压安装 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd ~&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir java&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd java&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar zxvf jdk-8u341-linux-x64.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 设置 PATH ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd jdk1.8.0_341&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pwd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
/root/java/jdk1.8.0_341&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
vim /etc/profile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/profile&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
export JAVA_HOME=/root/java/jdk1.8.0_341&lt;br /&gt;
export PATH=$PATH:$JAVA_HOME/bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
source /etc/profile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 验证 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
java -version&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
javac -version&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ZooKeeper 集群 ==&lt;br /&gt;
&lt;br /&gt;
=== 解压安装 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd ~&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir zookeeper&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd zookeeper&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar zxvf zookeeper-3.4.12.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 设置 PATH ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd zookeeper-3.4.12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pwd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
/root/zookeeper/zookeeper-3.4.12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
vim /etc/profile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/profile&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
export ZOOKEEPER_HOME=/root/zookeeper/zookeeper-3.4.12&lt;br /&gt;
export PATH=$PATH:$ZOOKEEPER_HOME/bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
source /etc/profile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 修改 ZooKeeper 配置 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd conf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cp zoo_sample.cfg zoo.cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
vim zoo.cfg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
zoo.cfg&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# The number of milliseconds of each tick&lt;br /&gt;
#tickTime=2000&lt;br /&gt;
# The number of ticks that the initial &lt;br /&gt;
# synchronization phase can take&lt;br /&gt;
#initLimit=10&lt;br /&gt;
# The number of ticks that can pass between &lt;br /&gt;
# sending a request and getting an acknowledgement&lt;br /&gt;
#syncLimit=5&lt;br /&gt;
# the directory where the snapshot is stored.&lt;br /&gt;
# do not use /tmp for storage, /tmp here is just &lt;br /&gt;
# example sakes.&lt;br /&gt;
#dataDir=/tmp/zookeeper&lt;br /&gt;
# the port at which the clients will connect&lt;br /&gt;
#clientPort=2181&lt;br /&gt;
# the maximum number of client connections.&lt;br /&gt;
# increase this if you need to handle more clients&lt;br /&gt;
#maxClientCnxns=60&lt;br /&gt;
#&lt;br /&gt;
# Be sure to read the maintenance section of the &lt;br /&gt;
# administrator guide before turning on autopurge.&lt;br /&gt;
#&lt;br /&gt;
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance&lt;br /&gt;
#&lt;br /&gt;
# The number of snapshots to retain in dataDir&lt;br /&gt;
#autopurge.snapRetainCount=3&lt;br /&gt;
# Purge task interval in hours&lt;br /&gt;
# Set to &amp;quot;0&amp;quot; to disable auto purge feature&lt;br /&gt;
#autopurge.purgeInterval=1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ZooKeeper服务器心跳时间，单位为ms&lt;br /&gt;
tickTime=2000&lt;br /&gt;
# 允许follower连接并同步到leader的初始化连接时间，以tickTime的倍数来表示&lt;br /&gt;
initLimit=10&lt;br /&gt;
# leader与follower心跳检测最大容忍时间，响应超过syncLimit*tickTime，leader认为&lt;br /&gt;
# follower“死掉”，从服务器列表中删除follower&lt;br /&gt;
syncLimit=5&lt;br /&gt;
# 数据目录&lt;br /&gt;
dataDir=/tmp/zookeeper/data&lt;br /&gt;
# 日志目录&lt;br /&gt;
dataLogDir=/tmp/zookeeper/log&lt;br /&gt;
# ZooKeeper对外服务端口&lt;br /&gt;
clientPort=2181&lt;br /&gt;
&lt;br /&gt;
server.0=192.168.0.128:2888:3888&lt;br /&gt;
server.1=192.168.0.129:2888:3888&lt;br /&gt;
server.2=192.168.0.130:2888:3888&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p /tmp/zookeeper/data&lt;br /&gt;
mkdir -p /tmp/zookeeper/log&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd /tmp/zookeeper/data&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
vim myid&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
myid：服务器的编号&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 启动 ZooKeeper 服务 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
zkServer.sh start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
zkServer.sh status&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 停止 ZooKeeper 服务 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
zkServer.sh stop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Kafka 集群 ==&lt;br /&gt;
&lt;br /&gt;
=== 解压安装 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd ~&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir kafka&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd kafka&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar zxvf kafka_2.11-2.0.0.tgz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 设置 PATH ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd kafka_2.11-2.0.0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pwd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
/root/kafka/kafka_2.11-2.0.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
vim /etc/profile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/profile&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
export KAFKA_HOME=/root/kafka/kafka_2.11-2.0.0&lt;br /&gt;
export PATH=$PATH:$KAFKA_HOME/bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
source /etc/profile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 修改 Kafka 配置 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd config&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
vim server.properties&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server.properties&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
# contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
# this work for additional information regarding copyright ownership.&lt;br /&gt;
# The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
# (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
# the License.  You may obtain a copy of the License at&lt;br /&gt;
#&lt;br /&gt;
#    http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
#&lt;br /&gt;
# Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
# distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
# See the License for the specific language governing permissions and&lt;br /&gt;
# limitations under the License.&lt;br /&gt;
&lt;br /&gt;
# see kafka.server.KafkaConfig for additional details and defaults&lt;br /&gt;
&lt;br /&gt;
############################# Server Basics #############################&lt;br /&gt;
&lt;br /&gt;
# The id of the broker. This must be set to a unique integer for each broker.&lt;br /&gt;
broker.id=0&lt;br /&gt;
&lt;br /&gt;
############################# Socket Server Settings #############################&lt;br /&gt;
&lt;br /&gt;
# The address the socket server listens on. It will get the value returned from &lt;br /&gt;
# java.net.InetAddress.getCanonicalHostName() if not configured.&lt;br /&gt;
#   FORMAT:&lt;br /&gt;
#     listeners = listener_name://host_name:port&lt;br /&gt;
#   EXAMPLE:&lt;br /&gt;
#     listeners = PLAINTEXT://your.host.name:9092&lt;br /&gt;
listeners=PLAINTEXT://192.168.0.128:9092&lt;br /&gt;
&lt;br /&gt;
# Hostname and port the broker will advertise to producers and consumers. If not set, &lt;br /&gt;
# it uses the value for &amp;quot;listeners&amp;quot; if configured.  Otherwise, it will use the value&lt;br /&gt;
# returned from java.net.InetAddress.getCanonicalHostName().&lt;br /&gt;
#advertised.listeners=PLAINTEXT://your.host.name:9092&lt;br /&gt;
&lt;br /&gt;
# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details&lt;br /&gt;
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL&lt;br /&gt;
&lt;br /&gt;
# The number of threads that the server uses for receiving requests from the network and sending responses to the network&lt;br /&gt;
num.network.threads=3&lt;br /&gt;
&lt;br /&gt;
# The number of threads that the server uses for processing requests, which may include disk I/O&lt;br /&gt;
num.io.threads=8&lt;br /&gt;
&lt;br /&gt;
# The send buffer (SO_SNDBUF) used by the socket server&lt;br /&gt;
socket.send.buffer.bytes=102400&lt;br /&gt;
&lt;br /&gt;
# The receive buffer (SO_RCVBUF) used by the socket server&lt;br /&gt;
socket.receive.buffer.bytes=102400&lt;br /&gt;
&lt;br /&gt;
# The maximum size of a request that the socket server will accept (protection against OOM)&lt;br /&gt;
socket.request.max.bytes=104857600&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
############################# Log Basics #############################&lt;br /&gt;
&lt;br /&gt;
# A comma separated list of directories under which to store log files&lt;br /&gt;
log.dirs=/tmp/kafka-logs&lt;br /&gt;
&lt;br /&gt;
# The default number of log partitions per topic. More partitions allow greater&lt;br /&gt;
# parallelism for consumption, but this will also result in more files across&lt;br /&gt;
# the brokers.&lt;br /&gt;
num.partitions=1&lt;br /&gt;
&lt;br /&gt;
# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.&lt;br /&gt;
# This value is recommended to be increased for installations with data dirs located in RAID array.&lt;br /&gt;
num.recovery.threads.per.data.dir=1&lt;br /&gt;
&lt;br /&gt;
############################# Internal Topic Settings  #############################&lt;br /&gt;
# The replication factor for the group metadata internal topics &amp;quot;__consumer_offsets&amp;quot; and &amp;quot;__transaction_state&amp;quot;&lt;br /&gt;
# For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.&lt;br /&gt;
offsets.topic.replication.factor=1&lt;br /&gt;
transaction.state.log.replication.factor=1&lt;br /&gt;
transaction.state.log.min.isr=1&lt;br /&gt;
&lt;br /&gt;
############################# Log Flush Policy #############################&lt;br /&gt;
&lt;br /&gt;
# Messages are immediately written to the filesystem but by default we only fsync() to sync&lt;br /&gt;
# the OS cache lazily. The following configurations control the flush of data to disk.&lt;br /&gt;
# There are a few important trade-offs here:&lt;br /&gt;
#    1. Durability: Unflushed data may be lost if you are not using replication.&lt;br /&gt;
#    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.&lt;br /&gt;
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.&lt;br /&gt;
# The settings below allow one to configure the flush policy to flush data after a period of time or&lt;br /&gt;
# every N messages (or both). This can be done globally and overridden on a per-topic basis.&lt;br /&gt;
&lt;br /&gt;
# The number of messages to accept before forcing a flush of data to disk&lt;br /&gt;
#log.flush.interval.messages=10000&lt;br /&gt;
&lt;br /&gt;
# The maximum amount of time a message can sit in a log before we force a flush&lt;br /&gt;
#log.flush.interval.ms=1000&lt;br /&gt;
&lt;br /&gt;
############################# Log Retention Policy #############################&lt;br /&gt;
&lt;br /&gt;
# The following configurations control the disposal of log segments. The policy can&lt;br /&gt;
# be set to delete segments after a period of time, or after a given size has accumulated.&lt;br /&gt;
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens&lt;br /&gt;
# from the end of the log.&lt;br /&gt;
&lt;br /&gt;
# The minimum age of a log file to be eligible for deletion due to age&lt;br /&gt;
log.retention.hours=168&lt;br /&gt;
&lt;br /&gt;
# A size-based retention policy for logs. Segments are pruned from the log unless the remaining&lt;br /&gt;
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.&lt;br /&gt;
#log.retention.bytes=1073741824&lt;br /&gt;
&lt;br /&gt;
# The maximum size of a log segment file. When this size is reached a new log segment will be created.&lt;br /&gt;
log.segment.bytes=1073741824&lt;br /&gt;
&lt;br /&gt;
# The interval at which log segments are checked to see if they can be deleted according&lt;br /&gt;
# to the retention policies&lt;br /&gt;
log.retention.check.interval.ms=300000&lt;br /&gt;
&lt;br /&gt;
############################# Zookeeper #############################&lt;br /&gt;
&lt;br /&gt;
# Zookeeper connection string (see zookeeper docs for details).&lt;br /&gt;
# This is a comma separated host:port pairs, each corresponding to a zk&lt;br /&gt;
# server. e.g. &amp;quot;127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002&amp;quot;.&lt;br /&gt;
# You can also append an optional chroot string to the urls to specify the&lt;br /&gt;
# root directory for all kafka znodes.&lt;br /&gt;
zookeeper.connect=192.168.0.128:2181,192.168.0.129:2181,192.168.0.130:2181/kafka&lt;br /&gt;
&lt;br /&gt;
# Timeout in ms for connecting to zookeeper&lt;br /&gt;
zookeeper.connection.timeout.ms=6000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
############################# Group Coordinator Settings #############################&lt;br /&gt;
&lt;br /&gt;
# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.&lt;br /&gt;
# 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.&lt;br /&gt;
# The default value for this is 3 seconds.&lt;br /&gt;
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.&lt;br /&gt;
# 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.&lt;br /&gt;
group.initial.rebalance.delay.ms=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 启动 Kafka 服务 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd /root/kafka/kafka_2.11-2.0.0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* 前台方式启动 Kafka broker 进程&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-server-start.sh config/server.properties&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* 后台方式启动 Kafka broker 进程&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-server-start.sh -daemon config/server.properties&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jps 命令查看 Kafka 服务进程是否已经启动&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
jps -l&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 验证部署 ===&lt;br /&gt;
&lt;br /&gt;
==== 测试 topic 创建与删除 ====&lt;br /&gt;
&lt;br /&gt;
创建主题&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-topics.sh --zookeeper 192.168.0.130:2181/kafka --create --topic topic-demo --partitions 3 --replication-factor 3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
列出所有可用的主题&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-topics.sh --zookeeper 192.168.0.130:2181/kafka --list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
查看主题的详细信息&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-topics.sh --zookeeper 192.168.0.130:2181/kafka --describe --topic topic-demo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
删除主题&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-topics.sh --zookeeper 192.168.0.130:2181/kafka --delete --topic topic-demo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 测试消息发送与消费 ====&lt;br /&gt;
&lt;br /&gt;
使用 kafka-console-consumer.sh 脚本订阅主题 topic-demo&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-console-consumer.sh --bootstrap-server 192.168.0.130:9092 --topic topic-demo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
kafka-console-producer 发送消息&lt;br /&gt;
&lt;br /&gt;
使用 kafka-console-producer.sh 脚本发送一条消息「Hello, Kafka!」至主题 topic-demo&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-console-producer.sh --broker-list 192.168.0.130:9092 --topic topic-demo&lt;br /&gt;
&amp;gt;Hello, Kafka!&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
kafka-console-consumer 接收消息&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-console-consumer.sh --bootstrap-server 192.168.0.130:9092 --topic topic-demo&lt;br /&gt;
Hello, Kafka!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 停止 Kafka 服务 ===&lt;br /&gt;
&lt;br /&gt;
* 前台方式启动 Kafka broker 进程时&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Ctrl + C&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* 后台方式启动 Kafka broker 进程时&lt;br /&gt;
&lt;br /&gt;
优雅关闭&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bin/kafka-server-stop.sh&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Woodrow</name></author>
	</entry>
</feed>