CentOS-尝试部署kafka集群

kafka简介

Kafka是一种高吞吐量的分布式发布订阅消息系统。

需要依赖于zookeeper服务,可以参照下面文章部署:

centos-试试zookeeper集群部署

环境介绍

Linux系统:Centos6

192.168.122.10 server1

192.168.122.11 server2

192.168.122.12 server3


jdk部署

解压jdk压缩包到/opt/jdk

下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

tar zxvf jdk-8u111-linux-x64.tar.gz

mv jdk1.8.0_111 /opt/jdk

创建普通用户运行kafka

useradd kafka

修改文件句柄和进程限制,并修改hosts

echo '192.168.122.10 server1' >> /etc/hosts

echo '192.168.122.11 server2' >> /etc/hosts

echo '192.168.122.12 server3' >> /etc/hosts

echo 'kafka soft nproc 65535 ' >> /etc/security/limits.conf

echo 'kafka hard nproc 65535 ' >> /etc/security/limits.conf

echo 'kafka soft nofile 65535 ' >> /etc/security/limits.conf

echo 'kafka hard nofile 65535 ' >> /etc/security/limits.conf

修改环境变量

su - kafka

echo 'export JAVA_HOME=/opt/jdk' >> /home/kafka/.bash_profile

echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /home/kafka/.bash_profile

. /home/kafka/.bash_profiles

下载kafka并解压安装

下载地址:http://mirror.bit.edu.cn/apache/kafka/0.10.2.0/kafka_2.11-0.10.2.0.tgz

tar zxvf kafka_2.11-0.10.2.0.tgz

mv kafka_2.11-0.10.2.0 /opt/

cd /opt

ln -s kafka_2.11-0.10.2.0 kafka

修改配置文件

cd /opt/kafka/config

vim server.properties

#修改broker.id ,在集群里面是唯一的

broker.id=0

#修改日志目录路径

log.dirs=/data/kafka-logs

#修改连接的zookeeper

zookeeper.connect=192.168.122.10:2181,192.168.122.11:2181,192.168.122.12:2181

创建目录及修改权限

su - root

mkdir -p /data/kafka-logs

chown kafka.kafka /data/kafka-logs -R

启动kafka

cd /opt/kafka/

nohup bin/kafka-server-start.sh config/server.properties &

其他两个节点只要broker.id分别设置成2 3 就可以了


你可能感兴趣的:(CentOS-尝试部署kafka集群)