1.在服务器安装 java
2.配置一套zookeeper集群
我在该服务器配置了一套 数量为3的 伪zookeeper集群
zoo1 对应 2181端口
zoo2 对应 2182端口
zoo3 对应 2183端口
(如果不想做集群,可以临时启用一个 zookeeper模拟实例)
3.上传 kafka_2.12-1.1.0.tgz
解压
# tar -zxvf kafka_2.12-1.1.0.tgz
4.修改配置文件
# cd kafka_2.12-1.1.0/config
# vi server.properties
红字是我本机 伪zookeeper集群地址
############################# 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
zookeeper.connect=localhost:2181,localhost:2182,localhost:2183
# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
5.启动 kafka
# cd kafka_2.12-1.1.0
# bin
/kafka-server-start
.sh config
/server
.properties
[2018-07-02 15:32:53,153] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$) [2018-07-02 15:32:54,168] INFO starting (kafka.server.KafkaServer) [2018-07-02 15:32:54,170] INFO Connecting to zookeeper on localhost:2181,localhost:2182,localhost:2183 (kafka.server.KafkaServer) [2018-07-02 15:32:54,209] INFO [ZooKeeperClient] Initializing a new session to localhost:2181,localhost:2182,localhost:2183. (kafka.zookeeper.ZooKeeperClient) …… [2018-07-02 15:32:56,962] INFO Kafka version : 1.1.0 (org.apache.kafka.common.utils.AppInfoParser) [2018-07-02 15:32:56,962] INFO Kafka commitId : fdcf75ea326b8e07 (org.apache.kafka.common.utils.AppInfoParser) [2018-07-02 15:32:56,964] INFO [KafkaServer id=0] started (kafka.server.KafkaServer)
后台启动方式:
cd kafka_2.12-1.1.0/bin
nohup ./kafka-server-start.sh ../config/server.properties 1>/dev/null 2>&1 &
官方原文:http://kafka.apache.org/quickstart