部署zookeeper
官网下载zookeeper二进制包
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.2/apache-zookeeper-3.8.2-bin.tar.gz
解压
tar zxvf apache-zookeeper-3.8.2-bin.tar.gz
修改配置文件
cd apache-zookeeper-3.8.2-bin/conf
mv zoo_sample.cfg zoo.cfg
[root@riverxyz conf]# grep -Ev "^$|#" zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/apache-zookeeper-3.8.2-bin/data
clientPort=2181
启动
cd ..
bin/zkServer.sh start
部署kafka
官网下载二进制包
wget https://downloads.apache.org/kafka/3.5.1/kafka_2.13-3.5.1.tgz
解压
tar zxvf https://downloads.apache.org/kafka/3.5.1/kafka_2.13-3.5.1.tgz
修改配置文件
cd kafka_2.13-3.5.1/conf
[root@riverxyz kafka_2.13-3.5.1]# grep -Ev "^$|#" config/server.properties
broker.id=0
listeners=PLAINTEXT://:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.retention.check.interval.ms=300000
zookeeper.connect=10.10.10.103:2181
zookeeper.connection.timeout.ms=18000
group.initial.rebalance.delay.ms=0
主要是以下这三个位置
listeners=PLAINTEXT://:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
zookeeper.connect=10.10.10.103:2181
启动
bin/kafka-server-start.sh -daemon config/server.properties
创建测试Topic
bin/kafka-topics.sh --create --topic testTopic --replication-factor 1 --partitions 1 --bootstrap-server 10.10.10.103:9092
Created topic testTopic
查看Topic
bin/kafka-topics.sh --bootstrap-server 10.10.10.103:9092 --list
__consumer_offsets
my-new-topic
testTopic
topicname
从Topic生产消息
运行生产者后从>后面输入信息
bin/kafka-console-producer.sh --broker-list 10.10.10.103:9092 --topic testTopic
>this is a TestTopic
消费Topic
运行消费得后会输出前面生产者输入的信息
bin/kafka-console-consumer.sh --bootstrap-server 10.10.10.103:9092 --topic testTopic
this is a TestTopic
标签:bin,单机版,SSL,--,zookeeper,kafka,PLAINTEXT
From: https://blog.51cto.com/riverxyz/7058526