因此,我正在学习关于Pluralsight的MongoDB教程,并且能够在同一台机器上创建a、b和c数据库。在成功地创建了这三个端口之后,我在端口30000上运行mongo,它是我的主数据库的端口。
>mongo --port 30000它显示连接到端口,然后我键入
db.getMongo()
它连接到了地址
我输入了一个javascript对象,就像Pluralsight上的那个家伙做的那样
>var democonfig={ _id: "demo", members: [{ _id: 0, host: 'localhost: 30000', priority: 10}, { _id: 1, host: 'localhost: 40000'}, { _id: 2, host: 'localhost: 50000', arbiterOnly: true}] };按enter之后,我尝试使用democonfig文件运行rs.initiate。
rs.initiate(democonfig)这是我得到的错误:
{ "ok" : 0, "errmsg" : "Bad digit \" \" while parsing 30000", "code" : 93 }这就是我的replicaSet bat文件的样子。
cd \Pluralsight\
md \Pluralsight\db1
md \Pluralsight\db2
md \Pluralsight\db3
@REM Primary
start "a" c:\MongoDB\bin\mongod.exe --dbpath ./db1 --port 30000 --replSet "demo"
@REM Secondary
start "b" c:\MongoDB\bin\mongod.exe --dbpath ./db2 --port 40000 --replSet "demo"
@REM Arbiter
start "c" c:\MongoDB\bin\mongod.exe --dbpath ./db3 --port 50000 --replSet "demo"发布于 2015-10-11 19:15:40
我在Pluralsight的教程中也遇到了同样的问题:“MongoDb入门教程”。下面是我在“配置副本集”部分中使用的内容:
{
"_id": "demo",
"members": [
{
"_id": 0,
"host": "localhost:30000",
"priority": 10
},
{
"_id": 1,
"host": "localhost:40000"
},
{
"_id": 2,
"host": "localhost:50000",
"arbiterOnly": true
}
]
}发布于 2015-09-17 17:58:12
解决了!只要删除javascript代码之间的所有空格,它就能正常运行。
发布于 2017-08-09 00:34:49
我刚刚删除了localhost:和端口号(localhost:30000)之间的空间,以及其他两个主机的相同空间。效果很好。
https://stackoverflow.com/questions/32636451
复制相似问题