【发布时间】:2019-05-22 17:14:04
【问题描述】:
我正在本地机器上测试一个副本集。它仅用于测试。 我启动了本地 mongodb 实例 bin/mongod 然后启动三个实例,配置如下:
mongod --replSet rstest --logpath \data\rs2\2.log --dbpath \data\rs2 --port 27018 --smallfiles --oplogSize 64
mongod --replSet rstest --logpath \data\rs3\3.log --dbpath \data\rs3 --port 27019 --smallfiles --oplogSize 64
mongod --replSet rstest --logpath \data\rs3\3.log --dbpath \data\rs3 --port 27019 --smallfiles --oplogSize 64
然后我启动 mongo --port 27017 并输入以下配置:
config = {_id:“rstest”, members:[
{_id:0,host:“localhost:27017”},
{_id:1,host:“localhost:27018”},
{_id:2,host:“localhost:27019”}
]};
当我输入上述代码并按回车键时,我收到以下错误消息: E QUERY [js] SyntaxError: missing : after property id @(shell):1:101
E QUERY [js] SyntaxError: missing : after property id @(shell):1:101
我无法弄清楚小姐在哪里: 有没有办法让外壳屏幕显示行#s?或者 1:101 在哪里
知道为什么我会收到此错误吗?失踪的:应该去哪里?
【问题讨论】:
-
语法错误在这种情况下没有帮助。如果您已经准确地剪切和粘贴,问题是您在值周围有smart quotes(又名大引号)而不是普通的
"字符。如果将“和”直接替换为",则不会出现语法错误。不幸的是,在mongoshell 中没有打开行号的选项,因此您必须使用外部编辑器或计算错误消息中的行数和字符偏移量。 -
非常感谢。我根本没有注意到这一点。是的,这就是问题所在。 @Stennie 一切都按预期工作。我赞成您的评论,但无法接受它作为答案,因为它是评论,而不是答案。如果您输入答案,我将很乐意接受它作为答案,以便您获得奖励。
标签: mongodb mongodb-replica-set