First download Mongo-hadoop Adapter
git clone https://github.com/mongodb/mongo-hadoop.git
git checkout release-1.0
Then go to the Mongo-hadoop directory and find BUILD.SBT to modify hadoop920.html ">release in Thisbuild as follows:
Hadooprelease in Thisbuild: = "0.20"
Then run./SBT package (about SBT Https://github.com/harrah/xsbt/wiki)
It is necessary to turn the & wall when running.
At the end of the run, a jar file Mongo-hadoop-core_0.20.205.0-1.0.1.jar is core/target in the directory, then the MongoDB driver package is downloaded.
wget--no-check-certificate Https://github.com/downloads/mongodb/mongo-java-driver/mongo-2.7.3.jar After downloading, you can start to develop the Mongo-hadoop program.
Run the sample: first import the data into the MongoDB, and the commands are as follows.
./SBT Load-sample-data
Then create a new project in Eclipe, such as Treasury, to copy the source and resource files from Mongo-hadoop/example/treasury_field to the new project.
As shown in the figure:
Then modify the URL of the MongoDB in the Mongo-treasury_yield.xml file and store collection
Mongo.input.uri
Mongodb://127.0.0.1/mongo_hadoop.yield_historical.in
Mongo.output.uri
Mongodb://127.0.0.1/mongo_hadoop.yield_historical.out
Then modify the Treasuryyieldxmlconfig.java as follows:
Configuration.adddefaultresource ("Resources/mongo-treasury_yield.xml");
Configuration.adddefaultresource ("Resources/mongo-defaults.xml");
The project is packaged into a jar file.
Run Hadoop jar Treasury.jar Com.mongodb.hadoop.treasury.TreasuryXMLConfig to run the Hadoop program. The results of the operation are as follows: Data in MongoDB.
Copyright: Original works, allow reprint, reprint, please be sure to hyperlink form to indicate the original source of the article, author information and this statement. Otherwise, it will be held liable http://www.51ou.com/browse/MongoDB/51808.html