虚拟机搭建
https://blog.csdn.net/qq_37598011/article/details/88960035
安装Java环境
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
\
下载完成后,上传压缩包:
rz
解压:
tar zxvf jdk-8u201-linux-x64.tar.gz
记下jdk目录,输入:
pwd
使用Vi编辑器,设置环境变量:
sudo vi /etc/profile
export JAVA_HOME=/myText/jdk1.8.0_201
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
环境生效:
source /etc/profile
安装zookeeper
http://apache.fayea.com/zookeeper/
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
下载后上传至linux:
rz
解压:
tar -zxvf zookeepre-3.4.13.tar.gz
进入目录后创建data目录:
cd zookeeper-3.4.13
mkdir data
进入conf文件夹:
cd conf/
将zoo_sample.cfg复制一份并重命名为zoo.cfg:
cp zoo_sample.cfg zoo.cfg
修改zoo.cfg中dataDir路径为刚刚创建的data:
vim zoo.cfg
修改server.properties文件(我的配置如下):
vim server.properties
broker.id=0
############################# Socket Server Settings #############################
listeners=PLAINTEXT://192.168.78.133:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
############################# Log Basics #############################
log.dirs=/data/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
############################# Internal Topic Settings #############################
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
############################# Log Flush Policy #############################
# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000
# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000
############################# Log Retention Policy #############################
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
############################# Zookeeper #############################
zookeeper.connect=192.168.78.133:2181
zookeeper.connection.timeout.ms=6000
############################# Group Coordinator Settings #############################
group.initial.rebalance.delay.ms=0
进入bin目录:
cd ../bin/
启动zkServer.sh:
./zkServer.sh start
OK~再看看状态:
输入jps:
安装Kafak
http://apache.01link.hk/kafka/2.2.0/
wget http://apache.01link.hk/kafka/2.2.0/kafka_2.11-2.2.0.tgz
解压:
tar -zxvf kafka_2.11-2.2.0.tgz
进入bin目录后,启动kafak:
bin/kafka-server-start.sh config/server.properties &
检测2181与9092端口:
netstat -tunlp|egrep "(2181|9092)"
单机测试:
提供者:
bin/kafka-console-producer.sh --broker-list 192.168.234.128:9092 --topic test
消费者:
bin/kafka-console-consumer.sh --zookeeper 192.168.234.128:2181 --topic test --from-beginning
注意!!!!(高版本可能会报错:)
这时候需要用如下命令:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
OK!
来源:CSDN
作者:蛇皮皮蛋
链接:https://blog.csdn.net/qq_37598011/article/details/88980317