flume几种使用配置 avro spooling exec thrift

参考官网:

http://flume.apache.org/releases/content/1.9.0/FlumeUserGuide.html

# avro source
a1.sources = r1
a1.channels = c1
a1.sinks = k1
a1.sources.r1.type = avro
a1.sources.r1.channels = c1
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141
a1.sinks.k1.type = logger
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sinks.k1.channel = c1


# thrift source
a1.sources = r1
a1.channels = c1
a1.sinks = k1
a1.sources.r1.type = thrift
a1.sources.r1.channels = c1
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
a1.sinks.k1.channel = c1
a1.sinks.k1.type &
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用 Avro 数据源测试 Flume,您需要按照以下步骤进行操作: 1. 安装 Avro 在测试之前,您需要先安装 Avro。您可以从 Apache Avro 官方网站下载并安装 Avro。 2. 配置 FlumeFlume 中,您需要配置 Avro 作为数据源。以下是一个示例配置文件: ``` # Flume configuration file to receive data through Avro # Define the source, channel, and sink a1.sources = avro-source a1.channels = memory-channel a1.sinks = logger-sink # Describe/configure the source a1.sources.avro-source.type = avro a1.sources.avro-source.bind = localhost a1.sources.avro-source.port = 44444 # Describe the channel a1.channels.memory-channel.type = memory # Describe the sink a1.sinks.logger-sink.type = logger # Bind the source and sink to the channel a1.sources.avro-source.channels = memory-channel a1.sinks.logger-sink.channel = memory-channel ``` 在上面的配置文件中,我们定义了一个名为“avro-source”的 Avro 数据源,它绑定到本地主机的 44444 端口。我们还定义了一个名为“logger-sink”的日志记录器,它将数据写入 Flume 内存通道。 3. 启动 Flume 启动 Flume 并加载配置文件: ``` $ bin/flume-ng agent --conf conf --conf-file path/to/flume.conf --name a1 -Dflume.root.logger=INFO,console ``` 4. 发送数据 最后,您可以使用 Avro 发送数据到 Flume: ``` import org.apache.avro.ipc.SocketTransceiver; import org.apache.avro.ipc.specific.SpecificRequestor; import org.apache.avro.Protocol; import org.apache.avro.Schema; import org.apache.avro.generic.GenericData; import org.apache.avro.generic.GenericRecord; public class AvroTest { public static void main(String[] args) throws Exception { // Load the protocol and the schema Protocol protocol = Protocol.parse("{\"namespace\": \"com.example.avrotest\",\"type\": \"record\", \"name\": \"UserData\", \"fields\": [{\"name\": \"id\", \"type\": \"int\"}, {\"name\": \"name\", \"type\": \"string\"}, {\"name\": \"age\", \"type\": \"int\"}]}"); Schema schema = protocol.getType("UserData"); // Create a generic record using the schema GenericRecord userData = new GenericData.Record(schema); userData.put("id", 1); userData.put("name", "John"); userData.put("age", 30); // Connect to the Avro source and send the data SocketTransceiver transceiver = new SocketTransceiver(new InetSocketAddress("localhost", 44444)); SpecificRequestor requestor = new SpecificRequestor(protocol, transceiver); requestor.request("append", userData); transceiver.close(); } } ``` 在此示例中,我们创建了一个名为“UserData”的 Avro 记录,并将其发送到本地 Flume Avro 数据源。您可以根据需要更改模式和数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值