单机版kafka的安装
简单记录单机版kafka的安装:
JDK1.8(jdk-8u131-linux-x64.rpm)
zookeeper (zookeeper-3.4.10.tar.gz)
kafka (kafka_2.12-2.0.0.tgz)
安装好JDK后
一、zookeeper安装
1、下载:wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
2、解压: tar -zxvf zookeeper-3.4.10.tar.gz
3、配置:
cd zookeeper-3.4.10/conf/
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
写入配置:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/data/zookeeper
dataLogDir=/var/log/kafka/zk
clientPort=2181
server.1=localhost:2888:3888
4、启动
./zkServer.sh start #启动
./zkServer.sh status #查看节点状态
二、安装kafka
1、下载:wget https://archive.apache.org/dist/kafka/2.0.0/kafka_2.12-2.0.0.tgz
2、解压:tar -zxvf kafka_2.12-2.0.0.tgz
3、启动:./kafka-server-start.sh ../config/server.properties &
4、使用jps查看启动情况:
[root@centos7 bin]# jps
19815 Kafka
19032 QuorumPeerMain
33307 Jps
三、测试kafka
创建一个topic: ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_kafka
查看创建的topic: ./kafka-topics.sh --list --zookeeper localhost:2181
启动消费者: ./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_kafka --from-beginning
启动生产者: ./kafka-console-producer.sh --broker-list localhost:9092 --topic test_kafka