Flink从Kafka读取数据存入MySQL
运行环境
os Version:win10
Flink Version:1.6.2
Kafka Version:0.9.0.0
MySQL Version:5.6.21
数据格式
1.74.103.143 2018-12-20 18:12:00 "GET /class/130.html HTTP/1.1" 404 https://search.yahoo.com/search?p=Flink实战
zookeeper
启动zookeeper
命令行输入zkserver(设置好环境变量)
> zkserver
kafka
启动kafka
kafka 安装目录
.inwindowskafka-server-start.bat .configserver.properties
创建topic
.inwindows 目录下
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test001
打开生产者
kafka-console-producer.bat --broker-list localhost:9092 --topic test
打开消费者
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test001 --from-beginning
mysql 建表
create table log_info(
ID INT NOT NULL AUTO_INCREMENT,
IP VARCHAR(50),
TIME VARCHAR(50),
CourseID VARCHAR(10),
Status_Code VARCHAR(10),
Referer VARCHAR(100),
PRIMARY KEY ( ID )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
查看表数据
select count(*) from log_info;