EnterpriseDB / mongo_fdw

PostgreSQL foreign data wrapper for MongoDB
GNU Lesser General Public License v3.0
326 stars 70 forks source link

Why can't the query in postgresql? #76

Closed dazuiba008 closed 6 years ago

dazuiba008 commented 7 years ago

hank=# CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address '127.0.0.1', port '5888'); CREATE SERVER hank=# CREATE USER MAPPING FOR postgres SERVER mongo_server OPTIONS (username 'test', password 'test'); CREATE USER MAPPING hank=# CREATE FOREIGN TABLE tb1 hank-# (name text) hank-# SERVER mongo_server hank-# OPTIONS (database 'test', collection 'tb1'); CREATE FOREIGN TABLE hank=# select * from tb1; ERROR: could not connect to 127.0.0.1:5888 HINT: Mongo driver connection error:

ahsanhadi commented 7 years ago

Are you running mongodb on local host with 5888 port? The default mode for mongodb is 27017.

On Thu, Mar 2, 2017 at 8:25 AM, dazuiba008 notifications@github.com wrote:

hank=# CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address '127.0.0.1', port '5888'); CREATE SERVER hank=# CREATE USER MAPPING FOR postgres SERVER mongo_server OPTIONS (username 'test', password 'test'); CREATE USER MAPPING hank=# CREATE FOREIGN TABLE tb1 hank-# (name text) hank-# SERVER mongo_server hank-# OPTIONS (database 'test', collection 'tb1'); CREATE FOREIGN TABLE hank=# select * from tb1; ERROR: could not connect to 127.0.0.1:5888 HINT: Mongo driver connection error:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/EnterpriseDB/mongo_fdw/issues/76, or mute the thread https://github.com/notifications/unsubscribe-auth/AHmqpIOXlXZDlx6HWNrUXf_oUpHfZwcmks5rhja5gaJpZM4MQgMQ .

-- Ahsan Hadi Snr Director Product Development EnterpriseDB Corporation The Enterprise Postgres Company

Phone: +92-51-8358874 Mobile: +92-333-5162114

Website: www.enterprisedb.com EnterpriseDB Blog: http://blogs.enterprisedb.com/ Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient or authorized to receive this for the intended recipient, any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete this message.

dazuiba008 commented 7 years ago

yes,the config file dbpath = /data01/shard/config port = 5888 logpath = /data01/mongodb_log/mongodb_5888.log logappend = true fork = true noauth = true nounixsocket = true directoryperdb = true journal = true journalCommitInterval = 40 profile = 0 nohttpinterface = true nssize = 1000 oplogSize = 1024 storageEngine = wiredTiger wiredTigerJournalCompressor = none

Connect is normal

mongo@db-192-168-101-115-> mongo 127.0.0.1:5888/test MongoDB shell version: 3.2.8 connecting to: 127.0.0.1:5888/test hank:PRIMARY>

ahsanhadi commented 7 years ago

Which version of mongodb are you using? Also are you using the mongodb fdw from the following location and following the build and usage instructions...

https://github.com/EnterpriseDB/mongo_fdw

On Fri, Mar 3, 2017 at 7:44 AM, dazuiba008 notifications@github.com wrote:

yes,the config file dbpath = /data01/shard/config port = 5888 logpath = /data01/mongodb_log/mongodb_5888.log logappend = true fork = true noauth = true nounixsocket = true directoryperdb = true journal = true journalCommitInterval = 40 profile = 0 nohttpinterface = true nssize = 1000 oplogSize = 1024 storageEngine = wiredTiger wiredTigerJournalCompressor = none

Connect is normal

mongo@db-192-168-101-115-> mongo 127.0.0.1:5888/test MongoDB shell version: 3.2.8 connecting to: 127.0.0.1:5888/test hank:PRIMARY>

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EnterpriseDB/mongo_fdw/issues/76#issuecomment-283849705, or mute the thread https://github.com/notifications/unsubscribe-auth/AHmqpNbOLzECAGt3wpR3042UoOkGm1uZks5rh36ogaJpZM4MQgMQ .

-- Ahsan Hadi Snr Director Product Development EnterpriseDB Corporation The Enterprise Postgres Company

Phone: +92-51-8358874 Mobile: +92-333-5162114

Website: www.enterprisedb.com EnterpriseDB Blog: http://blogs.enterprisedb.com/ Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient or authorized to receive this for the intended recipient, any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete this message.

gabbasb commented 7 years ago

Since you are using noauth=true, your user mapping should be without any options, like this CREATE USER MAPPING FOR postgres SERVER mongo_server; and it should work. Also make sure that this command sudo netstat -tulpn | grep :5888 gives a result similar to tcp 0 0 127.0.0.1:5888 0.0.0.0:* LISTEN 81356/mongod

ahsanhadi commented 7 years ago

Can i close the issue if the given suggestions worked for you?