Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.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
Javascript ShardingTest()能否将非默认dbpath传递给mongod?_Javascript_Mongodb_Homebrew - Fatal编程技术网

Javascript ShardingTest()能否将非默认dbpath传递给mongod?

Javascript ShardingTest()能否将非默认dbpath传递给mongod?,javascript,mongodb,homebrew,Javascript,Mongodb,Homebrew,我正在OS X 10.11/15A263e上运行mongodb 3.0.6(),无法通过js代码指定非默认数据文件路径 我希望避免由于某些原因而在/data中弄乱符号链接或实际数据文件,但更重要的是,我希望了解如何使该类ShardingTest下面的代码正常工作: manoa:dev mike$ mongo --nodb MongoDB shell version: 3.0.6 > var options = { shardOptions : { dbpath : "/usr/local/

我正在OS X 10.11/15A263e上运行mongodb 3.0.6(),无法通过js代码指定非默认数据文件路径

我希望避免由于某些原因而在/data中弄乱符号链接或实际数据文件,但更重要的是,我希望了解如何使该类ShardingTest下面的代码正常工作:

manoa:dev mike$ mongo --nodb
MongoDB shell version: 3.0.6
> var options = { shardOptions : { dbpath : "/usr/local/var/mongodb" } };
> cluster = new ShardingTest( { shards : 3 }, { other : options } );
Resetting db path '/data/db/test0'
2015-08-31T07:54:03.707-0500 E QUERY    Error: boost::filesystem::create_directory: No such file or directory: "/data/db/test0"
    at Function.MongoRunner.runMongod (src/mongo/shell/servers.js:589:13)
    at new ShardingTest (src/mongo/shell/shardingtest.js:259:36)
    at (shell):1:11 at src/mongo/shell/servers.js:589
但是我的JS太弱,无法从那里的帮助中归纳出dbpath是如何设置的,以及哪些参数将覆盖默认路径


是否有人可以提出一种调试此脚本的方法,或提供将我首选的db路径提供给ShardingTest函数的实际语法?

MongoRunner。数据路径是:

因此,您可以将其设置为所需的任何目录,例如:

// don't forget the trailing slash
MongoRunner.dataPath = '/home/your_user/data/db/'
// don't forget the trailing slash
MongoRunner.dataPath = '/home/your_user/data/db/'