kafka环境安装

 源码包下载:

http://archive.apache.org/dist/kafka/1.0.0/

 

集群环境:

master 192.168.1.99
slave1 192.168.1.100
slave2 192.168.1.101

 

下载安装包:

# Master
wget http://archive.apache.org/dist/kafka/1.0.0/kafka_2.11-1.0.0.tgz -C /usr/local/src
tar -zxvf kafka_2.11-1.0.0.tgz
mv kafka_2.11-1.00 /usr/local/kafka

 

修改配置文件:

cd /usr/local/kafka/config

vim server.properties

log.dirs=/usr/local/kafka/logs
zookeeper.connect=master:2181,slave1:2181,slave2:2181

## 需要创建日志目录

mkdir /usr/local/kafka/logs

 

配置环境变量:

#Master slave1 slave2

vim ~/.bashrc
KAFKA_HOME=/usr/local/kafka
PATH=$PATH:$KAFKA_HOME/bin

#刷新环境变量
source ~/.bashrc

 

拷贝安装包:

rsync -av /usr/local/kafka slave1:/usr/local/kafka
rsync -av /usr/local/kafka slave2:/usr/local/kafka

 

修改Kafka配置文件:

#Master
vim /usr/local/kafka/config/server.propertie
broker.id=0
#Slave1
vim  /usr/local/kafka/config/server.propertie
broker.id=1
#Slave2
vim  /usr/local/kafka/config/server.propertie
broker.id=2

 

启动kafka集群(需提前启动zookeeper):

如果有自建的zookeeper集群,需要自启;

如果没有,则需要启动kafka自带的zookeeper,方法为:

/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties > /dev/null &

## 启动kafka集群(需分别在三台机器上面启动)

/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties > /dev/null &

 

进程状态:

#Master

#Slave1

#Slave2

 

关闭集群:

/usr/local/kafka/bin/kafka-server-stop.sh

 

 

posted @ 2018-09-23 11:07  wang_zai  阅读(696)  评论(0编辑  收藏  举报