mongoDB id 导出,dump,sed,count,mysql import等用法示例
#count collection
db.news.count({"lpublishtime":{"$gte":1358697600000}});
#mongo导出
mongoexport -h 192.168.1.175 --port 33000 -d booaa_so -c weibo -f ‘_id‘ -q "{\"lweibotime\":{\"\$gte\":1349020800000,\"\$lt\":1351699200000}}" -o weibo_20121201_33000.ids &
######################20121227.txt######################
#mongo导出0.1
mongoexport --port 33000 -d booaa_so -c bbs -f ‘_id‘ -o 33000.bbs.ids;
#替换,将导出的文件内容替换成一个插入sql语句
#sed v1
sed ‘s/{ "_id" : { "\$oid" : /insert ignore into index_quene3_test (id,createtime) values (/‘ 33001.bbs.ids> 33001.bbs.ids_tmp
sed ‘s/ } }/,now());/‘ 33001.bbs.ids_tmp> 33001.bbs.ids_final
#sed v2
sed ‘s/{ "_id" : { "\$oid" : "/ /‘ 20130121_33002_bbs.ids> 20130121_33002_bbs.ids_tmp
sed ‘s/" } }/ /‘ 20130121_33002_bbs.ids_tmp> 20130121_33002_bbs.ids_final
#sed 3
sed ‘s/insert into index_quene/insert ignore into index_quene/‘ 33001.weibo.ids_final> 33001.weibo.ids_fffff
#mysql导入
#2013-01-12 import
mysql -um4n -p01D060A476642BA8335B832AC5B211F222F641B5 -h192.168.1.136 -D boss_db < 33002.bbs.ids_final &
mysql -um4n -p01D060A476642BA8335B832AC5B211F222F641B5 -h192.168.1.136 -D boss_db < 33002.blog.ids_final &
#统计文件行数数量
[webadmin@idc89 ~]$ wc -l weibo_20130121_33002.ids_final
4942900 weibo_20130121_33002.ids_final
#index_module mv
mv busstmp/weiboMerge/weibo0/* buss/weibo0/
mv busstmp/weiboMerge/weibo1/* buss/weibo1/
#mysql sql import
insert ignore into index_quene4 (id,createtime) select id,createtime from index_quene4_test;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。