1.关于 mongdb 导出数据问题,在测试中使用./mongoexport -h 192.168.1.205 -d el_shop_goods -c access_exception_log --type=csv --fields accessDate -o /home/txt.txt 导出数据极慢~
2.可能跟内存与机器性能有关,如下 js 代码可以加快速度
定义:export-cash-bill.js
var time=yestoday
db.bill_flowing.find({'syncTimeStr':{$regex:time}}).forEach(
function(x){
print([
x['flowNo'],
x['totalAmount'],
x['status']+'',
x['source']+'',
x['cashTime'],
x['remark'],
x['deviceNo'],
x['syncTimeStr'],
x['couponCount']+'',
x['cashTradeNo'],
x['couponAmount'],
x['integralAmount'],
x['ticket'],
x['shopId'],
x['storeId'],
x['createTimeStr'],
x['payAmount'],
x['payType']+'',
x['payTimeStr'],
x['onduty'],
x['outTradeNo'],
x['payUser'],
x['openId']
]
);
}
)
定义:export-cash-bill.sh
yestoday=`date -d "1 day ago" +"%Y-%m-%d"`
/apps/svr/mongodb/bin/mongo 192.168.1.228 --eval "var host='192.168.1.228', dbname='ws_shop_pos',yestoday='"$yestoday"'" /apps/export/export-cash-bill.js |awk '{if(NR>3) print $0}' > /apps/data/cash_bill/cash_bill_$yestoday.csv
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于