简体   繁体   English

rmongodb支持MongoDB 3

[英]rmongodb support for MongoDB 3

I am building a R script in which I need to connect to MongoDB through authentication and process the data fetched from database using rmongodb package.For that I have created a new MongoDB user in version 3.0.4 and while connecting to mongoDB from R script authentication fails. 我正在构建一个R脚本 ,我需要通过身份验证连接到MongoDB并使用rmongodb包处理从数据库获取的数据。为此我在3.0.4版本中创建了一个新的MongoDB用户,同时从R脚本身份验证连接到mongoDB失败。 Also the user is authenticated successfully through mongo shell. 此外,用户通过mongo shell成功进行了身份验证。 Also authentication works fine while I authenticate user created in MongoDB version 2.x. 当我验证在MongoDB版本2.x中创建的用户时,身份验证也正常工作。

Following is code snippet which we have used in R script to connect to Mongo database. 以下是我们在R脚本中用于连接Mongo数据库的代码片段。

mongo <- mongo.create("127.0.0.1", "", "user", "pass", "db", 0L ) mongo < - mongo.create(“127.0.0.1”,“”,“user”,“pass”,“db”,0L)

While executing above code snippet we receive the following response 在执行上面的代码段时,我们会收到以下响应

error: Loading required package: rmongodb Authentication failed. 错误:加载所需的包:rmongodb身份验证失败。

Please suggest me appropriate solution to authentication failure issue in rmongodb package. 请建议我在rmongodb包中解决身份验证失败问题。

rmongodb (as at 1.8.0) uses a legacy MongoDB C driver which doesn't have full support for MongoDB 3.0 yet. rmongodb (在1.8.0)使用遗留的MongoDB C驱动程序, rmongodb没有完全支持MongoDB 3.0。 In particular, it will not support using the new SCRAM-SHA-1 default authentication or optional WiredTiger storage engine. 特别是,它不支持使用新的SCRAM-SHA-1默认身份验证或可选的WiredTiger存储引擎。

There's an rmongodb issue in Github tracking this: Compatibility with version 3.0 of MongoDB . 在Github中有一个rmongodb问题跟踪这个: 与MongoDB 3.0版的兼容性

Until rmongodb is updated your options (in order of least to most hasslesome) include: 在更新rmongodb之前,您的选项(按照最少到最顺利的顺序)包括:

  • use a different driver which does have MongoDB 3.x support (ie RMongo 0.1.0 or newer ) 使用具有MongoDB 3.x支持的不同驱动程序(即RMongo 0.1.0或更高版本

  • use MongoDB 2.6 使用MongoDB 2.6

  • use MongoDB 3.x but downgrade to the older MONGO-CR auth (and do not use WiredTiger or any alternative storage engines) 使用MongoDB 3.x但降级到较旧的MONGO-CR auth(并且不使用WiredTiger或任何替代存储引擎)

Having just gone through this myself, I thought I'd add my two cents in case it helps someone. 刚刚经历过这个问题,我想我会加上我的两分钱以防万一。

@Stennie is right on target to with the authentication stuff. @Stennie是正确的目标与身份验证的东西。 So if you want to use mongo 3 the way to get it going is as follows (this is from a ubuntu install). 因此,如果你想使用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

should work now! 现在应该工作! I hope that helps someone... 我希望能帮到某个人......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM