Connection error with mongodb using Rmongo - r

I am running meteor application in a localhost on port 3000 and I can't connect R with my MongoDB. ( I checked this code for MongoDB running on port 27017 without meteor - just pure database and it's working properly). Meteor create an own database which is calling meteor and inside are my collections ( including images in this sample).
library(RMongo)
mongo<- mongoDbConnect("meteor", host="127.0.0.1", port=3000) #error
#mongo<- mongoDbConnect("meteor", host="127.0.0.1", port=27017)# - that's work
output <- dbGetQuery(mongo, 'images', '{}')
print(output)
I have this error:
error in '.jcall(rmongo.object#javaMongo, "S", "dbGetQuery", collection, ':
com.mongodb.MongoException$Network: Read operation to server /127.0.0.1:3000 failed on database meteor
dbGetQuery ... dbGetQueryForKeys -> dbGetQueryForKeys -> .jcall -> .jcheck -> .Call
EDIT:
the same problem with any other R packages like mongolite
No suitable servers found (serverSelectionTryOnce set): [connection closed calling ismaster on 'localhost:3000']

In case that somebody else will have this problem:
type:
meteor mongo -U
to get URL address of your db, and now copy paste to host:""

Related

Airflow SambaHook authentication issue with SpnegoError and Kerberos?

I am trying to connect to a Samba server in Airflow using the SambaHook class. The Samba server requires Kerberos authentication.
I have already defined a Samba connection in Airflow using the following parameters:
Host,Schema and Extra {"auth": "kerberos"}
airflow connections add "samba_repo" --conn-type "samba" --conn-host "myhost.mywork.com" --conn-schema "fld" --conn-extra '{"auth": "kerberos"}'
I'm trying to use the SambaHook class in Airflow to connect to a Samba server. When I run my code, I get the following error:
Failed to authenticate with server: SpnegoError (1): SpnegoError (16): Operation not supported or available, Context: Retrieving NTLM store without NTLM_USER_FILE set to a filepath, Context: Unable to negotiate common mechanism
However, when I use smbclient to connect to the same server using Kerberos authentication from the Docker terminal, it works fine with the command: smbclient //'myhost'/'fld' -c 'ls "\workpath\*" ' -k
What I tried: I set up a connection to the Samba server in Airflow using the SambaHook class and tried to use the listdirmethod to retrieve a list of files in a specific directory.
What I expected to happen: I expected the listdir method to successfully retrieve a list of files in the specified directory from the Samba server.
What actually resulted: Instead, I encountered the following error message:
Failed to authenticate with server: SpnegoError (1): SpnegoError (16): Operation not supported or available, Context: Retrieving NTLM store without NTLM_USER_FILE set to a filepath, Context: Unable to negotiate common mechanism

How to connect PostgreSQL installed on ubuntu using R

I have installed the Ubuntu postgreSQL very quickly, using the following command,
$sudo apt install postgresql postgresql-contrib
And I login into the database using he following command,
$sudo -i -u postgres
$psql
Then I create the table and index of my database in it. I can see that the database is correctly imported, and have index created, and the database is ready to go.
But the problem is in the R program, I use the library(RPostgreSQL) to connect to the database, I have filled the connection details as follows,
connection <- dbConnect(driver, dbname='testchr22', host='localhost', port=5432, user= 'postgres', password='')
But all the connection failed.
But my problem is the database connection always have problems, I didn’t set up the password, I don’t know what password should include.
I have always encounter the following errors, forever, and don't know where I got it wrong.
Error in postgresqlNewConnection(drv, ...) : RS-DBI driver: ()
Calls: batchAnnotate -> dbConnect -> dbConnect -> postgresqlNewConnection
Execution halted

Kafakacomsumer for R fetching

I am working on kafka . I have created kafka producer on my server . I want to get data from kafkaproducer to my local system in r.
I have tried following code in R:
library(rkafka)
consumer1<-rkafka.createConsumer("ipaddress:9092","mytest")
consumer11 <- rkafka.read(consumer1)
It throws following error:
[1] "Java-Object{com.musigma.consumer.MuConsumer#3349e9bb}"
Unable to connect to zookeeper server
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within
timeout: 100000
at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:880)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84)
at kafka.consumer.ZookeeperConsumerConnector.connectZk(ZookeeperConsumerConnector.scala:156)
at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:114)
at kafka.javaapi.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:65)
at kafka.javaapi.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:67)
at kafka.consumer.Consumer$.createJavaConsumerConnector(ConsumerConnector.scala:100)
at kafka.consumer.Consumer.createJavaConsumerConnector(ConsumerConnector.scala)
at com.musigma.consumer.MuConsumer.CreateConsumer(MuConsumer.java:99)
java.lang.NullPointerException
at com.musigma.consumer.MuConsumer.startConsumer(MuConsumer.java:133)
My zookeeper is running on the ipaddress successfully.
The first parameter is Zookeeper, which runs on port 2181
You've given it Kafka port
Source - https://github.com/cran/rkafkajars/blob/master/java/com/musigma/consumer/MuConsumer.java#L87
Note: Looks like that library isn't maintained and using Zookeeper to connect with a consumer is practically deprecated, so maybe try finding another library

How to setup AWS KMS on Airflow?

Can you please advice if Airflow supports AWS KMS server side encryption? If yes, is there any documentation on how to setup? I am using Airflow 1.9.0 version.
I tried with creating s3 connection with extra args like -
{"aws_access_key_id":"xx", "aws_secret_access_key": "xx", "sse": "aws:kms", "sse-kms-key-id": "xx"}
and used s3 hook to upload a file in the code but it is throwing this error -
an error occurred (accessdenied) when calling the createmultipartupload operation access denied
Where as s3 cp from command line did work!
aws s3 cp test.txt s3://xxx/xx/test.txt --sse aws:kms --sse-kms-key-id "xx"
upload: ./test.txt to s3://xxx/xx/test.txt
thanks in advance.

Connect to MySQL database with RMySQL

I am making the move from RSQLite to RMySQL and I am confused by the user and password fields. FWIW, I'm running Windows 7, R 2.12.2, MySQL 5.5 (all 64 bit), and RMySQL 0.7-5.
I installed RMySQL as prescribed in this previous SO question, and as far as I know it works (i.e., I can load the package with library(RMySQL)). But when I try to run the tutorial from the R data import guide, I get a "failed to connect to database..." error. This is the code from the tutorial from the guide:
library(RMySQL) # will load DBI as well
## open a connection to a MySQL database
con <- dbConnect(dbDriver("MySQL"), user = "root", password = "root", dbname = "pookas")
## list the tables in the database
dbListTables(con)
## load a data frame into the database, deleting any existing copy
data(USArrests)
dbWriteTable(con, "arrests", USArrests, overwrite = TRUE)
dbListTables(con)
## get the whole table
dbReadTable(con, "arrests")
## Select from the loaded table
dbGetQuery(con, paste("select row_names, Murder from arrests",
"where Rape > 30 order by Murder"))
dbRemoveTable(con, "arrests")
dbDisconnect(con)
On the second line I get the following error:
> con <- dbConnect(dbDriver("MySQL"), user = "richard", password = "root", dbname = "pookas")
Error in mysqlNewConnection(drv, ...) :
RS-DBI driver: (Failed to connect to database: Error: Access denied for user 'richard'#'localhost' (using password: NO)
)
I have tried with and without user and password and with admin as user. I have also tried using a dbname that I made before with the command line and with one that doesn't exist.
Any tips? Is there a good reference here? Thanks!
That is most likely a setup issue on the server side. Make sure that networked access is enabled.
Also, a local test with the command-line client is not equivalent as that typically uses sockets. The mysql server logs may be helpful.
First try to connect to MySQL server using MySQL Workbench or command line mysql using the same parameter. If it connects then R should also be able to connect.
Typically this issue comes when MySQL server doesn't allow connections from remote machines.
As people have told you, you can try to connect to the host with other application as mysql workbench. How odd! When I have tried in RStudio to connect to my db with your code without indicate the host in the command I haven't been able to connect.
I have needed to indicate the host ( host = 'localhost' ) in the command.

Resources