Setup external mongo on own server, what do I need to do as first setup?


#1

hi all,

Lets say I want to run my own mongo via a docker image and also node separately. Do I then need to do some initial stuff like create a database or something like that? I dont see people doing it… (I know that if I use compose.io it is done automatically).

Example: https://blog.giantswarm.io/deploy-meteor-application-in-1-minute/

I see my mongo is running, but I get an error.

https://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html#mongoclient-connect

Pattern is mongodb://{hostname}:{port}/{dbname}

So, I first have to create a database?

I get this error

Error: invalid schema, expected mongodb
W20161007-21:03:25.608(2)? (STDERR)     at module.exports (C:\Users\mbj\AppData\Local\.meteor\packages\npm-mongo\1.5.48\npm\node_modules\mongodb\lib\url_parser.js:20:11)
W20161007-21:03:25.610(2)? (STDERR)     at connect (C:\Users\mbj\AppData\Local\.meteor\packages\npm-mongo\1.5.48\npm\node_modules\mongodb\lib\mongo_client.js:290:16)
W20161007-21:03:25.612(2)? (STDERR)     at Function.MongoClient.connect (C:\Users\mbj\AppData\Local\.meteor\packages\npm-mongo\1.5.48\npm\node_modules\mongodb\lib\mongo_client.js:114:3)
W20161007-21:03:25.614(2)? (STDERR)     at new MongoConnection (meteor://�app/packages/mongo/mongo_driver.js:174:11)
W20161007-21:03:25.621(2)? (STDERR)     at new MongoInternals.RemoteCollectionDriver (meteor://�app/packages/mongo/remote_collection_driver.js:4:16)
W20161007-21:03:25.624(2)? (STDERR)     at Object.<anonymous> (meteor://�app/packages/mongo/remote_

Mongo docker log

2016-10-05T10:06:10.479+0000 I JOURNAL  [initandlisten] journal dir=/data/db/journal
2016-10-05T10:06:10.479+0000 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2016-10-05T10:06:11.567+0000 I JOURNAL  [initandlisten] preallocateIsFaster=true 10.54
2016-10-05T10:06:12.623+0000 I JOURNAL  [initandlisten] preallocateIsFaster=true 7.54
2016-10-05T10:06:14.669+0000 I JOURNAL  [initandlisten] preallocateIsFaster=true 12.46
2016-10-05T10:06:14.669+0000 I JOURNAL  [initandlisten] preallocateIsFaster check took 4.189 secs
2016-10-05T10:06:14.669+0000 I JOURNAL  [initandlisten] preallocating a journal file /data/db/journal/prealloc.0
2016-10-05T10:06:15.465+0000 I JOURNAL  [initandlisten] preallocating a journal file /data/db/journal/prealloc.1
2016-10-05T10:06:16.392+0000 I JOURNAL  [initandlisten] preallocating a journal file /data/db/journal/prealloc.2
2016-10-05T10:06:17.234+0000 I JOURNAL  [durability] Durability thread started
2016-10-05T10:06:17.234+0000 I JOURNAL  [journal writer] Journal writer thread started
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=9f6923447cce
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] 
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] db version v3.0.6
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] build info: Linux ip-10-184-200-117 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-10-05T10:06:17.251+0000 I CONTROL  [initandlisten] options: {}
2016-10-05T10:06:17.263+0000 I INDEX    [initandlisten] allocating new ns file /data/db/local.ns, filling with zeroes...
2016-10-05T10:06:17.298+0000 I STORAGE  [FileAllocator] allocating new datafile /data/db/local.0, filling with zeroes...
2016-10-05T10:06:17.298+0000 I STORAGE  [FileAllocator] creating directory /data/db/_tmp
2016-10-05T10:06:17.331+0000 I STORAGE  [FileAllocator] done allocating datafile /data/db/local.0, size: 64MB,  took 0.012 secs
2016-10-05T10:06:17.346+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-10-05T10:16:02.075+0000 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2016-10-05T10:16:02.075+0000 I CONTROL  [signalProcessingThread] now exiting
2016-10-05T10:16:02.075+0000 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2016-10-05T10:16:02.075+0000 I NETWORK  [signalProcessingThread] closing listening socket: 5
2016-10-05T10:16:02.075+0000 I NETWORK  [signalProcessingThread] closing listening socket: 6
2016-10-05T10:16:02.075+0000 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2016-10-05T10:16:02.075+0000 I NETWORK  [signalProcessingThread] shutdown: going to flush diaglog...
2016-10-05T10:16:02.075+0000 I NETWORK  [signalProcessingThread] shutdown: going to close sockets...
2016-10-05T10:16:02.075+0000 I STORAGE  [signalProcessingThread] shutdown: waiting for fs preallocator...
2016-10-05T10:16:02.075+0000 I STORAGE  [signalProcessingThread] shutdown: final commit...
2016-10-05T10:16:02.088+0000 I JOURNAL  [signalProcessingThread] journalCleanup...
2016-10-05T10:16:02.088+0000 I JOURNAL  [signalProcessingThread] removeJournalFiles
2016-10-05T10:16:02.168+0000 I JOURNAL  [signalProcessingThread] Terminating durability thread ...
2016-10-05T10:16:02.177+0000 I JOURNAL  [journal writer] Journal writer thread stopped
2016-10-05T10:16:02.177+0000 I JOURNAL  [durability] Durability thread stopped
2016-10-05T10:16:02.178+0000 I STORAGE  [signalProcessingThread] shutdown: closing all files...
2016-10-05T10:16:02.178+0000 I STORAGE  [signalProcessingThread] closeAllFiles() finished
2016-10-05T10:16:02.178+0000 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2016-10-05T10:16:02.178+0000 I CONTROL  [signalProcessingThread] dbexit:  rc: 0
2016-10-07T14:40:24.673+0000 I JOURNAL  [initandlisten] journal dir=/data/db/journal
2016-10-07T14:40:24.673+0000 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2016-10-07T14:40:24.703+0000 I JOURNAL  [durability] Durability thread started
2016-10-07T14:40:24.703+0000 I JOURNAL  [journal writer] Journal writer thread started
2016-10-07T14:40:24.720+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=9f6923447cce
2016-10-07T14:40:24.720+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-10-07T14:40:24.720+0000 I CONTROL  [initandlisten] 
2016-10-07T14:40:24.720+0000 I CONTROL  [initandlisten] db version v3.0.6
2016-10-07T14:40:24.721+0000 I CONTROL  [initandlisten] git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2
2016-10-07T14:40:24.721+0000 I CONTROL  [initandlisten] build info: Linux ip-10-184-200-117 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-10-07T14:40:24.721+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-10-07T14:40:24.721+0000 I CONTROL  [initandlisten] options: {}
2016-10-07T14:40:24.779+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-10-07T15:05:48.126+0000 I NETWORK  [initandlisten] connection accepted from 172.17.0.1:56046 #1 (1 connection now open)
2016-10-07T15:05:48.131+0000 I NETWORK  [initandlisten] connection accepted from 172.17.0.1:56048 #2 (2 connections now open)
2016-10-07T15:05:48.243+0000 I NETWORK  [conn1] end connection 172.17.0.1:56046 (1 connection now open)
2016-10-07T15:05:48.472+0000 I NETWORK  [conn2] end connection 172.17.0.1:56048 (0 connections now open)
2016-10-07T16:03:17.820+0000 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2016-10-07T16:03:17.833+0000 I CONTROL  [signalProcessingThread] now exiting
2016-10-07T16:03:17.838+0000 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2016-10-07T16:03:17.863+0000 I NETWORK  [signalProcessingThread] closing listening socket: 5
2016-10-07T16:03:17.863+0000 I NETWORK  [signalProcessingThread] closing listening socket: 6
2016-10-07T16:03:17.864+0000 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2016-10-07T16:03:17.869+0000 I NETWORK  [signalProcessingThread] shutdown: going to flush diaglog...
2016-10-07T16:03:17.869+0000 I NETWORK  [signalProcessingThread] shutdown: going to close sockets...
2016-10-07T16:03:17.876+0000 I STORAGE  [signalProcessingThread] shutdown: waiting for fs preallocator...
2016-10-07T16:03:17.877+0000 I STORAGE  [signalProcessingThread] shutdown: final commit...
2016-10-07T16:03:17.881+0000 I JOURNAL  [signalProcessingThread] journalCleanup...
2016-10-07T16:03:17.881+0000 I JOURNAL  [signalProcessingThread] removeJournalFiles
2016-10-07T16:03:17.900+0000 I JOURNAL  [signalProcessingThread] Terminating durability thread ...
2016-10-07T16:03:17.979+0000 I JOURNAL  [journal writer] Journal writer thread stopped
2016-10-07T16:03:17.984+0000 I JOURNAL  [durability] Durability thread stopped
2016-10-07T16:03:17.984+0000 I STORAGE  [signalProcessingThread] shutdown: closing all files...
2016-10-07T16:03:17.985+0000 I STORAGE  [signalProcessingThread] closeAllFiles() finished
2016-10-07T16:03:17.985+0000 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2016-10-07T16:03:17.985+0000 I CONTROL  [signalProcessingThread] dbexit:  rc: 0
2016-10-07T16:03:59.302+0000 I JOURNAL  [initandlisten] journal dir=/data/db/journal
2016-10-07T16:03:59.302+0000 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2016-10-07T16:03:59.335+0000 I JOURNAL  [durability] Durability thread started
2016-10-07T16:03:59.335+0000 I JOURNAL  [journal writer] Journal writer thread started
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=9f6923447cce
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] 
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] db version v3.0.6
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] build info: Linux ip-10-184-200-117 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-10-07T16:03:59.361+0000 I CONTROL  [initandlisten] options: {}
2016-10-07T16:03:59.377+0000 I NETWORK  [initandlisten] waiting for connections on port 27017

Startup bat file

cd C:\Users\MBJ\Documents\GitHub\QRSMeteor
SET MONGO_URL='mongodb://localhost:27001'
meteor run --settings settings-development.json

Thank you,


#2

I think i have to open the mongo shell and then create the database, but why is this then Not already in Some image?

sudo docker run -it -p 28000:27017 --name mongoContainer mongo:latest mongo And then use shell commands? https://docs.mongodb.com/getting-started/shell/client/


#3

Here is a really solid tutorial on how to deploy a mongo replica set via docker:


#4

Thanks, so to summarize

  • connect to mongo shell
  • create a new database

Use that new database in the mongo URL


#5

It looks like the chicken egg problem. In meteor i have to specify a database path, but mongo says it does not need it…

https://www.mkyong.com/mongodb/how-to-create-database-or-collection-in-mongodb/


#6

Dont tell me… That mongo just creates the database on the fly if you call this url right?