Following is my mongo.conf:
# mongod.conf
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
# bindIp: 127.0.0.1
replication:
replSetName: rs0
oplogSizeMB: 250
I tried to import the data given here on the guest linux using
wget https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/dataset.json
mongoimport --host=127.0.0.1 --port=27017 --db test --collection dataset --file dataset.json
and also tried on the host machine (mac):
mongoimport --host=127.0.0.1 --port=27071 --db test --collection dataset --file dataset.json
In both the cases I get the following output:
2016-02-25T11:01:56.280-0500 connected to: 127.0.0.1:27071
2016-02-25T11:01:59.278-0500 [........................] test.dataset 0.0 B/11.3 MB (0.0%)
2016-02-25T11:01:59.309-0500 [........................] test.dataset 0.0 B/11.3 MB (0.0%)
2016-02-25T11:01:59.309-0500 Failed: error checking connected node type: no reachable servers
2016-02-25T11:01:59.309-0500 imported 0 documents
All the requests that I make to port 27071 on the host system are forwarded to post 27017 on the linux guest. There are no connections issues as curl localhost:27071 gives It looks like you are trying to access MongoDB over HTTP on the native driver port.
UPDATE:
Following is the log of mongo:
2016-02-25T18:33:23.938+0000 I CONTROL ***** SERVER RESTARTED *****
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] MongoDB starting : pid=4810 port=27017 dbpath=/var/lib/mongodb 64-bit host=vagrant-ubuntu-trusty-64
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] db version v3.0.9
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] git version: 20d60d3491908f1ae252fe452300de3978a040c7
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] build info: Linux ip-10-732-9-221 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "0.0.0.0", port: 27017 }, replication: { oplogSizeMB: 250, replSetName: "rs0" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-02-25T18:33:23.969+0000 I JOURNAL [initandlisten] journal dir=/var/lib/mongodb/journal
2016-02-25T18:33:23.969+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2016-02-25T18:33:24.006+0000 I JOURNAL [durability] Durability thread started
2016-02-25T18:33:24.006+0000 I JOURNAL [journal writer] Journal writer thread started
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten]
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten]
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten]
2016-02-25T18:33:24.010+0000 I REPL [initandlisten] Did not find local replica set configuration document at startup; NoMatchingDocument Did not find replica set configuration document in local.system.replset
2016-02-25T18:33:24.011+0000 I NETWORK [initandlisten] waiting for connections on port 27017
If I try to do mongoimport --host=0.0.0.0 --port=27071 --db test --collection dataset --file dataset.json from the host system, following is added to the log:
2016-02-25T18:36:03.443+0000 I NETWORK [initandlisten] connection accepted from 10.0.2.2:51277 #1 (1 connection now open)
2016-02-25T18:36:06.479+0000 I NETWORK [conn1] end connection 10.0.2.2:51277 (0 connections now open)
and when I try this same command from the guest linux, I get:
2016-02-25T18:38:29.982+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:59910 #2 (1 connection now open)
2016-02-25T18:38:32.994+0000 I NETWORK [conn2] end connection 127.0.0.1:59910 (0 connections now open)
Try to chance your bindIp param to 0.0.0.0, and restart the service.
Related
Im using bitnami 3.2.11-0, when I try to start serivce something bad occurs and neither service could be started.
root#ip-172-31-15-96:/home/bitnami/apps/api# sudo service bitnami start
resize2fs 1.42.9 (4-Feb-2014)
The filesystem is already 26212055 blocks long. Nothing to do!
/opt/bitnami/mongodb/scripts/ctl.sh : mongodb could not be started
/opt/bitnami/php/scripts/ctl.sh : php-fpm could not be started
Syntax OK
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
/opt/bitnami/apache2/scripts/ctl.sh : httpd could not be started
/opt/bitnami/var/init/post-start/040_update_ip: 17: /opt/bitnami/var/init/post-start/040_update_ip: /opt/bitnami/apps/*/bnconfig: not found
daemon with PID 1454 awakened
ERROR: child process failed, exited with error number 14
about to fork child process, waiting until server is ready for connections.
forked process: 1559
2017-10-09T21:33:01.815+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] MongoDB starting : pid=1559 port=27017 dbpath=/opt/bitnami/mongodb/data/db 64-bit host=ip-172-31-15-96
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] db version v3.2.11
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] git version: 009580ad490190ba33d1c6253ebd8d91808923e4
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] modules: none
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] build environment:
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] distarch: x86_64
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-10-09T21:33:01.820+0000 I CONTROL [initandlisten] options: { config: "/opt/bitnami/mongodb/mongodb.conf", net: { bindIp: "127.0.0.1", port: 27017, unixDomainSocket: { filePermissions: 502, pathPrefix: "/opt/bitnami/mongodb/tmp" } }$
2017-10-09T21:33:01.842+0000 I - [initandlisten] Detected data files in /opt/bitnami/mongodb/data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-10-09T21:33:01.842+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=sn$
2017-10-09T21:33:02.088+0000 E STORAGE [initandlisten] WiredTiger (1) [1507584782:87985][1559:0x7fb7a2216cc0], file:collection-51-8988087643268075125.wt, WT_SESSION.open_cursor: /opt/bitnami/mongodb/data/db/collection-51-898808764326807$
2017-10-09T21:33:02.088+0000 I - [initandlisten] Invariant failure: ret resulted in status UnknownError: 1: Operation not permitted at src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp 79
2017-10-09T21:33:02.097+0000 I CONTROL [initandlisten]
0x1313f62 0x12be9c8 0x12a6ced 0x10910e4 0x108f9e0 0x108ba02 0x108a40d 0x107afbb 0xfda4b4 0xfe0252 0x1079838 0xf9d4c8 0x96270e 0x964cb0 0x967ebd 0x7fb7a1117f45 0x95f0c9
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"400000","o":"F13F62","s":"_ZN5mongo15printStackTraceERSo"},{"b":"400000","o":"EBE9C8","s":"_ZN5mongo10logContextEPKc"},{"b":"400000","o":"EA6CED","s":"_ZN5mongo17invariantOKFailedEPKcRKNS_6StatusES1_j"},{"b":"400000",$
mongod(_ZN5mongo15printStackTraceERSo+0x32) [0x1313f62]
mongod(_ZN5mongo10logContextEPKc+0x138) [0x12be9c8]
mongod(_ZN5mongo17invariantOKFailedEPKcRKNS_6StatusES1_j+0xAD) [0x12a6ced]
mongod(_ZN5mongo17WiredTigerSession9getCursorERKSsmb+0xE4) [0x10910e4]
mongod(_ZN5mongo16WiredTigerCursorC1ERKSsmbPNS_16OperationContextE+0x50) [0x108f9e0]
mongod(_ZN5mongo21WiredTigerRecordStore6CursorC1EPNS_16OperationContextERKS0_b+0x92) [0x108ba02]
mongod(_ZN5mongo21WiredTigerRecordStoreC1EPNS_16OperationContextENS_10StringDataES3_SsbbllPNS_14CappedCallbackEPNS_20WiredTigerSizeStorerE+0x3ED) [0x108a40d]
mongod(_ZN5mongo18WiredTigerKVEngine14getRecordStoreEPNS_16OperationContextENS_10StringDataES3_RKNS_17CollectionOptionsE+0x1AB) [0x107afbb]
mongod(_ZN5mongo22KVDatabaseCatalogEntry14initCollectionEPNS_16OperationContextERKSsb+0x204) [0xfda4b4]
mongod(_ZN5mongo15KVStorageEngineC1EPNS_8KVEngineERKNS_22KVStorageEngineOptionsE+0x6D2) [0xfe0252]
mongod(+0xC79838) [0x1079838]
mongod(_ZN5mongo20ServiceContextMongoD29initializeGlobalStorageEngineEv+0x598) [0xf9d4c8]
mongod(+0x56270E) [0x96270e]
mongod(_ZN5mongo13initAndListenEi+0x10) [0x964cb0]
mongod(main+0x15D) [0x967ebd]
libc.so.6(__libc_start_main+0xF5) [0x7fb7a1117f45]
mongod(+0x55F0C9) [0x95f0c9]
----- END BACKTRACE -----
2017-10-09T21:33:02.097+0000 I - [initandlisten]
***aborting after invariant() failure
ERROR: child process failed, exited with error number 14
If I try using bin command it'll run.
root#ip-172-31-15-96:/home/bitnami/apps/api# mongod
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] MongoDB starting : pid=15830 port=27017 dbpath=/data/db 64-bit host=ip-172-31-15-96
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] db version v3.2.11
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] git version: 009580ad490190ba33d1c6253ebd8d91808923e4
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] modules: none
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] build environment:
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] distarch: x86_64
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-10-09T19:13:48.550+0000 I CONTROL [initandlisten] options: {}
2017-10-09T19:13:48.572+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-10-09T19:13:48.572+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten]
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten]
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten]
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2017-10-09T19:13:48.724+0000 I CONTROL [initandlisten]
2017-10-09T19:13:48.725+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2017-10-09T19:13:48.725+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2017-10-09T19:13:48.725+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
Has anyone experienced this before?
In bitnami stacks the following script is used:
sudo /opt/bitnami/ctlscript.sh start
I advise you to use that one but like this
sudo /opt/bitnami/ctlscript.sh restart
Finally i've reinstalled bitnami mean stack using wget.
$ wget https://bitnami.com/redirect/to/159963/bitnami-meanstack-3.4.9-0-linux-x64-installer.run
$ chmod +x ./bitnami-meanstack-3.4.9-0-linux-x64-installer.run
I followed the installer steps and then run $ sudo service bitnami start mongodb.
Thanks.
I'm trying to run a rocketchat server on Debian 8.6.
I've followed all the instructions from this page https://rocket.chat/docs/installation/manual-installation/debian/ which sends me to this one https://rocket.chat/docs/installation/manual-installation/ubuntu/#2-install-rocketchat
Now I'm stuck at this part.
Start the MongoDB shell and initiate the replica set:
mongo
rs.initiate()
It returns this
root#viejo:/# mongo
MongoDB shell version: 3.2.10
connecting to: test
Server has startup warnings:
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is always'.
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 3902 processes, 65536 files. Number of processes should be at least 32768 : 0.5 times number of files.
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
> rs.initiate()
{
"ok" : 0,
"errmsg" : "This node was not started with the replSet option",
"code" : 76
}
In the /etc/mongod.conf file, I have manually substituted this
replication:
replSetName: "001-rs"
with this
--replSet=001-rs
as recommended here Replica Set Error Code 76 but nothing changed
Here some important text:
root#viejo:/# mongod --version
db version v3.2.10
git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
allocator: tcmalloc
modules: none
build environment:
distmod: debian71
distarch: x86_64
target_arch: x86_64re
root#viejo:/# node --version
v4.5.0
This is my /etc/mongodb.conf file (the "journal=true" line is followed by 65 lines, all of them starting with #)
# mongodb.conf
# Where to store the data.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log
logappend=true
bind_ip = 127.0.0.1
#port = 27017
# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true
This is my /etc/mongod.conf file
# mongod.conf
# for documentation of all options, see:
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
#processManagement:
#security:
#operationProfiling:
replication:
replSetName: "001-rs"
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
This is my /etc/hosts file
127.0.0.1 localhost
127.0.1.1 viejo.primer viejo
127.0.0.1 viejo
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I've done this (in another tab) before running the mongo command.
root#viejo:/# mongod
2016-10-02T12:19:33.499-0700 I CONTROL [initandlisten] MongoDB starting : pid=1665 port=27017 dbpath=/data/db 64-bit host=viejo
2016-10-02T12:19:33.500-0700 I CONTROL [initandlisten] db version v3.2.10
2016-10-02T12:19:33.500-0700 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-10-02T12:19:33.500-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016
2016-10-02T12:19:33.500-0700 I CONTROL [initandlisten] allocator: tcmalloc
2016-10-02T12:19:33.500-0700 I CONTROL [initandlisten] modules: none
2016-10-02T12:19:33.500-0700 I CONTROL [initandlisten] build environment:
2016-10-02T12:19:33.500-0700 I CONTROL [initandlisten] distmod: debian71
2016-10-02T12:19:33.501-0700 I CONTROL [initandlisten] distarch: x86_64
2016-10-02T12:19:33.501-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-10-02T12:19:33.501-0700 I CONTROL [initandlisten] options: {}
2016-10-02T12:19:33.611-0700 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-10-02T12:19:33.611-0700 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 3902 processes, 65536 files. Number of processes should be at least 32768 : 0.5 times number of files.
2016-10-02T12:19:35.158-0700 I CONTROL [initandlisten]
2016-10-02T12:19:35.159-0700 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-10-02T12:19:35.160-0700 I NETWORK [initandlisten] waiting for connections on port 27017
2016-10-02T12:19:35.161-0700 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-10-02T12:19:50.030-0700 I NETWORK [initandlisten] connection accepted from 127.0.0.1:39524 #1 (1 connection now open)
I need some help here please!
Thanks in advance.
I have upgraded my MONGODB version from 2.6.7 to 3.0.3.
When I run following command
./mongod --dbpath database --storageEngine wiredTiger
getting output,
2015-10-19T14:47:04.936+0530 I CONTROL [initandlisten] MongoDB starting : pid=22642 port=27017 dbpath=database 64-bit host=inkilab-Vostro-2520
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten]
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten]
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten]
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] db version v3.0.0
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] git version: a841fd6394365954886924a35076691b4d149168
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] build info: Linux ip-10-179-177-12 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] allocator: tcmalloc
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "database", engine: "wiredTiger" } }
2015-10-19T14:47:04.963+0530 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2015-10-19T14:47:04.963+0530 E NETWORK [initandlisten] addr already in use
2015-10-19T14:47:05.203+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2015-10-19T14:47:27.542+0530 I CONTROL [initandlisten] now exiting
2015-10-19T14:47:27.543+0530 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2015-10-19T14:47:27.543+0530 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2015-10-19T14:47:27.543+0530 I NETWORK [initandlisten] shutdown: going to close sockets...
2015-10-19T14:47:27.600+0530 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2015-10-19T14:47:49.491+0530 I STORAGE [initandlisten] shutdown: removing fs lock...
2015-10-19T14:47:49.518+0530 I CONTROL [initandlisten] dbexit: rc: 48
Please help me.
The bindIp error indicates you already have a service running on the default port. In order to override, you must first stop or delete the service and start the mongod again.
In order to kill the services on the default port, you can try the following commands:
ps -eAf | grep mongo
This will give you current instances, if any of any service by name like "mongo", or interpret as service like 'mongo%'. Now you will have to kill the traces you have on the default port and this can be done using the kill command in shell. For help type:
man kill
Alternatively, you can start mongod on a new assigned port by using the -p or --port switch
Background Information
I'm playing around with my first nodejs test app that is attempting to connect to a remote mongodb.
Problem:
The connection is failing with the following message:
admin#testdev:~/Documents/nodejs_tests$ sudo nodejs index.js
Server has started.
Request for / received
About to route a request for: /
inside db connect method
Request for /favicon.ico received
About to route a request for: /favicon.ico
inside db connect method
MongoError: connect ECONNREFUSED
null
MongoError: connect ECONNREFUSED
null
Here's the logic to connect:
function connect_nimble() {
console.log("inside db connect method");
MongoClient.connect("mongodb://10.1.1.1:27017/test", function(err,db) {
console.log(err);
console.log(db);
if(!err) {
console.log("booya! Connected to mongo");
return true;
}
});
}
What I've checked so far:
I've made sure that the database server is using port 27017. Here's what I see in the mongodb logs when i restart the database:
admin#mongotest:~$ tail -f /var/log/mongodb/mongod.log
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten]
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] db version v3.0.4
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] git version: 0481c958daeb2969800511e7475dc66986fa9ed5
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] build info: Linux ip-10-45-73-23 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] allocator: tcmalloc
2015-07-21T09:52:41.452-0500 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
**2015-07-21T09:52:41.470-0500 I NETWORK [initandlisten] waiting for connections on port 27017**
I've made sure I have a database called "test" by starting "mongo"... and then switching in and out of the test database using the "use test" / "use admin" commands.
I don't believe I have authorization turned on. This is what I have in the mongo.conf file:
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
And to prove it, in order to get into the test database on the server via command line, I just have to type "mongo" and then by default, I'm in the test database. So I think I can safely assume I don't have any authentication going on.
Just in case, I also checked netstat for the port number:
admin#mongotest:~$ sudo netstat -taupen | grep mongo
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 117 6465150 18792mongod
admin#mongotest:~$
I'm currently reading the manual to see if there's anything else I should be checking. I'm also reading through the various stackoverflow posts that are similar, but I haven't found me an answer yet.
Any suggestions?
I can see in your logs that Mongo is listening on 127.0.0.1. This is likely your problem. You will have to change the bind-ip address configuration setting to allow Mongo to listen to specific or all IP addresses. You can find how to do this here: Cannot connect to mongodb using machine ip
Open a terminal.
Type mongod & and check the stacktrace.
This is an example of a failing start
I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
I NETWORK [initandlisten] shutdown: going to close listening sockets...
I NETWORK [initandlisten] shutdown: going to flush diaglog...
I CONTROL [initandlisten] now exiting
To fix this, Create the folder /data/db
In the terminal, type mkdir /data/db
Type againmongod
It works !!
[initandlisten] ** WARNING: Access control is not enabled for the database.
I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
I CONTROL [initandlisten]
I CONTROL [initandlisten]
I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
I know there are very similar questions, but I have tried all of their solutions, without success.
I have installed mongo on a Windows7 machine, as well as a Linux machine. No fancy configuration, just the default. I can start the mongod process, and then using the mongo shell I can connect to 127.0.0.1 on both with no issue whatsoever.
However, when I try to connect from the Windows machine to Linux, no luck.
I tried
mongo --host xxx.xxx.xxx.xxx --verbose
(with ip address for xxx.xxx.xxx.xxx of course) and got
MongoDB shell version: 2.6.0
connecting to: xxx.xxx.xxx.xxx:27017/test
2014-06-30T19:35:35.081-0400 creating new connection to:xxx.xxx.xxx.xxx:27017
2014-06-30T19:35:35.085-0400 [ConnectBG] BackgroundJob starting: ConnectBG
2014-06-30T19:35:56.091-0400 Error: couldn't connect to server xxx.xxx.xxx.xxx:27017
(xxx.xxx.xxx.xxx), connection attempt failed at src/mongo/shell/mongo.js:148
2014-06-30T19:35:56.092-0400 User Assertion: 12513:connect failed
exception: connect failed
I even tried starting mongod on the Linux machine using
mongod --bind_ip 0.0.0.0 -v
(note, I am not using a mongodb.conf file, but I even tried creating one with no bind_ip line, but same result) and none of these attempts solved my issues
I can connect to the Linux machine from Windows using putty fine, I can ping it, etc.
I read the other questions, but did not find a solution. I am new to this, this is my first time, so I might have overlooked something basic, any help is appreciated.
The command netstat -a | grep 27017 on the Linux machine gave me
tcp 0 0 *:27017 *:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 226111 /tmp/mongodb-27017.sock
I don't know if that is correct or that hints at an issue.
Just for completeness, the command
./mongod --bind_ip 0.0.0.0 -v
on the Linux machine to start the mongod process gave me:
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
2014-06-30T16:50:12.194-0700 [DataFileSync] BackgroundJob starting: DataFileSync
2014-06-30T16:50:12.194-0700 shardKeyTest passed
2014-06-30T16:50:12.194-0700 isInRangeTest passed
2014-06-30T16:50:12.194-0700 shardObjTest passed
2014-06-30T16:50:12.195-0700 [initandlisten] MongoDB starting : pid=28755 port=27017
dbpath=/data/db 64-bit host=five9-sac-1
2014-06-30T16:50:12.195-0700 [initandlisten] db version v2.6.3
2014-06-30T16:50:12.195-0700 [initandlisten] git version:
255f67a66f9603c59380b2a389e386910bbb52cb
2014-06-30T16:50:12.195-0700 [initandlisten] build info: Linux build12.nj1.10gen.cc
2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_ 64
BOOST_LIB_VERSION=1_49
2014-06-30T16:50:12.195-0700 [initandlisten] allocator: tcmalloc
2014-06-30T16:50:12.195-0700 [initandlisten] options: { net: { bindIp: "0.0.0.0" },
systemLog: { verbosity: 1 } }
2014-06-30T16:50:12.226-0700 [initandlisten] flushing directory /data/db
2014-06-30T16:50:12.246-0700 [initandlisten] journal dir=/data/db/journal
2014-06-30T16:50:12.246-0700 [initandlisten] recover : no journal files present, no
recovery needed
2014-06-30T16:50:12.246-0700 [initandlisten] flushing directory /data/db/journal
2014-06-30T16:50:12.274-0700 [initandlisten] flushing directory /data/db/journal
2014-06-30T16:50:12.292-0700 [initandlisten] opening db: local
2014-06-30T16:50:12.293-0700 [initandlisten] enter repairDatabases (to check pdfile
version #)
2014-06-30T16:50:12.293-0700 [initandlisten] local
2014-06-30T16:50:12.295-0700 [initandlisten] test
2014-06-30T16:50:12.295-0700 [initandlisten] opening db: test
2014-06-30T16:50:12.296-0700 [initandlisten] done repairDatabases
2014-06-30T16:50:12.296-0700 [initandlisten] opening db: admin
2014-06-30T16:50:12.296-0700 [initandlisten] query admin.system.roles planSummary: EOF
ntoreturn:0 ntoskip:0 keyUpdates:0 numYields:0 locks(micros) W :93 r:49
nreturned:0 reslen:20 0ms
2014-06-30T16:50:12.296-0700 [TTLMonitor] BackgroundJob starting: TTLMonitor
2014-06-30T16:50:12.296-0700 [ClientCursorMonitor] BackgroundJob starting:
ClientCursorMonitor
2014-06-30T16:50:12.296-0700 [initandlisten] fd limit hard:4096 soft:1024 max conn: 819
2014-06-30T16:50:12.296-0700 [IndexRebuilder] BackgroundJob starting: IndexRebuilder
2014-06-30T16:50:12.296-0700 [PeriodicTaskRunner] BackgroundJob starting:
PeriodicTaskRunner
2014-06-30T16:50:12.297-0700 [IndexRebuilder] opening db: local
2014-06-30T16:50:12.297-0700 [initandlisten] create collection local.startup_log {
size: 10485760, capped: true }
2014-06-30T16:50:12.297-0700 [initandlisten] command local.$cmd command: create {
create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0
numYields:0 reslen:75 0ms
2014-06-30T16:50:12.298-0700 [initandlisten] insert local.startup_log ninserted:1
keyUpdates:0 numYields:0 0ms
2014-06-30T16:50:12.298-0700 [initandlisten] waiting for connections on port 27017
2014-06-30T16:50:12.303-0700 [IndexRebuilder] opening db: test
2014-06-30T16:50:12.308-0700 [IndexRebuilder] checking complete
No further output when trying to connect from Windows with the mongo shell.
I am happy to run any other command and post the results.