apache flink网站上的例子需要安装kafka, 按照https://kafka.apache.org/quickstart 安装启动server报内存不足
bin
/zookeeper-server-start
.sh config
/zookeeper
.properties
bin
/kafka-server-start
.sh config
/server
.properties
然后进入kafka_2.12-0.11.0.0的bin目录,找到kafka-server-start.sh文件,vi kafka-server-start.sh
找到这一行export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
改为 export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M" 正常启动
1、创建主题
bin
/kafka-topics
.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic
test
2.查看主题
bin
/kafka-topics
.sh --list --zookeeper localhost:2181
3.生产者生产消息
bin
/kafka-console-producer
.sh --broker-list localhost:9092 --topic
test
4.消费者取出消息
bin
/kafka-console-consumer
.sh --bootstrap-server localhost:9092 --topic
test
--from-beginning