Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Hive connection to MongoDB with userid/pw

Hive connection to MongoDB with userid/pw

New Contributor

Hi,

I am trying to connect to mongodb and read the collection from the db. It is working ok with non secured db when no need of authorization. With the secured access

We have provided the username and password to the connector (eg. mongo.input.uri = "mongodb://myuser:mypassword@host:27017/mydb.mycollection"), for an Hadoop Job that pulls data from the database. I am geeting the message similar to the following: java.io.IOException: java.io.IOException: java.lang.RuntimeException: Unable to calculate input splits from collection stats: not authorized on mydb to execute command { collstats: "mycollectiont" }

Here is the hive query :

CREATE EXTERNAL TABLE uploadresult ( id STRING , confirmationCode STRING , dateCreated STRING , failedMessages STRING , fileName STRING , reportingPeriod STRING , status STRING , user_id STRING , contract_id STRING ) STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler' WITH SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id","confirmationCode":"confirmationCode", "dateCreated":"dateCreated", "failedMessages":"failedMessages", "fileName":"fileName", "reportingPeriod":"reportingPeriod", "status":"status","user_id":"user_id","contract_id":"contract_id"}') TBLPROPERTIES( 'mongo.uri' = 'mongodb://<host>:27017/mydb.uploadresult', 'mongo.input.uri' = 'mongodb://user:pw@<host>:27017/mydb.uploadresult' );

4 REPLIES 4

Re: Hive connection to MongoDB with userid/pw

@Babu Angina

You can please try after removing collection name from "mongo.input.uri" ?

like,

'mongo.input.uri' = 'mongodb://user:pw@<host>:27017/mydb'

Re: Hive connection to MongoDB with userid/pw

New Contributor

Thanks for the quick response. I tried it but still getting the same error.

java.io.IOException: java.io.IOException: java.lang.RuntimeException: Unable to calculate input splits from collection stats: not authorized on tdr to execute command { collstats: "uploadresult" }

Re: Hive connection to MongoDB with userid/pw

New Contributor

Did not worked. Can you please help once

Thanks

Highlighted

Re: Hive connection to MongoDB with userid/pw

New Contributor

,

@Kanav Narula have you found any alternate solution for this.

Don't have an account?
Coming from Hortonworks? Activate your account here