errmsg 解析端口 30000 代码 93 时的错误数字“\”

errmsg bad digit "\" while parsing port 30000 code 93

所以,我正在学习关于 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}] };

按下回车键后,我尝试 运行 rs.initiate 使用文件 democonfig

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"

解决了!刚刚删除了 javascript 代码之间的所有空格,它 运行 没问题。

我 运行 在 Pluralsight 的 "Introduction to MongoDb" 教程中遇到了同样的问题。以下是我在 "configuring a replica set" 部分中使用的内容:

{
    "_id": "demo",
    "members": [
        {
            "_id": 0,
            "host": "localhost:30000",
            "priority": 10
        },
        {
            "_id": 1,
            "host": "localhost:40000"
        },
        {
            "_id": 2,
            "host": "localhost:50000",
            "arbiterOnly": true
        }
    ]
}

我刚刚删除了 localhost: 和端口号 (localhost:30000) 之间的 space 以及其他 2 台主机的相同内容。效果很好。