1. Please download the installation file, java environment in advance to install, unzip to the specified directory:
tar -zxvf kafka_2.11-2.3.1.tgz -C / root / Soft /
From the official website to download the file, upload it to centos virtual machine specified path, the current download folder below
Unzip to the specified directory soft folder below:
2. Create zk log directory.
zklogs mkdir
3. Check whether a successful start,
PS -ef | grep ZooKeeper
4. Start zookeeper
nohup bin/zookeeper-server-start.sh ./config/zookeeper.properties &
5. Modify configuration kafka
vim config / server.properties
Run vi config / server.properties kafka modify configuration information
modifying advertised.host.name advertised.port information and
change log file path:
Review log.dirs = / root / soft / kafka -logs is log .dirs = / root / soft / kafka / logs the parameter is a stored log file path kafka
advertised.host.name=192.168.132.152
advertised.port=9092
log.dirs=/root/soft/kafka/logs
6. Start kafka
nohup bin/kafka-server-start.sh ./config/server.properties
Execute the command ps -ef | grep kafka kafka see if started successfully
7. 创建mytest主题
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic mytest
Get all topic
bin / kafka-topics.sh --list --zookeeper localhost: 2181
8. The production test message
bin / kafka-console-producer.sh --broker-list localhost: 9092 --topic mytest
9. Consumer news
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic mytest --from-beginning
kafka java installation file and network disk download address:
Link: https: //pan.baidu.com/s/1DhbzsKvqB7Y3S9QJQUUK9A
extraction code: zim2