Analyzing MongoDB data using Hadoop mapreduce

Source: Internet
Author: User
Tags hadoop mapreduce

Use Hadoop MapReduce analyzes MongoDB data

(Many internet crawlers now store the data in Mongdb, so they study it and write this document)

Copyright NOTICE: This article is Yunshuxueyuan original article.
If you want to reprint please indicate the source: http://www.cnblogs.com/sxt-zkys/
QQ Technology Group: 299142667

First, the installation and use of Mongdb

1, official website download mongodb-linux-x86_64-rhel70-3.2.9.tgz

2, decompression (you can configure the environment variable)

3. Start the service side

./mongod--dbpath=/opt/local/mongodb/data--logpath=/opt/local/mongodb/logs--logappend--fork (background boot)

The first type: without AUTH certification

The second type: Requires auth authentication (that is, user name and password required)

When you specify the user name and password to view the data, the discovery can be seen

4. Start the client

./mongo

5. Client Shell command

Show DBS shows which databases are in MongoDB

DB Displays the database that is currently in use

Use DB name of the database you are using

(Note: If database does not exist, a will be created, and MongoDB will delete the database if it exits without any action)

Db.auth (Username,password) Username for username, password for password login to the database you want to use

Db.getcollectionnames () See what tables are in the current database

Db.  [Collectionname].insert ({...}) Add a document record to the specified database

Db. [Collectionname].findone () finds the first piece of data in a document

Db. [Collectionname].find () Find all records for a document

Db. [Collection].update ({query condition},{$set: {update content}}) updates a document record

Db. [Collection].drop () delete a collection from the database

Db.dropdatabase () Deleting a database

Data Example of the Mapreduce analysis MongoDB

1, write The MapReduce code, need to add two additional jar package, and need (jdk1.7 above)

2. Requirement Introduction and realization

Original data:

Result data:

Code writing:

Job:

Mapper:

Reduce:

The final result data:

Third, the last to recommend a MongoDB database management tools, very useful

Copyright NOTICE: This article is Yunshuxueyuan original article.
If you want to reprint please indicate the source: http://www.cnblogs.com/sxt-zkys/
QQ Technology Group: 299142667

Analyzing MongoDB data using Hadoop mapreduce

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.