1 kafka 解压配置启动
[hadoop@bigdata1 package]$ tar -xzvf kafka_2.11-2.2.0.tgz [hadoop@bigdata1 package]$ mv kafka_2.11-2.2.0 ../kafka211 [hadoop@bigdata1 package]$ cd ../kafka211 [hadoop@bigdata1 kafka211]$ ls -l total 52 drwxr-xr-x 3 hadoop hadoop 4096 Mar 10 2019 bin drwxr-xr-x 2 hadoop hadoop 4096 Mar 10 2019 config drwxr-xr-x 2 hadoop hadoop 4096 Sep 26 14:08 libs -rw-r—r— 1 hadoop hadoop 32216 Mar 10 2019 LICENSE -rw-r—r— 1 hadoop hadoop 336 Mar 10 2019 NOTICE drwxr-xr-x 2 hadoop hadoop 4096 Mar 10 2019 site-docs [hadoop@bigdata1 kafka211]$
vi server.properties listeners=PLAINTEXT://:9092 log.dirs=/home/hadoop/kafka211/kafka-logs zookeeper.connect=bigdata1:2181
—————- 如果没有zookeeper,可以直接使用kafka安装包自带 ————————-
[root@host3 opt]# cd /opt/kafka2.3
[root@host3 kafka2.3]# sh bin/zookeeper-server-start.sh config/zookeeper.properties &[hadoop@bigdata1 config]$ mkdir /home/hadoop/kafka211/kafka-logs [hadoop@bigdata1 config]$ nohup /home/hadoop/kafka211/bin/kafka-server-start.sh /home/hadoop/kafka211/config/server.properties & [1] 6769 [hadoop@bigdata1 config]$jps 6769 Kafka [hadoop@bigdata1 config]
2 kafka-manager 解压配置启动
参考文档:
https://www.cnblogs.com/dadonggg/p/8205302.html
[hadoop@bigdata1 package]$ unzip kafka-manager-1.3.3.7.zip -d ./^C [hadoop@bigdata1 package]$ mv kafka-manager-1.3.3.7 ../kafka-manager [hadoop@bigdata1 package]$ cd ../kafka-manager [hadoop@bigdata1 kafka-manager]$ ls -l total 32 drwxrwxr-x 2 hadoop hadoop 4096 Sep 26 15:19 bin drwxrwxr-x 2 hadoop hadoop 4096 Sep 26 15:19 conf drwxrwxr-x 2 hadoop hadoop 12288 Sep 26 15:19 lib -rw-r—r— 1 hadoop hadoop 6335 Jun 5 2017 README.md drwxrwxr-x 3 hadoop hadoop 4096 Sep 26 15:19 share [hadoop@bigdata1 kafka-manager]$
[hadoop@bigdata1 conf]$ vi application.conf kafka-manager.zkhosts=”bigdata1:2181” [hadoop@bigdata1 conf]$ nohup /home/hadoop/kafka-manager/bin/kafka-manager -Dconfig.file=/home/hadoop/kafka-manager/conf/application.conf -Dhttp.port=9091 & [2] 10928 [hadoop@bigdata1 conf]$ nohup: ignoring input and appending output to ‘nohup.out’ [hadoop@bigdata1 conf]$ [hadoop@bigdata1 conf]$ jps 10928 ProdServerStart [hadoop@bigdata1 conf]$
3 kafka 写入数据
—————- 创建Topic —————————————————————— [root@host3 kafka2.3]# [root@host3 kafka2.3]# bin/kafka-topics.sh —create —zookeeper localhost:2181 —replication-factor 1 —partitions 1 —topic flink-topic Created topic flink-topic. [root@host3 kafka2.3]# bin/kafka-topics.sh —create —zookeeper localhost:2181 —replication-factor 1 —partitions 1 —topic flink-topic-output Created topic flink-topic-output. [root@host3 kafka2.3]# bin/kafka-topics.sh —list —zookeeper localhost:2181 flink-topic flink-topic-output [root@host3 kafka2.3]#—————- 发送消息 —————————————————————— [root@host3 kafka2.3]# /home/hadoop/kafka211/bin/kafka-console-producer.sh —broker-list bigdata1:9092 —topic dts_db_2_emr
aaa bbb
—————- 读取消息 —————————————————————— [root@host3 kafka2.3]# bin/kafka-console-consumer.sh —bootstrap-server localhost:9092 —topic flink-topic —from-beginning aaa bbb