How to configure two MongoDB servers in one local system? - mongodb

In order to do replication in MongoDB in Windows 10, Multiple servers are needed in a single system. But the client cannot connect to the server. After the host is created using
mongod --bind_ip localhost,My-Example-Associated-Hostname
The output is
2020-07-09T19:41:00.708+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-07-09T19:41:01.913+0530 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-07-09T19:41:02.065+0530 I CONTROL [initandlisten] MongoDB starting : pid=18840 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-1R3OPQG
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] db version v4.2.7
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] allocator: tcmalloc
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] modules: none
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] build environment:
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] distmod: 2012plus
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] distarch: x86_64
2020-07-09T19:41:02.066+0530 I CONTROL [initandlisten] target_arch: x86_64
2020-07-09T19:41:02.067+0530 I CONTROL [initandlisten] options: { net: { bindIp: "localhost,My-Example-Associated-Hostname" } }
2020-07-09T19:41:03.115+0530 W NETWORK [initandlisten] Found no addresses for HostNotFound: Could not find address for My-Example-Associated-Hostname:27017: SocketException: No such host is known.
2020-07-09T19:41:03.142+0530 I STORAGE [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-07-09T19:41:03.143+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3533M,cache_overflow=(file_max=0M),session_max=33000,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,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-07-09T19:41:03.348+0530 I STORAGE [initandlisten] WiredTiger message [1594303863:347681][18840:140716566797904], txn-recover: Recovering log 11 through 12
2020-07-09T19:41:03.497+0530 I STORAGE [initandlisten] WiredTiger message [1594303863:497260][18840:140716566797904], txn-recover: Recovering log 12 through 12
2020-07-09T19:41:03.641+0530 I STORAGE [initandlisten] WiredTiger message [1594303863:641697][18840:140716566797904], txn-recover: Main recovery loop: starting at 11/6144 to 12/256
2020-07-09T19:41:03.900+0530 I STORAGE [initandlisten] WiredTiger message [1594303863:899522][18840:140716566797904], txn-recover: Recovering log 11 through 12
2020-07-09T19:41:04.077+0530 I STORAGE [initandlisten] WiredTiger message [1594303864:77045][18840:140716566797904], txn-recover: Recovering log 12 through 12
2020-07-09T19:41:04.210+0530 I STORAGE [initandlisten] WiredTiger message [1594303864:209691][18840:140716566797904], txn-recover: Set global recovery timestamp: (0, 0)
2020-07-09T19:41:04.667+0530 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-07-09T19:41:04.704+0530 I STORAGE [initandlisten] Timestamp monitor starting
2020-07-09T19:41:04.799+0530 I CONTROL [initandlisten]
2020-07-09T19:41:04.800+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-07-09T19:41:04.801+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-07-09T19:41:04.801+0530 I CONTROL [initandlisten]
2020-07-09T19:41:04.895+0530 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-07-09T19:41:04.915+0530 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
2020-07-09T19:41:04.916+0530 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-07-09T19:41:04.933+0530 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-07-09T19:41:04.961+0530 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-07-09T19:41:07.946+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2020-07-09T19:41:07.950+0530 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-07-09T19:41:07.997+0530 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-07-09T19:41:08.045+0530 I NETWORK [listener] Listening on 127.0.0.1
2020-07-09T19:41:08.045+0530 I NETWORK [listener] waiting for connections on port 27017
2020-07-09T19:41:08.083+0530 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
Then in the client I give
mongo --host My-Example-Associated-Hostname
But the output is
MongoDB shell version v4.2.7
connecting to: mongodb://My-Example-Associated-Hostname:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-07-09T19:41:30.776+0530 E QUERY [js] Error: couldn't connect to server My-Example-Associated-Hostname:27017, connection attempt failed: HostNotFound: Could not find address for My-Example-Associated-Hostname:27017: SocketException: No such host is known. :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-07-09T19:41:30.812+0530 F - [main] exception: connect failed
2020-07-09T19:41:30.812+0530 E - [main] exiting with code 1
How can I solve this?

Your hostname is not connect in client call. It should be mongo --host localhost

Related

Unable to connect with mongo db shell

After running mongod and mongo in terminal
$mongo
MongoDB shell version v4.2.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("707b65a3-c675-4b03-a386-21c5d589c05f") }
MongoDB server version: 4.2.6
and nothing happens! I am unable to create a new database. Please Help!
In another terminal
$ mongod
2020-06-28T20:52:27.841+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-06-28T20:52:28.502+0530 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] MongoDB starting : pid=14576 port=27017 dbpath=E:\data\db\ 64-bit host=BTL
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] db version v4.2.6
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] allocator: tcmalloc
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] modules: none
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] build environment:
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] distmod: 2012plus
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] distarch: x86_64
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] target_arch: x86_64
2020-06-28T20:52:28.504+0530 I CONTROL [initandlisten] options: {}
2020-06-28T20:52:28.512+0530 W STORAGE [initandlisten] Detected unclean shutdown - E:\data\db\mongod.lock is not empty.
2020-06-28T20:52:28.514+0530 I STORAGE [initandlisten] Detected data files in E:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-06-28T20:52:28.514+0530 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
2020-06-28T20:52:28.514+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1491M,cache_overflow=(file_max=0M),session_max=33000,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,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-06-28T20:52:28.889+0530 I STORAGE [initandlisten] WiredTiger message [1593357748:888613][14576:140705565789264], txn-recover: Recovering log 3 through 4
2020-06-28T20:52:29.105+0530 I STORAGE [initandlisten] WiredTiger message [1593357749:104639][14576:140705565789264], txn-recover: Recovering log 4 through 4
2020-06-28T20:52:29.382+0530 I STORAGE [initandlisten] WiredTiger message [1593357749:381648][14576:140705565789264], txn-recover: Main recovery loop: starting at 3/5632 to 4/256
2020-06-28T20:52:29.885+0530 I STORAGE [initandlisten] WiredTiger message [1593357749:884866][14576:140705565789264], txn-recover: Recovering log 3 through 4
2020-06-28T20:52:30.476+0530 I STORAGE [initandlisten] WiredTiger message [1593357750:475971][14576:140705565789264], txn-recover: Recovering log 4 through 4
2020-06-28T20:52:30.693+0530 I STORAGE [initandlisten] WiredTiger message [1593357750:692960][14576:140705565789264], txn-recover: Set global recovery timestamp: (0, 0)
2020-06-28T20:52:33.168+0530 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-06-28T20:52:36.667+0530 I STORAGE [initandlisten] Timestamp monitor starting
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten]
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten]
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-06-28T20:52:37.172+0530 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-06-28T20:52:37.173+0530 I CONTROL [initandlisten]
2020-06-28T20:52:42.495+0530 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-06-28T20:52:44.701+0530 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
2020-06-28T20:52:45.029+0530 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-06-28T20:52:45.348+0530 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-06-28T20:52:47.258+0530 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-06-28T20:52:51.373+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'E:/data/db/diagnostic.data'
2020-06-28T20:52:51.410+0530 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-06-28T20:52:51.411+0530 I NETWORK [listener] Listening on 127.0.0.1
2020-06-28T20:52:51.411+0530 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-06-28T20:52:51.411+0530 I NETWORK [listener] waiting for connections on port 27017
2020-06-28T20:52:52.042+0530 I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
2020-06-28T20:52:52.520+0530 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>

Why when i start mongod after installation it got stuck to [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>

yesterday when i was about to install mongodb, i created /data/db with the right permission and i typed mongod but it got stuck on [ftdc] Marking collection local.oplog.rs as collection version: since 1 hour, thanks if you take time to help me
I was having the same problem. Open a new terminal, cd into the same path and then run "mongo" command. Then it worked!
I think we have had the same problem and I found the solution for myself.
But I beg my pardon if I am wrong)
If you want to get access to Mongodb you have to type mongo instead of mongod.
I was doing a step by step tutorial on installation of MongoDB on Centos 7 and playing around with it.
At some point I've decided to shutdown the server with:
db.shutdownServer()
And after that I've had trouble starting/logging into the database with mongod.
But the thing is, that mongod starts the Mongodb server in your current terminal.
[root#ip-*-*-*-* tmp]# mongod
2020-06-09T19:52:14.630+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-06-09T19:52:14.632+0000 W ASIO [main] No TransportLayer configured during NetworkInterface startup
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] MongoDB starting : pid=27618 port=27017 dbpath=/data/db 64-bit host=ip-*-*-*-*.eu-central-1.compute.internal
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] db version v4.2.7
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] allocator: tcmalloc
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] modules: none
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] build environment:
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] distmod: rhel70
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] distarch: x86_64
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
2020-06-09T19:52:14.633+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-06-09T19:52:14.633+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=256M,cache_overflow=(file_max=0M),session_max=33000,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,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2020-06-09T19:52:15.356+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:356822][27618:0x7f9b34a81c40], txn-recover: Recovering log 6 through 7
2020-06-09T19:52:15.412+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:412272][27618:0x7f9b34a81c40], txn-recover: Recovering log 7 through 7
2020-06-09T19:52:15.500+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:500634][27618:0x7f9b34a81c40], txn-recover: Main recovery loop: starting at 6/22528 to 7/256
2020-06-09T19:52:15.609+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:609015][27618:0x7f9b34a81c40], txn-recover: Recovering log 6 through 7
2020-06-09T19:52:15.672+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:672877][27618:0x7f9b34a81c40], txn-recover: Recovering log 7 through 7
2020-06-09T19:52:15.727+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:727038][27618:0x7f9b34a81c40], txn-recover: Set global recovery timestamp: (0, 0)
2020-06-09T19:52:15.735+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-06-09T19:52:15.739+0000 I STORAGE [initandlisten] Timestamp monitor starting
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten]
2020-06-09T19:52:15.743+0000 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-06-09T19:52:15.744+0000 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
2020-06-09T19:52:15.744+0000 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-06-09T19:52:15.745+0000 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-06-09T19:52:15.746+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-06-09T19:52:15.746+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2020-06-09T19:52:15.748+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-06-09T19:52:15.749+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-06-09T19:52:15.749+0000 I NETWORK [listener] Listening on /tmp/mongodb-27017.sock
2020-06-09T19:52:15.749+0000 I NETWORK [listener] Listening on 127.0.0.1
2020-06-09T19:52:15.749+0000 I NETWORK [listener] waiting for connections on port 27017
2020-06-09T19:52:16.000+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
And I just got stuck at this point and pressed ctrl+C
2020-06-09T19:56:26.172+0000 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends
2020-06-09T19:56:26.172+0000 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2020-06-09T19:56:26.176+0000 I NETWORK [listener] removing socket file: /tmp/mongodb-27017.sock
2020-06-09T19:56:26.176+0000 I - [signalProcessingThread] Stopping further Flow Control ticket acquisitions.
2020-06-09T19:56:26.176+0000 I CONTROL [signalProcessingThread] Shutting down free monitoring
2020-06-09T19:56:26.176+0000 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Deregistering all the collections
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Timestamp monitor shutting down
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Shutting down session sweeper thread
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Finished shutting down session sweeper thread
2020-06-09T19:56:26.180+0000 I STORAGE [signalProcessingThread] Shutting down journal flusher thread
2020-06-09T19:56:26.264+0000 I STORAGE [signalProcessingThread] Finished shutting down journal flusher thread
2020-06-09T19:56:26.264+0000 I STORAGE [signalProcessingThread] Shutting down checkpoint thread
2020-06-09T19:56:26.264+0000 I STORAGE [signalProcessingThread] Finished shutting down checkpoint thread
2020-06-09T19:56:26.268+0000 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2020-06-09T19:56:26.268+0000 I CONTROL [signalProcessingThread] now exiting
2020-06-09T19:56:26.268+0000 I CONTROL [signalProcessingThread] shutting down with code:0
And at this point I realized that I had that fatal extra letter and I was able to access the database with
[root#ip-*-*-*-* tmp]# mongo
After many hours and few reinstalls, I decided to look and view if some files was "corrupt", I found that MongoDB doesn't delete its folder in /var/lib/, so I deleted it and when I reinstalled MongoDB again it worked like a charm.

Mongod exits with error code: 62 when attempting to start mongod

I tried to start mongod and got this error
forked process: 4271
ERROR: child process failed, exited with error number 62
To see additional information in this output, start without the "--fork" option.
I retried with sudo mongod and got this instead
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] MongoDB starting : pid=4275 port=27017 dbpath=/data/db 64-bit host=dhcp020-218-083.wireless.buffalo.edu
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] db version v4.2.1
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] allocator: system
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] modules: none
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] build environment:
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] distarch: x86_64
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] target_arch: x86_64
2019-11-26T12:54:27.563-0500 I CONTROL [initandlisten] options: {}
2019-11-26T12:54:27.564-0500 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-11-26T12:54:27.564-0500 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,cache_overflow=(file_max=0M),session_max=33000,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,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
2019-11-26T12:54:28.082-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:81997][4275:0x114a835c0], txn-recover: Recovering log 35 through 36
2019-11-26T12:54:28.131-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:131917][4275:0x114a835c0], txn-recover: Recovering log 36 through 36
2019-11-26T12:54:28.180-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:180756][4275:0x114a835c0], txn-recover: Main recovery loop: starting at 35/896 to 36/256
2019-11-26T12:54:28.259-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:259184][4275:0x114a835c0], txn-recover: Recovering log 35 through 36
2019-11-26T12:54:28.306-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:306249][4275:0x114a835c0], txn-recover: Recovering log 36 through 36
2019-11-26T12:54:28.345-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:345839][4275:0x114a835c0], txn-recover: Set global recovery timestamp: (0,0)
2019-11-26T12:54:28.399-0500 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-11-26T12:54:28.405-0500 I STORAGE [initandlisten] Timestamp monitor starting
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten]
2019-11-26T12:54:28.405-0500 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2019-11-26T12:54:28.407-0500 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2019-11-26T12:54:28.408-0500 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: BadValue: Invalid value for version, found 3.6, expected '4.2' or '4.0'. Contents of featureCompatibilityVersion document in admin.system.version: { _id: "featureCompatibilityVersion", version: "3.6" }. See http://dochub.mongodb.org/core/4.0-feature-compatibility.). If the current featureCompatibilityVersion is below 4.0, see the documentation on upgrading at http://dochub.mongodb.org/core/4.0-upgrade-fcv.
2019-11-26T12:54:28.408-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-11-26T12:54:28.408-0500 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-26T12:54:28.408-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Deregistering all the collections
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Timestamp monitor shutting down
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Shutting down session sweeper thread
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Finished shutting down session sweeper thread
2019-11-26T12:54:28.408-0500 I STORAGE [initandlisten] Shutting down journal flusher thread
2019-11-26T12:54:28.499-0500 I STORAGE [initandlisten] Finished shutting down journal flusher thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Shutting down checkpoint thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Finished shutting down checkpoint thread
2019-11-26T12:54:28.500-0500 I STORAGE [initandlisten] Downgrading WiredTiger datafiles.
2019-11-26T12:54:28.576-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:576019][4275:0x114a835c0], txn-recover: Recovering log 36 through 37
2019-11-26T12:54:28.615-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:615152][4275:0x114a835c0], txn-recover: Recovering log 37 through 37
2019-11-26T12:54:28.666-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:666135][4275:0x114a835c0], txn-recover: Main recovery loop: starting at 36/2048 to 37/256
2019-11-26T12:54:28.744-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:744560][4275:0x114a835c0], txn-recover: Recovering log 36 through 37
2019-11-26T12:54:28.790-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:790388][4275:0x114a835c0], txn-recover: Recovering log 37 through 37
2019-11-26T12:54:28.831-0500 I STORAGE [initandlisten] WiredTiger message [1574790868:831263][4275:0x114a835c0], txn-recover: Set global recovery timestamp: (0,0)
2019-11-26T12:54:28.964-0500 I STORAGE [initandlisten] shutdown: removing fs lock...
2019-11-26T12:54:28.965-0500 I CONTROL [initandlisten] now exiting
2019-11-26T12:54:28.965-0500 I CONTROL [initandlisten] shutting down with code:62```
I already checked to see if I have a /data/db folder and I do, I tried to delete the data folder and recreate it with no luck. I checked on the forums and error code 62 means that the data/db folder is on a different version than the MongoDB installation, I'm not sure how I would go about fixing this error.

mongo: “exception: connect failed”

I am trying to connect to the mongo server, using the "mongo" command in the command prompt and this error is showing: "exception: connect failed"
Here is how I am trying to do it:
enter image description here
This is the mongodb.log
2018-03-27T14:00:19.299+0800 I CONTROL [main] ***** SERVER RESTARTED *****
2018-03-27T14:00:19.647+0800 I CONTROL [main] Trying to start Windows service 'MongoDB'
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] MongoDB starting : pid=10480 port=27017 dbpath=d:\mongodbData\db 64-bit host=DESKTOP-KEA31I3
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] db version v3.6.3
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] allocator: tcmalloc
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] modules: none
2018-03-27T14:00:19.648+0800 I CONTROL [initandlisten] build environment:
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] distmod: 2008plus-ssl
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] distarch: x86_64
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-03-27T14:00:19.649+0800 I CONTROL [initandlisten] options: { service: true, storage: { dbPath: "d:\mongodbData\db" }, systemLog: { destination: "file", logAppend: true, path: "d:\mongodbData\log\mongodb.log" } }
2018-03-27T14:00:19.651+0800 I - [initandlisten] Detected data files in d:\mongodbData\db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-03-27T14:00:19.651+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7632M,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),
2018-03-27T14:00:19.834+0800 I STORAGE [initandlisten] WiredTiger message [1522130419:833660][10480:140722874245456], txn-recover: Main recovery loop: starting at 4/6272
2018-03-27T14:00:19.970+0800 I STORAGE [initandlisten] WiredTiger message [1522130419:970024][10480:140722874245456], txn-recover: Recovering log 4 through 5
2018-03-27T14:00:20.046+0800 I STORAGE [initandlisten] WiredTiger message [1522130420:46191][10480:140722874245456], txn-recover: Recovering log 5 through 5
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-03-27T14:00:20.172+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.173+0800 I CONTROL [initandlisten] ** WARNING: The file system cache of this machine is configured to be greater than 40% of the total memory. This can lead to increased memory pressure and poor performance.
2018-03-27T14:00:20.174+0800 I CONTROL [initandlisten] See http://dochub.mongodb.org/core/wt-windows-system-file-cache
2018-03-27T14:00:20.174+0800 I CONTROL [initandlisten]
2018-03-27T14:00:20.402+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'd:/mongodbData/db/diagnostic.data'
2018-03-27T14:00:20.404+0800 I NETWORK [initandlisten] waiting for connections on port 27017
2018-03-27T14:00:20.404+0800 I STORAGE [initandlisten] Service running
Please help me. How to fix it
Run this following command :
sudo service mongodb stop
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
mongo

MongoDB server running, I get "mongo: command not found"

I`ve started mongoDB and it seems like its running fine, I think (see message below)? Then I open a new terminal window and I try to use the "mongo" command I get the following message:
-bash: mongo: command not found
When I try commands such as "use newtest", it says
-bash: use: command not found
My Path:
PATH=/Users/myname/.npm-global/bin:$PATH
Here is the message when I start mongoDB:
myname-MacBook-Air:~ myname$ mongod
I CONTROL [initandlisten] MongoDB starting : pid=581 port=27017 dbpath=/data/db 64-bit host=myname-MacBook-Air.local
I CONTROL [initandlisten] db version v3.6.2
I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8zh 14 Jan 2016
I CONTROL [initandlisten] allocator: system
I CONTROL [initandlisten] modules: none
I CONTROL [initandlisten] build environment:
I CONTROL [initandlisten] distarch: x86_64
I CONTROL [initandlisten] target_arch: x86_64
I CONTROL [initandlisten] options: {}
W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,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),
I STORAGE [initandlisten] WiredTiger message [1519475976:405758][581:0x7fff95b02340], txn-recover: Main recovery loop: starting at 4/3200
I STORAGE [initandlisten] WiredTiger message [1519475976:408878][581:0x7fff95b02340], txn-recover: Recovering log 4 through 5
I STORAGE [initandlisten] WiredTiger message [1519475976:564148][581:0x7fff95b02340], txn-recover: Recovering log 5 through 5
I CONTROL [initandlisten]
I CONTROL [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] ** WARNING: This server is bound to localhost.
I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
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 FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
I NETWORK [initandlisten] waiting for connections on port 27017
I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK
What am I doing wrong here to start mongodB? Or am I misunderstanding it?
Thanks :)