Preparation before installation (zk been deployed)
Turn off the firewall
service iptables stop # temporarily closed chkconfig iptables OFF && setenforce 0 # permanently closed
java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
If not, please refer to the installation environment JDK installation method java ~ / .bashrc file (two way environment variable profile)
2. kafka upload files to the virtual machine kafka_2.12-2.2.0
rz command to bring up the upload window
ll command to view the uploaded files kafka
3. Installation kafka to decompress in / opt
. -zxvf kafka_2 the tar . 11 - 1.0 . 0 .tgz -C / opt / rename file kafka: . kafka_2 Music Videos . 11 - 1.0 . 0 / opt / kafka
4. Switch to the configuration file directory kafka
pwd
cd /opt/kafka/config
config file in the installation directory folder 5.kafka its configuration file, we need to modify are server.properties and zookeeper.properties.
Kafka used to live-logs - mkdir 0 the server.properties: Kafka used to live in the configuration file log.dirs = / tmp / kafka- logs amended as: log.dirs = / opt / Kafka used to live / Kafka used to live-logs - 0 host.name = your ip address zookeeper.properties kafka comes zookeeper arranged dataDir = / tmp / zookeeper modified to: dataDir = / opt / Kafka / my_zookeeper
6. Start zookeeper
/opt/kafka/bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties
7. Start kafka
/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties
8. Create a theme (let us create a theme called "test", and it contains only one partition, only one copy)
--create --zookeeper localhost /opt/kafka/bin/kafka-topics.sh: 2181 --replication factor- 1 --partitions 1 - Topic 1704d Note: Alternatively, you can configure the agent in a publication does not exist theme created automatically when the subject, instead of manually creating a theme.
9. View topic: If we run the command list topic, we can now see that the topic
/opt/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181
List localhost --broker-/opt/kafka/bin/kafka-console-producer.sh: 9092 - Topic 1704d > input waiting messages sent
11. Start Consumers
Server---bootstrap /opt/kafka/bin/kafka-console-consumer.sh 192.168 . 25.133 : 9092 --topic 1704d - from - Beginning starting from the first receiving / opt / kafka / bin / kafka -console- --bootstrap-Server consumer.sh 192.168 . 25.133 : 9092 --topic 1704d now started to accept the producers sent.