首页 > 解决方案 > insertMany 下拉 mongodb 服务

问题描述

我有 API,我可以在其中获取数据。我mongoose用来将它保存到我的本地 MongoDB 中。每次保存时,我都会动态创建新的modelinsertMany在其上使用:

const data = result.Data;
const newCollectionName = `tab_${name.toLowerCase()}`;
const Schema = new mongoose.Schema({}, { strict: false });
const TAB = mongoose.model(newCollectionName, Schema);
return TAB.collection.drop(() => {
  // eslint-disable-next-line
  const clearJSONs = Object.values(data)
    .filter(x => typeof x === 'object');

  return TAB.insertMany(clearJSONs, (err, result2) => {
    // console.log(result2);
    res.json({ success: true });
  });
});

但是……后来,当一切都快完成时,我的猫鼬服务倒下了……而且……我什至不知道该怎么办。


更新。蒙哥日志:

2018-06-17T13:43:09.883+0300 E STORAGE  [conn58] WiredTiger error (24) [1529232189:883394][4799:0x7f9fe1d30700], WT_SESSION.create: /var/lib/mongodb/: directory-sync: open: Too many open files

如何解决这个问题?

标签: mongodbmongoose

解决方案


问题ulimits出在系统上。这个人描述了最好的解决方案


推荐阅读