How to run mongodb on linux,ubuntu as process

How to run mongodb on linux,ubuntu as process

Supposed that mongodb is installed and configured, and now you want to Start mongod as a Daemon:


ubuntu@ip-127-0-0-1:/var/lib/mongodb$ sudo mongod --fork --logpath /var/log/mongodb.log --dbpath /var/lib/mongodb
about to fork child process, waiting until server is ready for connections.
forked process: 21293
child process started successfully, parent exiting
ubuntu@ip-127-0-0-1:/var/lib/mongodb$ 

Now, how to test if mongodb has started really as daemon;


ubuntu@ip-127-0-0-1:/var/lib/mongodb$ mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
Server has startup warnings: 
2019-10-19T07:49:38.302+0000 I STORAGE  [initandlisten] 
2019-10-19T07:49:38.303+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-10-19T07:49:38.303+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-10-19T07:49:38.571+0000 I CONTROL  [initandlisten] 
> show dbs
admin      0.000GB
UKgoodbye  0.002GB
local      0.000GB
> 

Mongodb is ready!