当前位置:首页 > 系统运维 > 正文内容

kafka集群安装配置

zhangquanyu5年前 (2020-10-29)系统运维1651

1、wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.10.1.1/kafka_2.10-0.10.1.1.tgz
2、单机环境
tar -zxvf kafka_2.10-0.10.1.1.tgz -C /usr/local/
cd /usr/local/kafka_2.10-0.10.1.1
vim config/zookeeper.properties
vim config/server.properties
nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &
nohup ./bin/kafka-server-start.sh config/server.properties &
./bin/kafka-console-producer.sh --broker-list 192.168.17.116:9092 --topic test
./bin/kafka-console-consumer.sh --zookeeper 192.168.17.116:2181 --topic test --from-beginning
3、集群环境
192.168.17.116
192.168.17.118
192.168.17.99
vim config/zookeeper.properties
tickTime=2000  
dataDir=/data/zookeeper/  
clientPort=2181  
initLimit=5  
syncLimit=2  
server.1=192.168.17.116:2888:3888
server.1=192.168.17.118:2888:3888
server.1=192.168.17.99:2888:3888
在dataDir目录/data/zookeeper/下写一个myid文件,命令如下:echo 1 >myid,这个id是zookeeper的主机标示,每个主机id不同,在这里我设置的第二台是2,第三台是3。
vim config/server.properties
broker.id=1(前面设置的本机id)  
port=9092  
host.name=192.168.17.116(本机IP)  
zookeeper.connect=192.168.17.116:2181,192.168.17.118:2181,192.168.17.99:2181  
log.dirs=/usr/ss/kafka_2.10-0.9.0.0/logs  
nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &
nohup ./bin/kafka-server-start.sh config/server.properties &
创建topic:
./bin/kafka-topics.sh --create --topic topic_1 --partitions 1 --replication-factor 3 --zookeeper 127.0.0.1:2181
bin/kafka-topics.sh --create --topic topic_2 --partitions 1 --replication-factor 3  \--zookeeper localhost:2181
bin/kafka-topics.sh --create --topic topic_3 --partitions 1 --replication-factor 3  \--zookeeper localhost:2181
查看topic创建情况:
bin/kafka-topics.sh --list --zookeeper localhost:2181
发送消息
bin/kafka-console-producer.sh --topic topic_1 --broker-list 192.168.1.181:9092,192.168.1.181:9093,192.168.1.181:9094
接收消息
bin/kafka-console-consumer.sh --topic topic_1 --zookeeper 192.168.1.181:2181 --from-beginning


扫描二维码推送至手机访问。

版权声明:本文由张权予博客发布,如需转载请注明出处。

本文链接:https://zhangquanyu.com/?id=7

标签: kafka
分享给朋友:

“kafka集群安装配置” 的相关文章

RocketMQ安装使用

RocketMQ安装使用

wget "https://github.com/alibaba/RocketMQ/releases/download/v3.2.6/alibaba-rocketmq-3.2.6.tar.gz" tar -zxvf alibaba-rocketmq...

nginx安装配置

nginx安装配置

1、nginx安装配置 安装依赖包:        yum -y install gcc automake autoconf libtool make gcc ...

php7.4.2+SWOOLE4.5源码包安装

php7.4.2+SWOOLE4.5源码包安装

wget https://www.php.net/distributions/php-7.4.2.tar.bz2 cd php-7.4.2 yum -y install gcc gcc-c++ libxml2-devel&nb...

CentOS7安装Rancher并部署kubernetes

CentOS7安装Rancher并部署kubernetes

setenforce 0 sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config systemctl stop fire...

Jenkins配置Ansible

Jenkins配置Ansible

【安装Ansible Plugin】Jenkins->系统管理->管理插件->可选插件->Ansible Plugin->直接安装Jenkins->系统管理->Global Tools Configuration->Ansible->新增Ansi...