检查java8 没有就安装
java -version
安装jdk1.8
yum -y install java-1.8.0-openjdk
下载kafka (网速很慢)
wget https://dlcdn.apache.org/kafka/3.5.0/kafka_2.13-3.5.0.tgz
解压缩
tar -xzf kafka_2.13-3.5.0.tgz
cd kafka_2.13-3.5.0
后台启动ZooKeeper服务(这里使用kafka里自带的zookeeper启动服务,也可以自己下载安装zookeeper) 默认端口2181
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
*集群https://ken.io/note/zookeeper-cluster-deploy-guide
server.1=192.168.88.11:2888:3888
server.2=192.168.88.12:2888:3888
server.3=192.168.88.13:2888:3888
kafka配置文件,改完再启动Kafka 默认端口 9092
*集群 https://www.cnblogs.com/kentalk/p/kafka-cluster-deploy-guide.html
进入配置文件夹
cd /kafka_2.13-3.5.0/config
编辑server.properties
vim server.properties
• broker.id:唯一标识ID
• listeners=PLAINTEXT://localhost:9092:kafka服务监听地址和端口
• log.dirs:日志存储目录
• zookeeper.connect:指定zookeeper服务地址
在内网部署及访问kafka时,只需要配置listeners参数即可
listeners=PLAINTEXT://192.168.110.129:9092
1外网环境_在内网部署kafka服务,并且生产者或者消费者在外网环境时,需要添加额外的配置
listener.security.protocol.map=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
listeners=INTERNAL://192.168.110.129:9092,EXTERNAL://192.168.110.129:9093
advertised.listeners=INTERNAL://192.168.110.129:9092,EXTERNAL://<公网ip>:<端口>
inter.broker.listener.name=INTERNAL
2外网环境_此时zookeeper中的配置如下
{"listener_security_protocol_map":{"INTERNAL":"PLAINTEXT","EXTERNAL":"PLAINTEXT"},"endpoints":["INTERNAL://192.168.110.129:9092","EXTERNAL://<公网ip>:<端口>"],"jmx_port":-1,"host":"192.168.110.129","timestamp":"1578999811569","port":9092,"version":4}
stamp":"1578999811569","port":9092,"version":4}
cZxid = 0x500285971
ctime = Tue Jan 14 19:03:31 CST 2020
mZxid = 0x500285971
mtime = Tue Jan 14 19:03:31 CST 2020
pZxid = 0x500285971
cversion = 0
dataVersion = 0
aclVersion = 0+
ephemeralOwner = 0x30095ee6b3e3e58
dataLength = 236
numChildren = 0
新终端 启动Kafka
bin/kafka-server-start.sh config/server.properties
———————————————————安装到启动完成———————————————
———————————————————终端测试Kafka———————————————
新终端 Kafka创建一个主题 quickstart-events
bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092
终端 生产者
bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092
新终端 消费者
bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092
——————————————————————自行安装zookeeper————————————————————
下载zookeeper (网速很慢)
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.2/apache-zookeeper-3.8.2-bin.tar.gz
下载网址 https://zookeeper.apache.org/releases.html
解压
tar -zxvf zookeeper-3.4.12.tar.gz
创建数据和日志存放目录
cd /www/zookeeper/
mkdir data
mkdir log
把conf下的zoo_sample.cfg备份一份,然后重命名为zoo.cfg
cd conf/
cp zoo_sample.cfg zoo.cfg
配置zookeeper,编辑zoo.cfg文件
vim zoo.cfg
重新配置dataDir和dataLogDir的存储路径,就刚刚创建的目录
最后,启动 Zookeeper 服务 , 进入Zookeeper的bin目录
cd zookeeper/zookeeper-3.4.12/bin
启动Zookeeper
./zkServer.sh start
查询Zookeeper状态
./zkServer.sh status
关闭Zookeeper状态
./zkServer.sh stop
标签:bin,教程,--,zookeeper,192.168,kafka,9092,安装 From: https://www.cnblogs.com/shiding/p/17840294.html