赞
踩
Kafka内部有自置的zookeeper,此处我们选择外部从新安装配置zookeeper。 先选择一个结点进行配置,后面在远程拷贝到其他结点,此处选用westgisB062为例:
vim .bashrc
并在其加入:#zookeeper
export ZOOKEEPER_HOME=/home/CCX/software/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
#kafka
export KAFKA_HOME=/home/CCX/software/kafka
export PATH=$PATH:$KAFKA_HOME/bin
source .bashrc
使其生效cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
,修改配置:dataDir=/home/CCX/software/zookeeper/zkData
,此路径改为自己所建的文件目录,并在文末加入以下信息:server.1=westgisB061:2888:3888
server.2=westgisB062:2888:3888
server.3=westgisB063:2888:3888
server.4=westgisB060:2888:3888
server.5=westgisB059:2888:3888
server.id不能重复,要保证唯一性,每个server.id对应一个节点的机器名,并与kafka配置文件中的broker.id相对应。
/home/CCX/software/zookeeper
)创建一个zkdata目录:mkdir zkdata
,在zkdata目录下新建一个文件myid ,在文件中添加server对应的id,注意不要有空格,且与kafka中的broker.id相对应。vim myid
:2[CCX@westgisB062 zookeeper]$ xsync /home/CCX/software/zookeeper/
并修改对应myid文件的内容,westgisB059~westgisB063分别为5,4,1,2,3
[CCX@westgisB062 kafka]$ mkdir datas
vim server.properties
broker.id=2 #保证唯一性
log.dirs=/home/CCX/software/kafka/datas #kafka数据的保存路径
zookeeper.connect=westgisB059:2181,westgisB060:2181,westgisB061:2181,westgisB062:2181,westgisB063:2181
[CCX@westgisB062 kafka]$ xsync /home/CCX/software/kafka/
,分别依次修改节点对应的broker.id,与server.id要相对应。zkServer.sh start
$KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
$KAFKA_HOME/bin/kafka-server-stop.sh -daemon $KAFKA_HOME/config/server.properties
zkServer.sh stop
#!/bin/bash
for i in westgisB059 westgisB060 westgisB061 westgisB062 westgisB063
do
echo "=====$i====="
ssh $i '/home/CCX/software/zookeeper/bin/zkServer.sh start'
done
#! /bin/bash case $1 in "start"){ for i in westgisB059 westgisB060 westgisB061 westgisB062 westgisB063 do echo " --------启动 $i Kafka-------" ssh $i "/home/CCX/software/kafka/bin/kafka-server-start.sh -daemon /home/CCX/software/kafka/config/server.properties " done };; "stop"){ for i in westgisB059 westgisB060 westgisB061 westgisB062 westgisB063 do echo " --------停止 $i Kafka-------" ssh $i "/home/CCX/software/kafka/bin/kafka-server-stop.sh stop" done };; esac
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。