MongoDB 4 Quick Start Guide
上QQ阅读APP看书,第一时间看更新

Configure and run MongoDB on RHEL/Fedora/CentOS

If you followed the procedure outlined previously, a configuration file /etc/mongod.conf will have been auto-generated by the installation script. By default, database files will be placed in /var/lib/mongodb and log files in /var/log/mongodb/mongod.log. Here is an example of the auto-generated file for MongoDB v4.0 on CentOS 7:

You are now able to perform these operations:

    
Operation           Command
Start | stop | restart the server           /bin/systemctl start|stop|restart mongod.service
Access MongoDB via the shell (covered later)           mongo --host 127.0.0.1:27017

After starting the service, use the command /bin/systemctl status mongod.service to confirm the status of MongoDB: