Discussion:
[mongodb-user] Mongo connection problems
Bruce Malmat
2016-06-23 13:30:28 UTC
Permalink
I have a Mongo instance running in a docker container on an Amazon-hosted
server.
I need to connect to it with either RoboMongo or MongoChef for exploration,
and with command-line for automated extractions.

To get to the server from my laptop (Win 7 with Cygwin/bash), I create an
ssh tunnel:
ssh -i ~/.ssh/MY-PEM-FILE MY-***@MY-SERVER -L 27017:localhost:27017

With *MongoChef* I connect as "Direct Connection" to localhost on port
27017. The connection succeeds and I see:
- Tunnel to mongo 27017 localhost:27017
- local
+ startup_log
- sg_mage
+ catalog_product_entity
- __id__
I run IntelliShell and I get this in the main window:
2016-06-23T09:00:46.055-0400 I CONTROL [main] \
Hotfix KB2731284 or later update is not installed, will zero-out data
files
MongoDB shell version: 3.2.4
connecting to: localhost:27017/local
2016-06-23T09:00:46.187-0400 E QUERY [thread1] \
Error: network error while attempting to run command 'whatsmyuri' on
host 'localhost:27017' :
***@src/mongo/shell/mongo.js:226:14
@(shell):1:6
Connected: you can now execute commands from the editor above.
I then run the query db.catalog_product_entity.find({}).limit(1) but the
scrollbar pumps forever, returning no results.

I can right-click the sg_mage collection and choose Export Collections ...
and I can export the full 1.9 million items to json!
That's not really what I need ... but it demonstrates that I can "see" the
data by that method.
I truly am connected, albeit with limited functionality. Export, yes.
Query, no. :(

Moving to *RoboMongo* ... same tunnel connection ... I see this:
- Tunnel to mongo 27017 (2)
+ System
- sg_mage
Collections (0)
Functions (0)
Users (0)
No collections at all ! But ... when I query with
db.catalog_product_entity.find({}).limit(1) I do get data:
- (1) 1 { 4 fields }
_id 1
- attr_0 { 21 fields }
entity_id 1
entity_type_id 4
attribute_set_id 4
type_id simple
etc ... etc ...
- category_ids Array [1]
0 4
- galleries { 1 fields }
media_gallery Array [0]
attr_1_url_path portugal.html
So I *cannot* point and click through the items in the left-hand bar, but I
can query the data in the main window.
This is "good enough" for investigative / ad-hoc work.

For automated extracts I want to use command-line mongo. I have that
installed on my laptop (Win 7 with Cygwin bash).
I run this:
echo "use sg_mage;
db.catalog_product_entity.find({}).limit(1)" | "C:/Program
Files/MongoDB/Server/3.2/bin/mongo.exe"
and I get this:
MongoDB shell version: 3.2.7
connecting to: 127.0.0.1:27017/test
2016-06-23T14:16:13.100+0100 E QUERY [thread1] \
Error: network error while attempting to run command 'whatsmyuri' on
host '127.0.0.1:27017' :
***@src/mongo/shell/mongo.js:231:14
@(connect):1:6
exception: connect failed
No joy. I really need to get this working.
Advice???
--
This email is sent for and on behalf of Stanley Gibbons PLC.

*Confidentiality:* This e-mail contains proprietary information, some or
all of which may be confidential and/or legally privileged. It is for the
intended recipient only. If an addressing or transmission error has
misdirected this e-mail, please notify the author by replying to this
e-mail and then delete the original. If you are not the intended recipient
you may not use, disclose, distribute, copy, print or rely on any
information contained in this e-mail. You must not inform any other person
other than Stanley Gibbons PLC or the sender of its existence.

For more information about Stanley Gibbons PLC please visit
www.stanleygibbons.com
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/ccbbfffd-f736-4173-9113-4489ae737c13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Stephen Steneker
2016-06-23 21:16:25 UTC
Permalink
Post by Bruce Malmat
I have a Mongo instance running in a docker container on an Amazon-hosted
server.
I need to connect to it with either RoboMongo or MongoChef for
exploration, and with command-line for automated extractions.
Hi Bruce,

Robomongo and MongoChef are both third party tools supported by their
developers; I would suggest contacting them directly for feature support.

What specific version of MongoDB server are you connecting to? You should
be able to establish a connection using the same version of the mongo shell
on your local machine in order to confirm your port forwarding is set up
correctly.
Post by Bruce Malmat
- Tunnel to mongo 27017 (2)
+ System
- sg_mage
Collections (0)
Functions (0)
Users (0)
No collections at all !
You haven't mentioned the specific versions you are using, but for MongoDB
3.0+ compatibility you need to be using Robomongo 0.9 or later. The
symptoms you've described (can't see collections but can retrieve results
via a find query) are commonly the result of using older tools or drivers
that have not been updated to support MongoDB 3.0+.


For automated extracts I want to use command-line mongo. I have that
Post by Bruce Malmat
installed on my laptop (Win 7 with Cygwin bash).
echo "use sg_mage;
db.catalog_product_entity.find({}).limit(1)" | "C:/Program
Files/MongoDB/Server/3.2/bin/mongo.exe"
For extracts from a single collection in JSON or CSV format, I would
suggest using the mongoexport
<https://docs.mongodb.com/manual/reference/program/mongoexport/> command
line utility instead. The equivalent of your query would be something like:

mongoexport --db sg_mage --collection catalog_product_entity --query
'{}' --limit 1

If you do want to run JavaScript from the command-line using the mongo
shell, instead of piping to the shell I would save your JavaScript in a
text file and pass this as a command-line option (eg: "mongo myscript.js").
There are syntax differences in an interactive vs scripted mongo shell
session; see Write Scripts for the mongo Shell
<https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/> for
more details and examples.

Regards,
Stephen
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/03a75345-b3e7-4d1f-b5f1-1d202fb52250%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Bruce Malmat
2016-06-24 16:38:54 UTC
Permalink
Thank you for the reply.

I fixed my problem by taking a copy of the "mongo" command-line tool (and
also the "mongoexport" tool) from another server.
I saved those executables on the server in question.
Now "mongo" works ... I just ssh from the laptop to the server and run
"mongo".
And thanks for turning me on to "mongoexport". It is, indeed, a better
solution for what I need to do. Thanks.

I took heed of your comment about RoboMongo. I was using 0.8.5. So I
installed the 0.9 version as you suggested.
I have an open ssh tunnel ... which allowed the old RoboMongo to see the
Mongo store (with limited functionality).
With that same tunnel, the new 0.9 RoboMongo crashes. Nothing more.
So I'm back to the old 0.8.5. I can live with the limited functionality.
I have only one object in this Mongo instance, and I know the structure. So
it's good enough that it allows me to just run queries.
--
This email is sent for and on behalf of Stanley Gibbons PLC.

*Confidentiality:* This e-mail contains proprietary information, some or
all of which may be confidential and/or legally privileged. It is for the
intended recipient only. If an addressing or transmission error has
misdirected this e-mail, please notify the author by replying to this
e-mail and then delete the original. If you are not the intended recipient
you may not use, disclose, distribute, copy, print or rely on any
information contained in this e-mail. You must not inform any other person
other than Stanley Gibbons PLC or the sender of its existence.

For more information about Stanley Gibbons PLC please visit
www.stanleygibbons.com
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/f46b322e-e100-42ba-af01-34c364be60b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...