北京知名的网站建设公司排名,网站开发的功能需求文档,淘宝关键词查询工具,品牌定位的七个步骤一、前提
1、kafka安装包下载#xff1a;http://kafka.apache.org/downloads
2、jdk已安装
3、scala已安装
4、zookeeper集群已安装并运行二、步骤
1、对kafka_2.9.2-0.8.1.tgz进行解压缩#xff1a;tar -zxvf kafka_2.9.2-0.8.1.tgz。2、对kafka目录进行改名#xff1a;mv …一、前提
1、kafka安装包下载http://kafka.apache.org/downloads
2、jdk已安装
3、scala已安装
4、zookeeper集群已安装并运行二、步骤
1、对kafka_2.9.2-0.8.1.tgz进行解压缩tar -zxvf kafka_2.9.2-0.8.1.tgz。2、对kafka目录进行改名mv kafka_2.9.2-0.8.1 kafka3、配置kafkavi /usr/local/kafka/config/server.propertiesbroker.id依次增长的整数0、1、2、3、4集群中Broker的唯一idzookeeper.connect192.168.1.107BD01:2181,192.168.1.108:2181,192.168.1.109:2181
用域名更好万一测试环境ip地址变了可以不用改配置三、启动
#从后台启动Kafka集群3台都需要启动
cd /opt/kafka/kafka_2.11-0.9.0.1//bin#进入到kafka的bin目录
./kafka-server-start.sh -daemon ../config/server.properties四、测试
集群中任选一台如BD03进入kafka\bin文件夹下
输入命令
#创建主题
./kafka-topics.sh --zookeeper BD03:2181,BD04:2181,BD05:2181 --topic TestTopic --replication-factor 1 --partitions 1 --create集群中任选一台如BD04进入kafka\bin文件夹下
输入命令
#创建生产者
./kafka-console-producer.sh --broker-list BD03:9092,BD04:9092,BD05:9092 --topic TestTopic集群中任选一台如BD05进入kafka\bin文件夹下
输入命令#创建消费者
./kafka-console-consumer.sh --zookeeper BD03:2181,BD04:2181,BD05:2181 --topic TestTopic --from-beginning----------------
BD04 生产者BD05 消费者五、关闭
以下参考了http://blog.csdn.net/M_SIGNALs/article/details/53201595似乎有一个是用来关闭服务的”kafka-server-stop.sh“于是我们运行这个脚本
[rootmaster bin]# kafka-server-stop.sh
No kafka server to stop[rootmaster bin]#
1234
what ? 没有服务要被关闭我们可以看一下这个脚本到底是怎么写的是不是我们的参数不正确还是怎么滴。
[rootmaster bin]# cat kafka-server-stop.sh
#!/bin/sh
# 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.
PIDS$(ps ax | grep -i kafka\.Kafka | grep java | grep -v grep | awk {print $1})if [ -z $PIDS ]; thenecho No kafka server to stopexit 1
else kill -s TERM $PIDS
fi[rootmaster bin]#
1234567891011121314151617181920212223242526
好吧这么看来也就是我们用这样的方法是不行了。干脆直接 kill -9
[rootmaster kafka_2.11-0.10.1.0]# jps
3448 Kafka
2136 NodeManager
3033 QuorumPeerMain
1772 DataNode
5757 Jps
3711 Kafka
[rootmaster kafka_2.11-0.10.1.0]# kill -9 3448
...
[1]- Killed kafka-server-start.sh server4.properties
...
1234567891011
就是这么简单粗暴。