赞
踩
看到这篇文章的同学应该都安装了 VMware Workstation Pro,并安装了centos 7 或者 centos 8,我安装的是桌面版,因为操作太舒服了
我选的3.6.3这个版本,太新的话有些框架不兼容~
2.登录linux 创建一个文件夹 zookeeper
3.在线下载
wget https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.6.3/apache-zookeeper-3.6.3-bin.tar.gz
下载后解压
tar -zxvf apache-zookeeper-3.6.3-bin.tar.gz
进入conf目录 复制 zoo_sample.cfg 命名zoo.cfg
cp zoo_sample.cfg zoo.cfg
bin/zkServer.sh start
cd /etc/init.d
使用命令vi zookeeper 或者文本编辑器打开
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
export JAVA_HOME=/usr/local/programs/jdk1.8
case $1 in
start) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh start;;
stop) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh stop;;
status) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh status;;
restart) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
2.给脚本添加执行权限
chmod +x zookeeper
3.使用service zookeeper start/stop命令来尝试启动关闭zookeeper,使用service zookeeper status查看zookeeper状态。
或者直接 zookeeper start/stop/status
4.添加到开机启动
chkconfig --add zookeeper
5.查看开机自启的服务中是否已经有我们的zookeeper
chkconfig --list zookeeper
zookeeper 0:off 1:off 2:on 3:on 4:on 5:on 6:off
wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.7.0/kafka_2.12-2.7.0.tgz
下载后解压
tar -zxvf kafka_2.12-2.7.0.tgz
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# FORMAT:
# listeners = listener_name://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://0.0.0.0:9092
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092
advertised.listeners=PLAINTEXT://192.168.73.128:9092
192.168.73.128 这个是我虚拟机的ip ,修改成同学你的ip就行,通过下面的命令可以查询
ifconfig -a
bin/kafka-server-start.sh -daemon config/server.properties
systemctl stop firewalld
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic beike
–create 创建主题
–topic 主题名称
–zookeeper zookeeper集群地址
–replication-factor 每个分区副本因子个数即每个分区有多少副本
–partitions 主题partition数
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic beike
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic beike --from-beginning
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。