step1:搭建flink环境
step2:搭建kafka环境(配置系统变量$KAFKA_HOME)
step3:搭建zookeeper环境
step4:启动zookeeper:进入zookeeper的bin目录下输入:zkServer.sh start
step5:启动kafka:进入kafka的bin目录下输入:kafka-server-start.sh $KAFKA_HOME/config/server.properties
step6:创建topic,生产者,消费者,查看topic状态
1.创建topic: zk
kafka-topics.sh --create --zookeeper hadoop001:2181 --replication-factor 1 --partitions 1 --topic hello_topic
2.查看所有topic
kafka-topics.sh --list --zookeeper hadoop001:2181
3.发送消息: broker
kafka-console-producer.sh --broker-list hadoop001:9092 --topic hello_topic
4.消费消息: zk
kafka-console-consumer.sh --zookeeper hadoop001:2181 --topic hello_topic --from-beginning
step7:生成wordCount demo代码
1.pom引用(kafka+flink+mysql)
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.11</artifactId>
<version>1.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.flink/flink-streaming-java -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.11</artifactId>
<version>1.0.0</version>
<!--<scope>provided</scope> -->
</dependency>
<dependency>
<groupId>org.apa