Problem running mongod with run-rs. Windows10 - mongodb

C:\Users\Ashwin Bordoloi> run-rs --mongod --keep --dbpath D:\MongoDB\Server\4.2\data
Skipping purge
Running 'mongod' [ 27017, 27018, 27019 ]
Restarting replica set...
Error: failed to start mongod with options [
'--port=27019',
'--dbpath=D:\\MongoDB\\Server\\4.2\\data\\27019',
'--bind_ip=ashwin1014',
'--replSet=rs'
]
2020-04-16T01:16:28.926+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-04-16T01:16:28.929+0530 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] MongoDB starting : pid=21056 port=27019 dbpath=D:\MongoDB\Server\4.2\data\27019 64-bit host=ashwin1014
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] db version v4.2.5
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] git version: 2261279b51ea13df08ae708ff278f0679c59dc32
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] allocator: tcmalloc
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] modules: none
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] build environment:
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] distmod: 2012plus
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] distarch: x86_64
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] target_arch: x86_64
2020-04-16T01:16:28.930+0530 I CONTROL [initandlisten] options: { net: { bindIp: "ashwin1014", port: 27019 }, replication: { replSet: "rs" }, storage: { dbPath: "D:\MongoDB\Server\4.2\data\27019" } }
2020-04-16T01:16:28.935+0530 E STORAGE [initandlisten] Failed to set up listener: SocketException: An attempt was made to access a socket in a way forbidden by its access permissions.
2020-04-16T01:16:28.936+0530 I CONTROL [initandlisten] now exiting
2020-04-16T01:16:28.936+0530 I CONTROL [initandlisten] shutting down with code:48
at ChildProcess.<anonymous> (C:\Users\Ashwin Bordoloi\AppData\Roaming\npm\node_modules\run-rs\node_modules\mongodb-topology-manager\lib\server.js:404:15)
at ChildProcess.emit (events.js:321:20)
at maybeClose (internal/child_process.js:1026:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
since MongoDb local environment does not allow transactions, i used run-rs to run a replicaSet. However if i use run-rs i get an error "Failed to start mongod wih options"

MongoDB is shutting down with error code 48, it seems like the resources are already consumed.
run
netstat -a -n | find "27019"
and check if port 27019 is already used
TCP 0.0.0.0:27019 0.0.0.0:0 LISTENING
Kill the process on that port and restart the mongo.

Related

(Mac) Cannot start mongo, via "mongod" command

Just trying to get up and started using the "mongod" command...
I've already looked at the following:
Cannot start mongo db
Trouble Starting MongoDB (Mac) - Code: 100
... and many other forum posts.
This is what I got in my terminal:
#####-MacBook-Pro-2:p2w4-back_end ashesmachine$ mongod
2020-05-17T13:53:02.341-0700 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-17T13:53:02.345-0700 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] MongoDB starting : pid=57712 port=27017 dbpath=/data/db 64-bit host=#####-MacBook-Pro-2.local
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] db version v4.2.6
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] allocator: system
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] modules: none
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] build environment:
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] distarch: x86_64
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] target_arch: x86_64
2020-05-17T13:53:02.346-0700 I CONTROL [initandlisten] options: {}
2020-05-17T13:53:02.346-0700 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-05-17T13:53:02.347-0700 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-05-17T13:53:02.347-0700 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-05-17T13:53:02.347-0700 I CONTROL [initandlisten] now exiting
2020-05-17T13:53:02.347-0700 I CONTROL [initandlisten] shutting down with code:100
You should create the data/db directory before starting mongodb. Something like mkdir -p /data/db
This worked for me:
sudo mongod --dbpath ~/Documents/data/mongo-db

Installing and Running MongoDB - Many Errors on Mac

I'm trying to install mongoDB on my Mac. However, I'm running into a lot of issues.
I first installed mongoDB using Homebrew by running the following commands:
brew tap mongodb/brew
brew install mongodb-community#4.2
Then ran it using:
brew services start mongodb-community#4.2
Everything looks fine at this point, until I try running in the terminal:
mongod
At first I thought the issue was that I didn't create the /data/db folder, so I ran:
sudo mkdir -p /data/db
This did not work.
I then found an article stating Mac users need to run:
sudo mkdir -p /System/Volumes/Data/data/db
This worked.. then I ran:
mongod --dbpath /System/Volumes/Data/data/db
And received the following:
2020-02-09T20:36:07.667-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] MongoDB starting : pid=65406 port=27017 dbpath=/System/Volumes/Data/data/db 64-bit host=user-MacBook-Pro.local
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] allocator: system
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] modules: none
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] build environment:
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-09T20:36:07.672-0500 I CONTROL [initandlisten] options: { storage: { dbPath: "/System/Volumes/Data/data/db" } }
2020-02-09T20:36:07.673-0500 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2020-02-09T20:36:07.673-0500 I CONTROL [initandlisten] now exiting
2020-02-09T20:36:07.673-0500 I CONTROL [initandlisten] shutting down with code:48
I tried running:
sudo chown -Rv user /System/Volumes/Data/data/db
mongod
Then received the following:
2020-02-09T20:36:52.247-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] MongoDB starting : pid=65410 port=27017 dbpath=/data/db 64-bit host=user-MacBook-Pro.local
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] allocator: system
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] modules: none
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] build environment:
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-09T20:36:52.249-0500 I CONTROL [initandlisten] options: {}
2020-02-09T20:36:52.250-0500 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2020-02-09T20:36:52.250-0500 I CONTROL [initandlisten] now exiting
2020-02-09T20:36:52.250-0500 I CONTROL [initandlisten] shutting down with code:48
For the SocketException, I tried:
mongod --port 27018
And received:
2020-02-09T20:37:39.191-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] MongoDB starting : pid=65414 port=27018 dbpath=/data/db 64-bit host=user-MacBook-Pro.local
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] allocator: system
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] modules: none
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] build environment:
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-09T20:37:39.195-0500 I CONTROL [initandlisten] options: { net: { port: 27018 } }
2020-02-09T20:37:39.196-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-02-09T20:37:39.196-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-02-09T20:37:39.196-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-02-09T20:37:39.196-0500 I CONTROL [initandlisten] now exiting
2020-02-09T20:37:39.196-0500 I CONTROL [initandlisten] shutting down with code:100
I just can't seem to figure out what's going on, since I've just been following all the steps I've found on StackOverflow from other people with this exact issue.
After doing some more research and viewing the comments above, it appears that when installing MongoDB through homebrew you will use the following commands:
brew services start mongodb-community
Then in a new tab:
mongo
This will start mongo successfully. I'm still not 100% sure why mongod kicks back errors, but for all I know, the above works.

Trying to use mongod command

I am trying to start working with MongoDB but when I write the mongod command I get this error
2019-10-20T23:26:41.054-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] MongoDB starting : pid=4724 port=27017 dbpath=/data/db 64-bit host=MacBook-Pro-de-Andres.local
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] db version v4.2.0
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] allocator: system
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] modules: enterprise
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] build environment:
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] distarch: x86_64
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] target_arch: x86_64
2019-10-20T23:26:41.062-0500 I CONTROL [initandlisten] options: {}
2019-10-20T23:26:41.064-0500 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2019-10-20T23:26:41.064-0500 I CONTROL [initandlisten] now exiting
2019-10-20T23:26:41.064-0500 I CONTROL [initandlisten] shutting down with code:48
It is a problem with your port number. Since your default port number 27017 is already allocated to mongodb, this error occurs.
In this case, You can do two things.
you can stop the mongodb process and run mongod. Either you can run
mongod in a different port.
mongod --port PORT_NUMBER
port number can be 27018 or any number you wish.
Hope you can fix your issue

Mongo Shell from local is not getting connected to mongo server running in docker

I ran mongo server in docker and the logs came up just fine.
2019-04-12T10:39:51.334+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=8a03346e57d7
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] db version v3.2.22
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] modules: none
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] build environment:
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] distmod: rhel70
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] distarch: x86_64
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-04-12T10:39:51.335+0000 I CONTROL [initandlisten] options: { net: { port: 27017 }, processManagement: { pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/data/db" } }
2019-04-12T10:39:51.339+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,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),verbose=(recovery_progress),
2019-04-12T10:39:51.389+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-04-12T10:39:51.389+0000 I CONTROL [initandlisten]
2019-04-12T10:39:51.406+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2019-04-12T10:39:51.406+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-04-12T10:39:51.406+0000 I NETWORK [initandlisten] waiting for connections on port 27017
But, while connecting the mongodb server from local shell, the connection is getting timedout.
~/mongodb/bin/mongo --host 172.17.0.2
MongoDB shell version v3.6.11
connecting to: mongodb://172.17.0.2:27017/?gssapiServiceName=mongodb
2019-04-12T16:04:45.750+0530 W NETWORK [thread1] Failed to connect to 172.17.0.2:27017 after 5000ms milliseconds, giving up.
2019-04-12T16:04:45.753+0530 E QUERY [thread1] Error: couldn't connect to server 172.17.0.2:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:263:13
#(connect):1:6
exception: connect failed
where 172.17.0.2 is the IP obtained by running docker inspect <container-id
I was able to connect mongo shell with in the docker using the command docker exec --it <container-id> bash.
Here's the Docker file for refrence.
RUN echo -e "\
[mongodb]\n\
name=MongoDB Repository\n\
baseurl=https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/3.2/x86_64/\n\
gpgcheck=0\n\
enabled=1\n" >> /etc/yum.repos.d/mongodb.repo
# Install mongodb
RUN yum update -y && yum install -y mongodb-org
# Set up directory requirements
RUN mkdir -p /data/db /var/log/mongodb /var/run/mongodb
VOLUME ["/data/db", "/var/log/mongodb"]
# Expose port 27017 from the container to the host
EXPOSE 27017
# Start mongodb
ENTRYPOINT ["/usr/bin/mongod"]
CMD ["--port", "27017", "--dbpath", "/data/db", "--pidfilepath", "/var/run/mongodb/mongod.pid"]
Let me know if I am missing something.
Using MacOS

Get this error to start the mongo db : Failed to set up listener: SocketException: Address already in use

I am start working with mongoDB recent and get this issue again and again. I think i miss something but not get exactly where is the issue.I am working on a latest mongo db version 4.0.1.
iron#iron-System-Product-Name:/media/iron/1d6c195f-2350-423c-a3f0-0500c92e580a/codesnippets$ sudo mongod --dbpath db
2018-08-24T09:30:26.351+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] MongoDB starting : pid=5994 port=27017 dbpath=db 64-bit host=iron-System-Product-Name
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] db version v4.0.1
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] git version: 54f1582fc6eb01de4d4c42f26fc133e623f065fb
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] allocator: tcmalloc
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] modules: none
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] build environment:
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] distmod: ubuntu1604
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] distarch: x86_64
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "db" } }
2018-08-24T09:30:26.354+0530 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address already in use
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] now exiting
2018-08-24T09:30:26.354+0530 I CONTROL [initandlisten] shutting down with code:48
sudo lsof -iTCP -sTCP:LISTEN -n -P
sudo kill <mongo_command_pid>
mongod
Try these three commands and you will surely get out of it.