cannot connect to MongoDB with Docker-compose - node.js

I'm trying to create 2 containers with Docker-compose which one contain Mongo serive and another contain web service written by NodeJS.
This is my docker-compose.yml file:
version: '3'
services:
mongo:
build: ./docker_mongo/
volumes:
- ./database:/data/db
ports:
- "27017:27017"
node_app:
build: ./docker_node/
ports:
- "3001:3001"
- "16427:16427"
command: npm start
environment:
- OS:PI
depends_on:
- mongo
- mqtt
When I ran docker-compose, mongo service display this message:
mongo_1 | 2020-01-05T07:36:39.699+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=90cbb91eebd0
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] db version v4.0.14
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] git version: 1622021384533dade8b3c89ed3ecd80e1142c132
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] modules: none
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] build environment:
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] distmod: ubuntu1604
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] distarch: x86_64
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] target_arch: x86_64
mongo_1 | 2020-01-05T07:36:39.703+0000 I CONTROL [initandlisten] options: {}
mongo_1 | 2020-01-05T07:36:39.708+0000 I STORAGE [initandlisten]
mongo_1 | 2020-01-05T07:36:39.708+0000 I STORAGE [initandlisten] ** WARNING: Support for MMAPV1 storage engine has been deprecated and will be
mongo_1 | 2020-01-05T07:36:39.708+0000 I STORAGE [initandlisten] ** removed in version 4.2. Please plan to migrate to the wiredTiger
mongo_1 | 2020-01-05T07:36:39.708+0000 I STORAGE [initandlisten] ** storage engine.
mongo_1 | 2020-01-05T07:36:39.708+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/deprecated-mmapv1
mongo_1 | 2020-01-05T07:36:39.708+0000 I STORAGE [initandlisten]
mongo_1 | 2020-01-05T07:36:39.708+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'.
mongo_1 | 2020-01-05T07:36:39.727+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal
mongo_1 | 2020-01-05T07:36:39.728+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
mongo_1 | 2020-01-05T07:36:39.730+0000 I STORAGE [initandlisten] WARNING: This file system is not supported. For further information see:
mongo_1 | 2020-01-05T07:36:39.730+0000 I STORAGE [initandlisten] http://dochub.mongodb.org/core/unsupported-filesystems
mongo_1 | 2020-01-05T07:36:39.730+0000 I STORAGE [initandlisten] Please notify MongoDB, Inc. if an unlisted filesystem generated this warning.
mongo_1 | 2020-01-05T07:36:39.970+0000 I JOURNAL [durability] Durability thread started
mongo_1 | 2020-01-05T07:36:39.971+0000 I JOURNAL [journal writer] Journal writer thread started
mongo_1 | 2020-01-05T07:36:40.003+0000 I STORAGE [initandlisten] WARNING: This file system is not supported. For further information see:
mongo_1 | 2020-01-05T07:36:40.003+0000 I STORAGE [initandlisten] http://dochub.mongodb.org/core/unsupported-filesystems
mongo_1 | 2020-01-05T07:36:40.003+0000 I STORAGE [initandlisten] Please notify MongoDB, Inc. if an unlisted filesystem generated this warning.
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten]
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten]
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
mongo_1 | 2020-01-05T07:36:40.003+0000 I CONTROL [initandlisten]
mongo_1 | 2020-01-05T07:36:40.308+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongo_1 | 2020-01-05T07:36:40.312+0000 I NETWORK [initandlisten] waiting for connections on port 27017
This shows that mongo service is ready on port 27017, but NodeJs server still could not to database:
node_app_1 | Error: Unable to connect to database
node_app_1 | MongoTimeoutError: Server selection timed out after 30000 ms
node_app_1 | at /node_app/app.js:84:20
With NodeJs server, mongoDb connect to url mongodb://mongo:27017/docker with mongo is the name of docker-compose service. I also tried with localhost but it didn't work.
I've tried this on a raspberry Pi, and it worked (just change mongo image).
Mongo Image on Pi
Can someone help?

In order to connect two containers, first, you have to understand docker networking. You are getting error probably because containers are isolated. There are multiple ways you can connect docker containers using different networking mode like:
Host-only network
Bridge networking
Read more here https://docs.docker.com/network/
You can configure host-only network as below:
Include network_mode: host for each service.
version: '3'
services:
mongo:
build: ./docker_mongo/
network_mode: host
volumes:
- ./database:/data/db
ports:
- "27017:27017"
node_app:
build: ./docker_node/
network_mode: host
ports:
- "3001:3001"
- "16427:16427"
command: npm start
environment:
- OS:PI
depends_on:
- mongo
- mqtt

Related

Why do I get "0 - Unknown Error [object ProgressEvent]" errors?

I have downloaded this file of the repository(https://github.com/zeeshan87/Server-side-Development-with-NodeJS-Express-and-MongoDB/tree/master/Final%20Integrating%20Client%20and%20Server) that is an Angular project combined with NodeJS server for backend part, and tried to run the integrated version of the project. in the Angular part it seems it works fine, but I don't know how exactly run the node server part?
I tried to create a file named data inside ..\Final Integrating Client and Server\conFusionServer folder, then ran mongod --dbpath=data --bind_ip 127.0.0.1 and it seems it works also fine with the following result:
2020-02-03T21:08:28.069+0330 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-03T21:08:28.074+0330 I CONTROL [initandlisten] MongoDB starting : pid=8660 port=27017 dbpath=data 64-bit host=DESKTOP-UQ8B9FK
2020-02-03T21:08:28.074+0330 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-02-03T21:08:28.074+0330 I CONTROL [initandlisten] db version v4.0.10
2020-02-03T21:08:28.075+0330 I CONTROL [initandlisten] git version: c389e7f69f637f7a1ac3cc9fae843b635f20b766
2020-02-03T21:08:28.075+0330 I CONTROL [initandlisten] allocator: tcmalloc
2020-02-03T21:08:28.075+0330 I CONTROL [initandlisten] modules: none
2020-02-03T21:08:28.075+0330 I CONTROL [initandlisten] build environment:
2020-02-03T21:08:28.075+0330 I CONTROL [initandlisten] distmod: 2008plus-ssl
2020-02-03T21:08:28.075+0330 I CONTROL [initandlisten] distarch: x86_64
2020-02-03T21:08:28.076+0330 I CONTROL [initandlisten] target_arch: x86_64
2020-02-03T21:08:28.076+0330 I CONTROL [initandlisten] options: { net: { bindIp: "127.0.0.1" }, storage: { dbPath: "data" } }
2020-02-03T21:08:28.079+0330 I STORAGE [initandlisten] Detected data files in data created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-02-03T21:08:28.079+0330 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7627M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2020-02-03T21:08:28.369+0330 I STORAGE [initandlisten] WiredTiger message [1580751508:368748][8660:140711408328272], txn-recover: Main recovery loop: starting at 5/6528 to 6/256
2020-02-03T21:08:28.491+0330 I STORAGE [initandlisten] WiredTiger message [1580751508:490742][8660:140711408328272], txn-recover: Recovering log 5 through 6
2020-02-03T21:08:28.594+0330 I STORAGE [initandlisten] WiredTiger message [1580751508:593742][8660:140711408328272], txn-recover: Recovering log 6 through 6
2020-02-03T21:08:28.653+0330 I STORAGE [initandlisten] WiredTiger message [1580751508:652710][8660:140711408328272], txn-recover: Set global recovery timestamp: 0
2020-02-03T21:08:28.923+0330 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-02-03T21:08:29.057+0330 I CONTROL [initandlisten]
2020-02-03T21:08:29.057+0330 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-02-03T21:08:29.060+0330 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-02-03T21:08:29.061+0330 I CONTROL [initandlisten]
2020-02-03T21:08:29.459+0330 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'data/diagnostic.data'
2020-02-03T21:08:29.463+0330 I NETWORK [initandlisten] waiting for connections on port 27017
But when I go to http://localhost:4200 to see the project, I get 0 - Unknown Error [object ProgressEvent] errors when loading the page elements!
It seems the connection between Angular and Node.JS isn't established but how can I fix it?

Docker-compose Nodejs Mongodb doesn't success

I am testing NodeJS + MongoDB on local Mac OS with docker-compose, but NodeJS and MongoDB can't connect successfully.
If I didn't setup --auth for MongoDB by below code, all works well.
Here's the code:
mongoose connection
mongodb://mongodb:27017/myprojectdatabase
docker-compose.yml
version: "3"
services:
web:
build: .
restart: always
ports:
- "8080:8080"
depends_on:
- mongodb
volumes:
- .:/mycode
mongodb:
image: mongo:latest
ports:
- "27017:27017"
Then I want to start --auth for the MongoDB like below, I got errors.
docker-compose.yml
version: "3"
services:
web:
build: .
restart: always
ports:
- "8080:8080"
depends_on:
- mongodb
volumes:
- .:/mycode
# environment:
# - NODE_ENV=production
mongodb:
image: mongo:latest
command: [--auth]
environment:
MONGO_INITDB_ROOT_USERNAME: my_admin
MONGO_INITDB_ROOT_PASSWORD: my2019
MONGO_INITDB_DATABASE: myprojectdatabase
ports:
- "27017:27017"
volumes:
- ./mydata:/data/db
Then I run
docker-compose down -v && docker-compose up --build
I got the output:
mongodb_1 | 2019-03-01T10:54:09.847+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=9554854909b1
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] db version v4.0.4
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] git version: f288a3bdf201007f3693c58e140056adf8b04839
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] modules: none
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] build environment:
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] distmod: ubuntu1604
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] distarch: x86_64
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] target_arch: x86_64
mongodb_1 | 2019-03-01T10:54:09.869+0000 I CONTROL [initandlisten] options: { net: { bindIpAll: true }, security: { authorization: "enabled" } }
mongodb_1 | 2019-03-01T10:54:09.873+0000 W STORAGE [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
mongodb_1 | 2019-03-01T10:54:09.876+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongodb_1 | 2019-03-01T10:54:09.878+0000 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
mongodb_1 | 2019-03-01T10:54:09.879+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=487M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
web_1 | connection error: { MongoNetworkError: failed to connect to server [mongodb:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 192.168.160.2:27017]
web_1 | at Pool.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:505:11)
web_1 | at emitOne (events.js:116:13)
And some times I can see the log contains the user created information, sometimes are not.
2019-03-01T10:38:50.323+0000 I STORAGE [conn2] createCollection: admin.system.users with generated UUID: 6b3b88f9-e77c-4094-a1c7-153816202a9e
mongodb_1 | Successfully added user: {
mongodb_1 | "user" : "my_admin",
mongodb_1 | "roles" : [
mongodb_1 | {
mongodb_1 | "role" : "root",
mongodb_1 | "db" : "admin"
mongodb_1 | }
mongodb_1 | ]
mongodb_1 | }
mongodb_1 | 2019-03-01T10:38:50.340+0000 E - [main] Error saving history file: FileOpenFailed: Unable to open() file /home/mongodb/.dbshell: Unknown error
I am new on docker stuff. I guess the main problem is web can't establish a connection with mongodb. Spend too long on this problem.
Any help? Thanks!
Make sure you're not going to localhost of the web container. Treat containers as separate machines: localhost in one container is not shared with another one. That's why in the connection string you have mongodb:27017 and not localhost:27017, because mongodb in your default docker network is a DNS name of the container with mongo. You are using this connection string in the first (successful) case, make sure you have a valid DNS name in the second one.
And also make sure to include your DB credentials (username:password) in the connection string too.

Can't connect to mongodb on remote but can on local

I'm trying to connect my node.js server (on ec2 instance) to my mongodb server (on ec2 instance but not the same). All works fine, i can connect to my mongodb with mongo on local but my node.js can't. Event if i try to type this command :
mongo <ec2-instance>/<dbname> -u <username> -p <password> --authenticationDatabase <dbname>
i get this error :
E QUERY [thread1] Error: couldn't connect to server
:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13 #(connect):1:6 exception:
connect failed
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] MongoDB starting : pid=2888 port=27017 dbpath=/data/db 64-bit host=ip-172-31-23-145
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] db version v3.4.9
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] allocator: tcmalloc
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] modules: none
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] build environment:
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] distmod: amazon
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] distarch: x86_64
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] target_arch: x86_64
2018-02-15T10:37:08.017+0000 I CONTROL [initandlisten] options: {}
2018-02-15T10:37:08.017+0000 W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
2018-02-15T10:37:08.042+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-02-15T10:37:08.042+0000 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
2018-02-15T10:37:08.042+0000 I STORAGE [initandlisten]
2018-02-15T10:37:08.042+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-02-15T10:37:08.042+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-02-15T10:37:08.042+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3480M,session_max=20000,eviction=(threads_min=4,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),
2018-02-15T10:37:08.065+0000 E STORAGE [initandlisten] WiredTiger error (1) [1518691028:65354][2888:0x7f4adae46e00], file:collection-2--1305918998266443804.wt, WT_SESSION.open_cursor: /data/db/collection-2--1305918998266443804.wt: handle-open: open: Operation not permitted
2018-02-15T10:37:08.065+0000 I - [initandlisten] Invariant failure: ret resulted in status UnknownError: 1: Operation not permitted at src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp 95
2018-02-15T10:37:08.065+0000 I - [initandlisten]
***aborting after invariant() failure
2018-02-15T10:37:08.076+0000 F - [initandlisten] Got signal: 6 (Aborted).
Here is what i got when i try to start mongod on my instance..

bitnami mean does not work using bitnami script

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.

Error run mongod

when run command "mongod" in terminal. Cant access localhost:28017
my log
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] MongoDB starting : pid=12891 port=27017 dbpath=/data/db 64-bit host=lucaspc
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] db version v3.2.7
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] allocator: tcmalloc
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] modules: none
2016-07-08T11:31:15.479-0300 I CONTROL [initandlisten] build environment:
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] distmod: ubuntu1404
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] distarch: x86_64
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] target_arch: x86_64
2016-07-08T11:31:15.480-0300 I CONTROL [initandlisten] options: {}
2016-07-08T11:31:15.531-0300 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2016-07-08T11:31:15.531-0300 E NETWORK [initandlisten] addr already in use
2016-07-08T11:31:15.531-0300 E STORAGE [initandlisten] Failed to set up sockets during startup.
2016-07-08T11:31:15.531-0300 I CONTROL [initandlisten] dbexit: rc: 48
There is already a process using the interface and port you want to use. You can find out what process that is using
sudo netstat -lpn | grep 27017
Then use
sudo kill <pid>
to stop it
Address already in use for socket: 0.0.0.0:27017
You already have an instance running on port 27017, change the port or kill the existing process.

Resources