1、在主节点使用Flume采集/data_log目录下实时日志文件中的数据,将数据存入到Kafka的Topic中(Topic名称分别为ChangeRecord、ProduceRecord和EnvironmentData,分区数为4),将Flume采集ChangeRecord主题的配置截图粘贴至客户端桌面【Release\任务D提交结果.docx】中对应的任务序号下;
该题采用flume监听实时日志文件中的数据变化,采集到对应的kafka的topic中
首先需要修改kafka的配置,使其能远程访问,配置文件地址:$KAFKA_HOME/config/server.properties
key | value | 中文含义 |
---|---|---|
listeners | PLAINTEXT://0.0.0.0:9092 | 负责绑定网卡 |
advertised.listeners | PLAINTEXT://your.hostname:9092 | 负责发布外网地址,这个地址会发布到zookeeper中。 |
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# FORMAT:
# listeners = listener_name://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
# 表示内网所有网卡都绑定9092
listeners=PLAINTEXT://0.0.0.0:9092
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
# 表示外网的访问地址,此处应该修改为直连ip
advertised.listeners=PLAINTEXT://your.hostname:9092
可在配置文件中修改默认分区,此配置是在topic生成之前分区的,如果主题已创建,可使用
kafka-topics.sh --alter --bootstrap-server bigdata1:9092 --topic xxxx --partitions 4
修改分区
num.partitions=4
接下来我们启动实时脚本,如没有运行权限,可用chmod命令设置权限
该脚本每次启动都会生成3个新文件,并向每个文件末尾追加一行数据
==================