rmongodb支持MongoDB 3

时间:2015-06-26 04:54:21

标签: r mongodb rmongodb

我正在构建 R脚本,我需要通过身份验证连接到 MongoDB ,并使用 rmongodb <处理从数据库获取的数据/ strong> package。为此我在版本3.0.4 中创建了一个新的MongoDB用户,并且从 R脚本连接到mongoDB时,身份验证失败。 此外,用户通过mongo shell成功进行了身份验证。 当我验证在MongoDB版本2.x中创建的用户时,身份验证也能正常工作。

以下是我们在R脚本中用于连接Mongo数据库的代码片段。

  

mongo&lt; - mongo.create(&#34; 127.0.0.1&#34;,&#34;&#34;,&#34;用户&#34;,&#34;传递&#34;, &#34; db&#34;,0L)

执行上面的代码段时,我们收到以下回复

  

错误:加载所需的包:rmongodb身份验证失败。

请在rmongodb软件包中建议适当的身份验证失败问题解决方案。

2 个答案:

答案 0 :(得分:4)

rmongodb(从1.8.0开始)使用遗留的MongoDB C驱动程序,该驱动程序尚未完全支持MongoDB 3.0。特别是,它不支持使用新的SCRAM-SHA-1默认认证或可选的WiredTiger存储引擎。

Github中有一个rmongodb问题跟踪此问题:Compatibility with version 3.0 of MongoDB

在更新rmongodb之前,您的选项(按照最少到最顺利的顺序)包括:

  • 使用具有MongoDB 3.x支持的其他驱动程序(即RMongo 0.1.0 or newer

  • 使用MongoDB 2.6

  • 使用MongoDB 3.x但降级到较旧的MONGO-CR身份验证(并且不使用WiredTiger或任何其他存储引擎)

答案 1 :(得分:3)

刚刚完成了这件事,我想我会加上我的两分钱,以防有人帮忙。

@Stennie是正确的目标与身份验证的东西。因此,如果你想使用mongo 3,那么它的运行方式如下(这是来自ubuntu安装)。

1) sudo nano /etc/mongod.conf 2) Comment out the "auth=TRUE" line 3) sudo service mongod restart 4) login to mongo shell (now with no authentication so everything is open) 5) use admin 6) Execute the following: var schema = db.system.version.findOne({"_id" : "authSchema"}) schema.currentVersion = 3 db.system.version.save(schema) (the above 3 commands are from here: https://jira.mongodb.org/browse/SERVER-17459) 7) create your users in the appropriate database 8) to make sure the right credentials are set up, type db.system.users.find() and amke sure they have the MONGODB-CR credentials 9) quit mongo 10) ucomment out the authentication line in /etc/mongod.conf 11) restart mongodb using sudo service mongod restart

现在应该工作!我希望能帮助别人......