1.JDK 1.8
2.zookeeper 3.4.8 Decompression
3.kafka Configuration
In the Kafka decompression directory under a config folder, which is placed in our configuration file
Consumer.properites consumer configuration, this profile is used to configure the consumers opened in section 2.5, where we use the default
Producer.properties producer configuration, this configuration file is used to configure the producers opened in section 2.5, where we use the default
Server.properties Kafka Server configuration, this profile is used to configure the Kafka server, currently only a few of the most basic configuration
-
- Broker.id affirms that the unique ID of the current Kafka server in the cluster needs to be configured as an integer, and that the ID of each Kafka server in the cluster should be unique, we use the default configuration here
- Listeners declare this Kafka server needs to listen to the port number, if it is running on the local virtual machine run can not configure this item, the default will use the address of localhost, if it is run on a remote server must be configured, for example:
listeners=plaintext://192.168.180.128:9092. And make sure that port 9092 of the server can access
3.zookeeper.connect Kafka the address of the zookeeper to be connected, the address that needs to be configured to zookeeper, because this time uses Kafka high version comes with the zookeeper, uses the default configuration to
zookeeper.connect=localhost:2181
4. Run Zookeeper I am the start command to the Zookeeper Bin directory: SH zkservwer.sh start
5. Start Kafka
Because it is not a cluster, it is the default configuration Kafka boot command: To Kafka bin./bin/kafka-server-start.sh config/server.properties success is as follows:
6.topic Test
1) In Kafka Unzip directory open terminal, enter
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic
test
创建一个名为test的topic
2) See if the creation was successful
./kafka-topics.sh --list --zookeeper localhost:2181
will appear test
3)创建一个消息消费者
在kafka解压目录打开终端,输入
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic
test
--from-beginning
可以创建一个用于消费topic为test的消费者 此时相当于一个控制台 不会有任何输出
4) Create a message producer
In the Kafka unzip directory open a new terminal, enter
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic
test
5) Consumption output:
This article refers to the blog address: https://www.cnblogs.com/hei12138/p/7805475.html
Kafka--linux Environment Construction