hadoop-2.7.3安装kafka_2.11-2.1.0

软件下载:

http://mirrors.shu.edu.cn/apache/kafka/2.1.0/kafka_2.11-2.1.0.tgz

把下载好的包kafka_2.11-2.1.0.tgz 上传到hadoop集群上master:/home/hadoop

解压:

tar -zxvf kafka_2.11-2.1.0.tgz

mv kafka_2.11-2.1.0 kafka_2.11

 修改配置文件:

vi server.properties

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=1

#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
listeners = PLAINTEXT://master:9092
#listeners=PLAINTEXT://:9092

# A comma separated list of directories under which to store log files
log.dirs=/home/hadoop/kafka_2.11/tmp

# root directory for all kafka znodes.
zookeeper.connect=master:2181,saver1:2181,saver2:2181

一共以上四处地方需要修改!

分别SCP到其他节点

scp -r kafka_2.11 192.168.1.40:/home/hadoop/

scp -r kafka_2.11 192.168.1.50:/home/hadoop/

192.168.1.40机器上修改的地方有:

vi server.properties

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=2

#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
listeners = PLAINTEXT://saver1:9092
#listeners=PLAINTEXT://:9092

192.168.1.50机器上修改的地方有:

vi server.properties

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=3

#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
listeners = PLAINTEXT://saver2:9092
#listeners=PLAINTEXT://:9092

 

启动kafka

nohup /home/hadoop/kafka_2.11/bin/kafka-server-start.sh /home/hadoop/kafka_2.11/config/server.properties >/dev/null 2>&1 &

停止kafka
/home/hadoop/kafka_2.11/bin/kafka-server-stop.sh

 

在停止的时候,出现:No kafka server to stop,后天明明有进程,却无法停止。

查看kafka-server-stop.sh脚本,进行脚本修改:
PIDS=$(ps ax | grep -i 'kafka' | grep java | grep -v grep | awk '{print $1}')

三台机器都需要执行。

查看进行:jps

15856 Kafka

验证:

cd /home/hadoop/kafka_2.11/bin

./kafka-topics.sh --create --zookeeper master:2181 --replication-factor 1 --partitions 1 --topic test

完。

posted @ 2019-01-24 18:31  醉城、  阅读(968)  评论(0编辑  收藏  举报