Mongodb errmsg错误数字“\&引用;解析端口30000代码93时

Mongodb errmsg错误数字“\&引用;解析端口30000代码93时,mongodb,mongoose,replicaset,database,Mongodb,Mongoose,Replicaset,Database,因此,我正在学习关于Pluralsight的MongoDB教程,我已经能够在同一台机器上创建a、b和c数据库。成功创建这三个端口后,我在端口30000上运行mongo,该端口是我的主数据库的端口 >mongo --port 30000 它显示连接到端口,然后我键入 db.getMongo() 它连接到了那个地址 我在Pluralsight上输入了一个javascript对象 >var democonfig={ _id: "demo", members: [{ _id: 0, hos

因此,我正在学习关于Pluralsight的MongoDB教程,我已经能够在同一台机器上创建a、b和c数据库。成功创建这三个端口后,我在端口30000上运行mongo,该端口是我的主数据库的端口

>mongo --port 30000
它显示连接到端口,然后我键入

db.getMongo()

它连接到了那个地址

我在Pluralsight上输入了一个javascript对象

>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"

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

我在Pluralsight的“MongoDb简介”教程中遇到了同样的问题。以下是我在“配置副本集”部分中使用的内容:


我刚刚删除了localhost:和端口号(localhost:30000)之间的空间,其他两台主机也是如此。它工作得很好

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