Execute SH file for MongoDB business logic Import

Source: Internet
Author: User

After converting data from HDFS to JSON format, the file name of the 10 files is filename _01 .... _02. 03 format. Write a simple sh file with the i+1 file name corresponding to the-do loop-the path of the file names to be passed in and the data files that need to be imported when executing, so that they can be passed in to facilitate the project to change the directory.

. sh Files:

However, there is no confusion! Discover./mongo-h 10.1.235.62-port 27017--eval "db."  ${name} ". Drop ()" does not work! It's--eval's problem ... The old version is can be executed, because it is a timed job, each import will first delete the original collection AH ~ torture not to be. Because of a variety of Baidu no fruit, there are few such use of articles, so, the code is changed-each time the shell file will be executed manually query count () if more than 0 remove the collection data good ~ the same ~

The last command specified is in the bin directory of MongoDB:./batchimport.sh dw_label_datas_crm/home/mongodb/mongodb/importdatafile

That's it. But still ask to teach--eval usage ... Seems to write a JS script ... Also please pass by the great God Enlighten.

Execute SH file for MongoDB business logic Import

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.