mongoimport失败:连接到数据库服务器时发生错误:无法在Google计算机上托管服务器

问题描述:

我正在使用以下代码尝试导入json文档的json数组。无论我做什么,我都会在标题中看到错误。我正在使用名为rs0的副本集。我正在运行mongod服务的gcompute实例中的命令。我试图使用localhost127.0.0.1作为本地主机种子。而第二个副本成员的IP。以及localhost的外部IP。mongoimport失败:连接到数据库服务器时发生错误:无法在Google计算机上托管服务器

mongoimport --db <db_name> --collection <collection_name> --username <uname> --password <pass> --host rs0/[ip_of_other_replica_member:27017],[127.0.0.1:27017] --type json --file "/tmp/json_backup_wilf17/json_array (10).json" --jsonArray --authenticationDatabase <db_name(same as --db)> 

提到我不断收到失败:错误连接到数据库服务器:没有可达服务器

mongod正在运行。我可以登录到mongo shell。我尝试使用rs.slaveOk(),现在我想出了一些想法。

当我忘记rs.initiate()调用时,我现在也陷入了这种情况(手动创建集群)。

尝试检查您是否确实拥有副本集配置。

后很长一段时间看这个,这是最愚蠢的理由:

--file “的/ tmp/json_backup_wilf17/json_array(10)以.json”

通知'阵列'中的'y'和'('('10')'之间的空格?将其消除并且它将起作用

这是一个代表Mongodb的模糊错误的问题