Mongod with --auth option

Hi,

I am trying to follow the course lecture " The Localhost Exception" in Authentication and when I try to execute the command
mongod --auth get the following error

vagrant@vagrant-ubuntu-trusty-64:~ mongod --auth 2019-04-10T18:10:03.821+0000 I CONTROL [initandlisten] MongoDB starting : pid=6037 port=27017 dbpath=/data/db 64-bit host=vagrant-ubuntu-trusty-64 2019-04-10T18:10:03.823+0000 I CONTROL [initandlisten] db version v3.2.22 2019-04-10T18:10:03.824+0000 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd 2019-04-10T18:10:03.825+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014 2019-04-10T18:10:03.827+0000 I CONTROL [initandlisten] allocator: tcmalloc 2019-04-10T18:10:03.827+0000 I CONTROL [initandlisten] modules: enterprise 2019-04-10T18:10:03.827+0000 I CONTROL [initandlisten] build environment: 2019-04-10T18:10:03.827+0000 I CONTROL [initandlisten] distmod: ubuntu1404 2019-04-10T18:10:03.828+0000 I CONTROL [initandlisten] distarch: x86_64 2019-04-10T18:10:03.830+0000 I CONTROL [initandlisten] target_arch: x86_64 2019-04-10T18:10:03.830+0000 I CONTROL [initandlisten] options: { security: { authorization: "enabled" } } 2019-04-10T18:10:03.903+0000 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating 2019-04-10T18:10:03.907+0000 I CONTROL [initandlisten] dbexit: rc: 100 vagrant@vagrant-ubuntu-trusty-64:~

Get the same error when executed againt vagrant@database:~$

@Rafeeq_01820

It might help if you read the error message which says

Data directory /data/db/ not found

Create your data directory and then start mongod (something you should already know from previous courses.)

Thanks. Yes I read the message but since I am using the Vagrant environment with two VMs already prebuilt, I assume this is already available and in the previous courses when I used the vagrant environment, -never created a Data directory and I did not had this kind of error at all.

I created the directory and then started mongod and I get the following information where it just hangs doing nothing until I forcibly abort it.

vagrant@database:/$ mongod --auth
2019-04-11T06:09:29.659+0000 I CONTROL [initandlisten] MongoDB starting : pid=11500 port=27017 dbpath=/data/db 64-bit host=database
2019-04-11T06:09:29.661+0000 I CONTROL [initandlisten] db version v3.2.22
2019-04-11T06:09:29.663+0000 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd
2019-04-11T06:09:29.663+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2019-04-11T06:09:29.663+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-11T06:09:29.663+0000 I CONTROL [initandlisten] modules: enterprise
2019-04-11T06:09:29.663+0000 I CONTROL [initandlisten] build environment:
2019-04-11T06:09:29.663+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2019-04-11T06:09:29.664+0000 I CONTROL [initandlisten] distarch: x86_64
2019-04-11T06:09:29.664+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-04-11T06:09:29.664+0000 I CONTROL [initandlisten] options: { security: { authorization: “enabled” } }
2019-04-11T06:09:29.738+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-11T06:09:29.905+0000 I CONTROL [initandlisten]
2019-04-11T06:09:29.906+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-04-11T06:09:29.907+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-04-11T06:09:29.908+0000 I CONTROL [initandlisten]
2019-04-11T06:09:29.909+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-04-11T06:09:29.910+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-04-11T06:09:29.910+0000 I CONTROL [initandlisten]
2019-04-11T06:09:29.996+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory ‘/data/db/diagnostic.data’
2019-04-11T06:09:29.997+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2019-04-11T06:09:29.998+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker

2019-04-11T06:17:49.771+0000 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends
2019-04-11T06:17:49.773+0000 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2019-04-11T06:17:49.782+0000 I CONTROL [signalProcessingThread] now exiting
2019-04-11T06:17:49.784+0000 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets…
2019-04-11T06:17:49.789+0000 I NETWORK [signalProcessingThread] closing listening socket: 6
2019-04-11T06:17:49.789+0000 I NETWORK [signalProcessingThread] closing listening socket: 7
2019-04-11T06:17:49.789+0000 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2019-04-11T06:17:49.789+0000 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog…
2019-04-11T06:17:49.789+0000 I NETWORK [signalProcessingThread] shutdown: going to close sockets…
2019-04-11T06:17:49.790+0000 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2019-04-11T06:17:49.859+0000 I STORAGE [signalProcessingThread] shutdown: removing fs lock…
2019-04-11T06:17:49.861+0000 I CONTROL [signalProcessingThread] dbexit: rc: 0
vagrant@database:/ mongod 2019-04-11T06:17:59.042+0000 I CONTROL [initandlisten] MongoDB starting : pid=11526 port=27017 dbpath=/data/db 64-bit host=database 2019-04-11T06:17:59.043+0000 I CONTROL [initandlisten] db version v3.2.22 2019-04-11T06:17:59.044+0000 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd 2019-04-11T06:17:59.045+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014 2019-04-11T06:17:59.093+0000 I CONTROL [initandlisten] allocator: tcmalloc vagrant@database:/ mongod --auth
2019-04-11T06:19:05.700+0000 I CONTROL [initandlisten] MongoDB starting : pid=11553 port=27017 dbpath=/data/db 64-bit host=database
2019-04-11T06:19:05.702+0000 I CONTROL [initandlisten] db version v3.2.22
2019-04-11T06:19:05.703+0000 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd
2019-04-11T06:19:05.704+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2019-04-11T06:19:05.705+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-11T06:19:05.705+0000 I CONTROL [initandlisten] modules: enterprise
2019-04-11T06:19:05.705+0000 I CONTROL [initandlisten] build environment:
2019-04-11T06:19:05.705+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2019-04-11T06:19:05.705+0000 I CONTROL [initandlisten] distarch: x86_64
2019-04-11T06:19:05.705+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-04-11T06:19:05.706+0000 I CONTROL [initandlisten] options: { security: { authorization: “enabled” } }
2019-04-11T06:19:05.765+0000 I - [initandlisten] Detected data files in /data/db created by the ‘wiredTiger’ storage engine, so setting the active storage engine to ‘wiredTiger’.
2019-04-11T06:19:05.767+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-11T06:19:06.034+0000 I STORAGE [initandlisten] WiredTiger [1554963546:33968][11553:0x7ff58b942d00], txn-recover: Main recovery loop: starting at 2/4224
2019-04-11T06:19:06.231+0000 I STORAGE [initandlisten] WiredTiger [1554963546:231380][11553:0x7ff58b942d00], txn-recover: Recovering log 2 through 3
2019-04-11T06:19:06.234+0000 I STORAGE [initandlisten] WiredTiger [1554963546:234566][11553:0x7ff58b942d00], txn-recover: Recovering log 3 through 3
2019-04-11T06:19:06.490+0000 I CONTROL [initandlisten]
2019-04-11T06:19:06.491+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-04-11T06:19:06.492+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-04-11T06:19:06.494+0000 I CONTROL [initandlisten]
2019-04-11T06:19:06.495+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-04-11T06:19:06.495+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-04-11T06:19:06.495+0000 I CONTROL [initandlisten]
2019-04-11T06:19:06.501+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory ‘/data/db/diagnostic.data’
2019-04-11T06:19:06.502+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2019-04-11T06:19:06.504+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker

There is nothing wrong with it
Your monod was up and running and waiting for connections

"2019-04-11T06:19:06.502+0000 I NETWORK [initandlisten] waiting for connections on port 27017"

Since you are not using --fork it will run in foreground.Don’t abort it.Just leave that session and open another session and connect to mongo
mongo --port xyz as instructed in your class
If you want to continue working in same session run it in background mode i,e use --fork

1 Like