mongo_fdw icon indicating copy to clipboard operation
mongo_fdw copied to clipboard

Connection Error

Open krisnamourt opened this issue 3 years ago • 6 comments

I'm trying to build a docker image with this data wrapper

from postgres:13.2

RUN apt -y update &&  apt -y upgrade
RUN apt-get install -y python python-pip
RUN apt-get install -y postgresql-11-python-multicorn 
RUN apt-get install -y build-essential libcurl4-openssl-dev libpq-dev pkg-config wget
RUN apt-get install -y git cmake make gcc libzstd-dev libssl-dev libsasl2-dev
RUN apt-get install -y python-setuptools
#RUN git clone https://github.com/asya999/yam_fdw.git && cd yam_fdw && python setup.py install
RUN apt-get install -y libmongoc-dev  libbson-dev 
RUN apt install -y postgresql-server-dev-13
RUN git clone https://github.com/EnterpriseDB/mongo_fdw.git --recursive && cd mongo_fdw && sed -i "s|cmake3|cmake|" autogen.sh && ./autogen.sh --with-master && make -f Makefile.meta && make -f Makefile.meta install

Everythins goes fine, and I also able to create the extension, the foreign server and table but when I try to query I got this error

Hint: Mongo error: "Authentication failed."

I'm trying to access another docker container locally

docker run --rm --name some-mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret -d mongo:3.0.15

I tryed by IP 172.17.0.1 and got the Authentication failed

When I tried localhost I got

Hint: Mongo error: "No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster on 'localhost:27017']"

and when I tried mongodb+srv://172.17.0.1 I got a new error

Hint: Mongo driver connection error.

I don't know if I missed some configuration or not or if postgres 13 has no support

krisnamourt avatar Apr 04 '21 15:04 krisnamourt

Thanks @krisnamourt for reporting an issue.

The Mongo fdw supports Postgres 13.

Hint: Mongo error: "Authentication failed." You may get authentication failure due to wrong username and/or password. Please confirm whether you are using 'username' and 'password' options while creating user mapping?. If so then please re-verify once. To investigate this failure further, MongoDB logs may help. Those are located at '/var/log/mongodb/mongod.log' in CentOS. If possible, please share with us.

Hint: Mongo error: "No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster on 'localhost:27017']" The error message suggests that the driver can’t connect to a MongoDB instance locally, indicating that it isn’t running or isn’t accepting any connections. Please confirm that you can connect to that address via another method (e.g. mongo shell) and retry. You can use following command to connect to mongo shell: mongo localhost:27017

Hint: Mongo driver connection error. This is not the correct way to provide the address. If we give any address with this format then it results into this error.

Also, check if MongoDB is running on mentioned address(172.17.0.1) as well. Kindly, make sure bindIp in mongod.conf is correctly added.

Please let us know the version of MongoDB server.

vaibhavdalvi93 avatar Apr 05 '21 09:04 vaibhavdalvi93

Ok, I'm trying to access another container in my manchine docker run --rm --name some-mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret -d mongo:3.0.15

I was able to access this mongodb from the shell but not from the postgres

krisnamourt avatar Apr 05 '21 22:04 krisnamourt

I'm trying to build a docker image with this data wrapper

from postgres:13.2

RUN apt -y update &&  apt -y upgrade
RUN apt-get install -y python python-pip
RUN apt-get install -y postgresql-11-python-multicorn 
RUN apt-get install -y build-essential libcurl4-openssl-dev libpq-dev pkg-config wget
RUN apt-get install -y git cmake make gcc libzstd-dev libssl-dev libsasl2-dev
RUN apt-get install -y python-setuptools
#RUN git clone https://github.com/asya999/yam_fdw.git && cd yam_fdw && python setup.py install
RUN apt-get install -y libmongoc-dev  libbson-dev 
RUN apt install -y postgresql-server-dev-13
RUN git clone https://github.com/EnterpriseDB/mongo_fdw.git --recursive && cd mongo_fdw && sed -i "s|cmake3|cmake|" autogen.sh && ./autogen.sh --with-master && make -f Makefile.meta && make -f Makefile.meta install

Everythins goes fine, and I also able to create the extension, the foreign server and table but when I try to query I got this error

Hint: Mongo error: "Authentication failed."

I'm trying to access another docker container locally

docker run --rm --name some-mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret -d mongo:3.0.15

I tryed by IP 172.17.0.1 and got the Authentication failed

When I tried localhost I got

Hint: Mongo error: "No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster on 'localhost:27017']"

and when I tried mongodb+srv://172.17.0.1 I got a new error

Hint: Mongo driver connection error.

I don't know if I missed some configuration or not or if postgres 13 has no support

I am not able to build the image in the above mentioned DockerFile and getting the following error

Done
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC --std=c99 -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -Ijson-c -DMETA_DRIVER -I. -I./ -I/usr/include/postgresql/11/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/mit-krb5  -c -o connection.o connection.c
connection.c:15:10: fatal error: postgres.h: No such file or directory
 #include "postgres.h"
          ^~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: connection.o] Error 1
The command '/bin/sh -c git clone https://github.com/EnterpriseDB/mongo_fdw.git --recursive && cd mongo_fdw && sed -i "s|cmake3|cmake|" autogen.sh && ./autogen.sh --with-master && make -f Makefile.meta && make -f Makefile.meta install' returned a non-zero code: 2
[root@kashif-hadoop-hive-image-centos7 mongo_146]# 

can you please check if any thing is missing in the Dockerfile commands.


from postgres:13.2

RUN apt -y update &&  apt -y upgrade
RUN apt-get install -y python python-pip
RUN apt-get install -y postgresql-11-python-multicorn 
RUN apt-get install -y build-essential libcurl4-openssl-dev libpq-dev pkg-config wget
RUN apt-get install -y git cmake make gcc libzstd-dev libssl-dev libsasl2-dev
RUN apt-get install -y python-setuptools
#RUN git clone https://github.com/asya999/yam_fdw.git && cd yam_fdw && python setup.py install
RUN apt-get install -y libmongoc-dev  libbson-dev 
RUN apt install -y postgresql-server-dev-13
RUN git clone https://github.com/EnterpriseDB/mongo_fdw.git --recursive && cd mongo_fdw && sed -i "s|cmake3|cmake|" autogen.sh && ./autogen.sh --with-master && make -f Makefile.meta && make -f Makefile.meta install

kashifzeeshan avatar Apr 07 '21 07:04 kashifzeeshan

Hi man, I made some Dockerfile version the last one build ok to me, but there's this other version too

from postgres:13.2

RUN apt -y update &&  apt -y upgrade
RUN apt-get install -y python python-pip
RUN apt-get install -y postgresql-11-python-multicorn 
RUN apt-get install -y build-essential libcurl4-openssl-dev libpq-dev pkg-config wget
RUN apt-get install -y git cmake make gcc libzstd-dev libssl-dev libsasl2-dev
RUN apt-get install -y python-setuptools
RUN apt-get install -y libmongoc-dev  libbson-dev 
RUN apt install -y postgresql-server-dev-13
RUN wget https://github.com/mongodb/mongo-c-driver/releases/download/1.17.0/mongo-c-driver-1.17.0.tar.gz && tar xzf mongo-c-driver-1.17.0.tar.gz && cd mongo-c-driver-1.17.0 && mkdir cmake-build && cd cmake-build && cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
RUN git clone https://github.com/EnterpriseDB/mongo_fdw.git ss&& cd mongo_fdw && sed -i "s|cmake3|cmake|" autogen.sh && ./autogen.sh --with-master && make -f Makefile.meta && make -f Makefile.meta install

Also build successfully, same erro when I try to configure mongo_fdw

krisnamourt avatar Apr 08 '21 23:04 krisnamourt

Hey man, using a docker-compose I was able to get an error message

mongo_1    | 2021-04-11T15:08:25.821+0000 I ACCESS   [conn3] SCRAM-SHA-1 authentication failed for mongoadmin on db from client 172.19.0.1 ; UserNotFound Could not find user mongoadmin@db
mongo_1    | 2021-04-11T15:08:25.822+0000 I NETWORK  [conn3] end connection 172.19.0.1:46002 (1 connection now open)

I have to chance the ecnrypt key?

krisnamourt avatar Apr 11 '21 15:04 krisnamourt

Well, I don't know why but if I use another user different from super user works.

krisnamourt avatar Apr 11 '21 15:04 krisnamourt