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