Flume Learning application: Write log data to MongoDB and flumemongodb in Java

Source: Internet
Author: User

Flume Learning application: Write log data to MongoDB and flumemongodb in Java
Overview

Windows: Java writes logs to Flume, and Flume writes the logs to MongoDB. System Environment
  • Operating System: win7 64
  • JDK: 1.6.0 _ 43
Download Resources
  • Maven: 3.3.3
    Download, install, and get started: 1. Maven-start and 2. Create a simple Maven Project
  • Flume: 1.6.0
    Download apache-flume-1.6.0-bin.tar.gz and decompress it to the appropriate directory (e.g. F: \ temp \ apache-flume-1.6.0-bin)
  • MongoDB: 3.2.3
    Download the mongodb-win32-x86_64-3.2.3-signed.msi and install it to the appropriate directory (e.g. D: \ develop \ MongoDB)
Auxiliary resource download
  • MongoDB Java Driver: 2.8.0
    : Mongo-java-driver-2.13.0.jar
    Download the package and place it in the lib of the Flume installation directory.
  • Flume-ng-mongodb-sink
    This is required for Flume to write data to MongoDB.
    : Flume-ng-mongodb-sink
    This is a Maven-based source code. After package, put the jar package under the lib of the Flume installation directory.
Initialization Specify dbpath for data initialization to MongoDB. Configure Flume implementation Flume to MongoDB under the conf of the Flume installation directory, add mongo-agent.properties:
agent.sources = so1agent.channels = c1agent.sinks = s1agent.sources.so1.type = avroagent.sources.so1.bind = 0.0.0.0agent.sources.so1.port = 44444agent.sources.so1.channels = c1agent.channels.c1.type = memoryagent.channels.c1.capacity = 1000agent.channels.c1.transactionCapacity = 100agent.sinks.s1.type = org.riderzen.flume.sink.MongoSinkagent.sinks.s1.host = localhostagent.sinks.s1.port = 27017agent.sinks.s1.model = singleagent.sinks.s1.db = testagent.sinks.s1.collection = logagent.sinks.s1.batch = 100agent.sinks.s1.channel = c1

Simple Description:

Java to Flume this is a Maven-based simple project, you can get the source code from the flume-ng-java2mongodb. File structure
src/main/java    |---- cn.sinobest.flume.client.demo              |---- LogDemo.javasrc/main/resources    |---- log4j.propertiespom.xml
Document Content test Appendix References

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.