kafka_2.11-0.10.1.0 单机安装(使用kafka集成zookeeper)
解压安装包到/data目录,并修改权限,并配置环境变量修改config/zookeeper.properties文件dataDir=/data/zookeeper_dataclientPort=2181修改config/server.properties文件broker.id=0delete.topic.enable=truelisteners=PLAINTEXT://0.0.0.0:90
·
解压安装包到/data目录,并修改权限,并配置环境变量
修改config/zookeeper.properties文件
dataDir=/data/zookeeper_data clientPort=2181
修改config/server.properties文件
broker.id=0 delete.topic.enable=true listeners=PLAINTEXT://0.0.0.0:9092 advertised.listeners=PLAINTEXT://[外网ip]:9092 log.dirs=/data/kafka-logs zookeeper.connect=localhost:2181
新建文件夹 /data/kafka-logs 、 /data/zookeeper_data 并修改权限
sudo chown elk:elk -R /data/kafka-logs sudo chown elk:elk -R /data/zookeeper_data
启动zookeeper、启动kafka
zookeeper-server-start.sh /data/kafka_2.11-0.10.1.0/config/zookeeper.properties kafka-server-start.sh /data/kafka_2.11-0.10.1.0/config/server.properties
编写操作脚本 kafka.sh
#!/bin/bash source /etc/profile #前台启动zk if [ $1 = "zk" ] then zookeeper-server-start.sh /data/kafka_2.11-0.10.1.0/config/zookeeper.properties #后台启动zk elif [ $1 = "zkbg" ] then nohup zookeeper-server-start.sh /data/kafka_2.11-0.10.1.0/config/zookeeper.properties >/dev/null 2>&1 & #关闭zk elif [ $1 = "zkstop" ] then zookeeper-server-stop.sh #前台启动kafka elif [ $1 = "kafka" ] then kafka-server-start.sh /data/kafka_2.11-0.10.1.0/config/server.properties #后台启动kafka elif [ $1 = "kafkabg" ] then nohup kafka-server-start.sh /data/kafka_2.11-0.10.1.0/config/server.properties >/dev/null 2>&1 & #关闭kafka elif [ $1 = "kafkastop" ] then kafka-server-stop.sh elif [ $1 = "consumer" ] then kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic $2 elif [ $1 = "producer" ] then kafka-console-producer.sh --broker-list localhost:9092 --topic $2 elif [ $1 = "create" ] then kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic $2 #创建topic elif [ $1 = "list" ] then kafka-topics.sh --list --zookeeper localhost:2181 #查看topic elif [ $1 = "delete" ] then kafka-topics.sh --delete --zookeeper localhost:2181 --topic $2 #删除topic else echo "parameter invalid" fi
更多推荐
已为社区贡献2条内容
所有评论(0)