Mongodb index built failed - mongodb

I have a MongoDB with around 80k documents, each one is an entry with title, body_text, etc. I want to do FullTextSearch, for which reason I created a text index with the command:
db.getCollection('arquivo_entry').createIndex({title:"text",body_text:"text"},{ weights:{title:2,body_text:1}},{default_language:"portuguese"})
The index building failed because of it ran out of memory and it killed the job that had mongodb running. This is in the log:
2018-03-22T14:58:12.017+0000 I - [initandlisten] Index Build: 2500/86187 2%
2018-03-22T14:58:15.028+0000 I - [initandlisten] Index Build: 6900/86187 8%
2018-03-22T14:58:18.012+0000 I - [initandlisten] Index Build: 12400/86187 14%
2018-03-22T14:58:21.065+0000 I - [initandlisten] Index Build: 17300/86187 20%
2018-03-22T14:58:24.047+0000 I - [initandlisten] Index Build: 22500/86187 26%
2018-03-22T14:58:27.043+0000 I - [initandlisten] Index Build: 28600/86187 33%
2018-03-22T14:58:30.013+0000 I - [initandlisten] Index Build: 34000/86187 39%
2018-03-22T14:58:32.478+0000 F - [initandlisten] out of memory.
And the problem now is that I'm not able to delete the index and each time I try to launch the database it starts to rebuild the index automatically. Additionally, I'm not able to start a mongodb shell. It gives me the following error:
MongoDB shell version v3.6.3 connecting to: mongodb://127.0.0.1:27017
2018-03-22T15:08:38.688+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-03-22T15:08:38.688+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13 #(connect):1:6
exception: connect failed

You can start the database with --noIndexBuildRetry option, drop the text index, and restart the database as usual.

Related

MongoDB installed correctly using Homebrew on Mac but typing "mongo" on the command line gives error: "exception: connect failed"

Mongo wont start on Mac.
Typed: "brew tap mongodb/brew" everything worked fine
Typed: "brew install mongodb-community#4.0" everything worked fine.
Typedy: "brew services start mongodb-community#4.0" everything worked fine.
When i type: "mongo"
I get the following error:
MongoDB shell version v4.0.9
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2019-05-14T17:06:06.551-0400 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:343:13
#(connect):2:6
exception: connect failed
When I type: "mongodb" I get the following error at the end of attempting to start:
2019-05-14T17:05:59.227-0400 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-05-14T17:05:59.228-0400 I CONTROL [initandlisten] now exiting
2019-05-14T17:05:59.228-0400 I CONTROL [initandlisten] shutting down with code:62
Any ideas are appreciated.
Thank you,

Cannot connect with MongoDB

I have problems with connecting with mongo.
me#the_host:~$ mongo
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-06-28T17:06:37.445+0200 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
I went to /var/log/mongodb/mongod.log to see:
2018-06-28T17:16:11.763+0200 I COMMAND [initandlisten] Assigning UUID b237b94b-b3a3-4ba1-9c39-c87d6f3555db to collection local.startup_log
2018-06-28T17:16:11.764+0200 F STORAGE [initandlisten] Unable to start up mongod due to missing featureCompatibilityVersion document.
2018-06-28T17:16:11.764+0200 F STORAGE [initandlisten] Please run with --journalOptions 4 to recover the journal. Then run with --repair to restore the document.
2018-06-28T17:16:11.764+0200 F - [initandlisten] Fatal Assertion 40652 at src/mongo/db/repair_database_and_check_version.cpp 555
2018-06-28T17:16:11.764+0200 F - [initandlisten]
I executed mongod --journalOptions 4 and then mongod --repair but the error is still the same.
I have no idea what to do next..
Could anybody, who overcame this before, point me to proper direction?

Using Mongo-cli to connect to an OpenShift database

I'm trying to connect to a database created onto OpenShift from a cartridge and I'm having issues connecting through it using Mongo client from shell.
I'm using Mac OS Sierra as a client and my Mongo project is hosted onto MiniShift. I can connect locally using OpenShift shell :
mongo sampledb --host localhost -u user -p password
But when I try to connect from MacOS directly :
mongo sampledb --host devmongo-mongo01.192.168.99.100.nip.io -u user -p password
I got this error stack with verbose mode activated:
2017-08-17T18:10:41.938+0200 D NETWORK [thread1] creating new connection to:devmongo-mongo01.192.168.99.100.nip.io:27017
2017-08-17T18:10:41.941+0200 W NETWORK [thread1] Failed to connect to 192.168.99.100:27017, in(checking socket for error after poll), reason: Connection refused
2017-08-17T18:10:41.941+0200 D - [thread1] User Assertion: 1:couldn't connect to server devmongo-mongo01.192.168.99.100.nip.io:27017, connection attempt failed src/mongo/scripting/mozjs/mongo.cpp 716
2017-08-17T18:10:41.941+0200 E QUERY [thread1] Error: couldn't connect to server devmongo-mongo01.192.168.99.100.nip.io:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
2017-08-17T18:10:41.941+0200 D - [thread1] User Assertion: 12513:connect failed src/mongo/shell/shell_utils.cpp 256
2017-08-17T18:10:41.941+0200 I QUERY [thread1] MozJS GC prologue heap stats - total: 3498847 limit: 0
2017-08-17T18:10:41.943+0200 I QUERY [thread1] MozJS GC epilogue heap stats - total: 350087 limit: 0
2017-08-17T18:10:41.943+0200 I QUERY [thread1] MozJS GC prologue heap stats - total: 241791 limit: 0
2017-08-17T18:10:41.944+0200 I QUERY [thread1] MozJS GC epilogue heap stats - total: 50423 limit: 0
2017-08-17T18:10:41.944+0200 D - [main] User Assertion: 12513:connect failed src/mongo/scripting/mozjs/proxyscope.cpp 295
exception: connect failed
I realized that it was not possible to edit "bind_ip" after deployment of MongoDB on OpenShift (so not possible to access MongoDB via a tool such a Robomongo). So my solution to use a Mongo Database in an OpenShift project, was to embed the projects that use the DB in same project and using connection String with service to identify the Database container instead of IP because if container is restarted, the IP can be changed but the service will remain the same.

Unable to connect to mongodb in docker container

Getting connection refused when trying to connect to MongoDb in Docker container.
Here's the output of docker ps:
docker ps CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES 21063296d7d8 mongo "/entrypoint.sh mongo"
44 minutes ago Up 29 minutes 0.0.0.0:57017->27017/tcp
mongodb-dev
Here's the snippet of docker logs mongodb-dev:
2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] db version
v3.0.7 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] git
version: 6ce7cbe8c6b899552dadd907604559806aa2e9bd
2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] build info:
Linux ip-10-183-78-195 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64
BOOST_LIB_VERSION=1_49 2015-11-28T05:36:36.363+0000 I CONTROL
[initandlisten] allocator: tcmalloc 2015-11-28T05:36:36.363+0000 I
CONTROL [initandlisten] options: {} 2015-11-28T05:36:36.365+0000 I
NETWORK [initandlisten] waiting for connections on port 27017
Here's the error when connecting to MongoDB in docker using port 57017
mongo localhost:57017
MongoDB shell version: 3.0.7 connecting to: localhost:57017/test
2015-11-27T22:09:22.733-0800 W NETWORK Failed to connect to
127.0.0.1:57017, reason: errno:61 Connection refused 2015-11-27T22:09:22.734-0800 E QUERY Error: couldn't connect to
server localhost:57017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181 exception: connect failed
Please let me know what I'm missing here. Thank you for your help!
It depends if you are using docker directly on a Linux host or on a Mac.
In the latter case, you would need to make sure you have port forwarded 57017 in your VirtualBox connection settings, as I mention in "How to connect mysql workbench to running mysql inside docker?"
VBoxManage controlvm "boot2docker-vm" --natpf1 "tcp-port57017 ,tcp,,57017,,57017"
VBoxManage controlvm "boot2docker-vm" --natpf1 "udp-port57017 ,udp,,57017,,57017"

MongoDB Issues on Yosemite

I typed in two commands, mongo and mongod and get the following results. Not sure how to fix this
mahtabalam$ mongo
MongoDB shell version: 3.0.6
connecting to: test
2015-09-19T18:59:35.315-0400 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-09-19T18:59:35.316-0400 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
mahtabalam$ mongod
2015-09-19T19:00:47.133-0400 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:13 Permission denied
2015-09-19T19:00:47.134-0400 I - [initandlisten] Fatal Assertion 28578
2015-09-19T19:00:47.134-0400 I - [initandlisten]
***aborting after fassert() failure
Update 1:
After trying sudo mongod --dbpath="Users/mahtabalam/Sites/mongo/data/db and then pressing ctrl + c on my macbook pro, and then re-entering mongod has yielded the following:
2015-09-19T21:54:49.819-0400 I JOURNAL [initandlisten] journal dir=/data/db/journal
2015-09-19T21:54:49.820-0400 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2015-09-19T21:54:49.836-0400 I JOURNAL [durability] Durability thread started
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten] MongoDB starting : pid=28979 port=27017 dbpath=/data/db 64-bit host=Mahtabs-MacBook-Pro.local
2015-09-19T21:54:49.836-0400 I JOURNAL [journal writer] Journal writer thread started
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten]
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] db version v3.0.6
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] git version: nogitversion
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] allocator: system
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] options: {}
2015-09-19T21:54:49.850-0400 I NETWORK [initandlisten] waiting for connections on port 27017
mongod command starts the DB server & it expects an argument dbpath so the full command would be sudo mongod --dbath="dblocation/data/db" where /data/db is mandatory to start the server.
Whereas mongo opens a mongo db shell where you can execute your db statements