Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB无法在NFS共享上分配数据文件_Mongodb_Nfs_File Locking_Vagrant - Fatal编程技术网

MongoDB无法在NFS共享上分配数据文件

MongoDB无法在NFS共享上分配数据文件,mongodb,nfs,file-locking,vagrant,Mongodb,Nfs,File Locking,Vagrant,背景: 我用流浪汉(http://vagrantup.com/)创建用于开发的虚拟机。我使用一个名为Buildout的Python构建系统来管理和构建我的项目。我使用一个构建配方来安装和配置MongoDB。它将MongoDB数据放入项目中的一个目录中。当不使用虚拟机时,这一切都可以正常工作。Vagrant的设置使源代码存储库存在于主机上,并由虚拟机通过NFS访问 我想做什么: 我希望以流浪用户身份运行mongod(在来宾操作系统中),并将数据目录保存在NFS共享中。尝试这样启动服务器会导致错误:

背景:
我用流浪汉(http://vagrantup.com/)创建用于开发的虚拟机。我使用一个名为Buildout的Python构建系统来管理和构建我的项目。我使用一个构建配方来安装和配置MongoDB。它将MongoDB数据放入项目中的一个目录中。当不使用虚拟机时,这一切都可以正常工作。Vagrant的设置使源代码存储库存在于主机上,并由虚拟机通过NFS访问

我想做什么:
我希望以流浪用户身份运行mongod(在来宾操作系统中),并将数据目录保存在NFS共享中。尝试这样启动服务器会导致错误:

vagrant@natty:/nfs_share$ bin/mongod --dbpath /nfs_share/mongodb/data --master --port 27001 --directoryperdb -vvvvv
Thu Oct 13 18:30:38 isInRangeTest passed
Thu Oct 13 18:30:38 shardKeyTest passed
Thu Oct 13 18:30:38 shardObjTest passed
Thu Oct 13 18:30:38 must specify both start and end of balancing window: { start: 1 }
Thu Oct 13 18:30:38 must specify both start and end of balancing window: { stop: 1 }
Thu Oct 13 18:30:38 cannot parse active window (use hh:mm 24hs format): { start: "21:30", stop: "28:35" }
Thu Oct 13 18:30:38 BalancingWidowObjTest passed
Thu Oct 13 18:30:38 BackgroundJob starting: DataFileSync
Thu Oct 13 18:30:38 versionCmpTest passed
Thu Oct 13 18:30:38 [initandlisten] MongoDB starting : pid=3240 port=27001 dbpath=/nfs_share/mongodb/data master=1 64-bit 
Thu Oct 13 18:30:38 [initandlisten] db version v1.8.1, pdfile version 4.5
Thu Oct 13 18:30:38 [initandlisten] git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04
Thu Oct 13 18:30:38 [initandlisten] build sys info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Thu Oct 13 18:30:39 [initandlisten] query: local.system.namespaces{ name: /^local.temp./ }
Thu Oct 13 18:30:39 [initandlisten] Accessing: local for the first time
Thu Oct 13 18:30:39 [initandlisten]    used cursor: 0x182e180
Thu Oct 13 18:30:39 [initandlisten] query local.system.namespaces reslen:36 nreturned:0 1ms
Thu Oct 13 18:30:39 [initandlisten] enter repairDatabases (to check pdfile version #)
Thu Oct 13 18:30:39 [initandlisten] done repairDatabases
Thu Oct 13 18:30:39 [initandlisten] waiting for connections on port 27001
Thu Oct 13 18:30:39 [initandlisten] master=true
Thu Oct 13 18:30:39 [initandlisten] ******
Thu Oct 13 18:30:39 [initandlisten] creating replication oplog of size: 944MB...
Thu Oct 13 18:30:39 [initandlisten] create collection local.oplog.$main { size: 990000000.0, capped: true, autoIndexId: false }
Thu Oct 13 18:30:39 [FileAllocator] allocating new datafile /nfs_share/mongodb/data/local/local.ns, filling with zeroes...
Thu Oct 13 18:30:39 [FileAllocator] warning: posix_fadvise fails /nfs_share/mongodb/data/local/local.ns errno:1 Operation not permitted
Thu Oct 13 18:30:39 [FileAllocator] FileAllocator: posix_fallocate failed: errno:9 Bad file descriptor falling back
Thu Oct 13 18:30:39 [FileAllocator] error failed to allocate new file: /nfs_share/mongodb/data/local/local.ns size: 16777216 errno:9 Bad file descriptor
Thu Oct 13 18:30:39 [initandlisten] New namespace: local.oplog.$main
New namespace: local.system.namespaces
Assertion: 12520:new file allocation failure
Thu Oct 13 18:30:39 [initandlisten] exception in initAndListen std::exception: new file allocation failure, terminating
Thu Oct 13 18:30:39 dbexit: 
Thu Oct 13 18:30:39 [initandlisten] shutdown: going to close listening sockets...
Thu Oct 13 18:30:39 [initandlisten] shutdown: going to flush diaglog...
Thu Oct 13 18:30:39 [initandlisten] shutdown: going to close sockets...
Thu Oct 13 18:30:39 [initandlisten] shutdown: waiting for fs preallocator...
Thu Oct 13 18:30:39 [initandlisten] shutdown: closing all files...
Thu Oct 13 18:30:39 closeAllFiles() finished
Thu Oct 13 18:30:39 [initandlisten] shutdown: removing fs lock...
Thu Oct 13 18:30:39 BackgroundJob starting: ClientCursorMonitor
Thu Oct 13 18:30:39 BackgroundJob starting: snapshot
Thu Oct 13 18:30:39 dbexit: really exiting now
mongod无法创建数据文件。错误消息是“警告:posix\u fadvise失败/nfs\u共享/mongodb/data/local/local.ns错误号:1不允许操作”。这最初表明文件权限是错误的。我不认为是这样,因为数据目录是组可写的,而vagrant位于组“dialut”中,该组是NFS共享的组所有者。我的第二个猜测是NFS是罪魁祸首。当我在非NFS的文件系统上运行此命令时,一切正常。我不确定出了什么问题。在MongoDB邮件列表上搜索发现一条来自某人的消息(),称如果数据目录不支持独占锁定,NFS将无法与MongoDB一起工作

可能的解决方案:
在存储库中放置指向非NFS位置的数据目录的符号链接

  • 这就是我目前正在做的。这不是很好,因为它不适用于构建配方,必须手动完成
  • 没有简单的方法可以确定构建是否在虚拟机中运行。也许它可以检测文件系统是否为NFS并编写相应的脚本
  • 将项目的组件放在不同的地方有点烦人。相反,Postgres的数据在别处,那么为什么不把MongoDB的数据也放在别处呢
问题:

  • 我看到的错误实际上与NFS有关吗?还是有其他可能的原因
  • 独占锁定是NFS的一项功能吗?可以启用/禁用它吗
  • 我在MongoDB邮件列表上看到有人在NFS上运行MongoDB。这样做需要特别考虑吗