Configure the package management system (yum
).
Create a /etc/yum.repos.d/mongodb-org-4.0.repo
file so that you can install MongoDB directly using yum
:
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
Install the MongoDB packages
sudo yum install -y mongodb-org
Start MongoDBsudo service mongod start
Verify that MongoDB has started successfully
[initandlisten] waiting for connections on port where You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:copycopied sudo chkconfig mongod on As needed, you can stop the sudo service mongod stop You can restart the sudo service mongod restart You can follow the state of the process for errors or important messages by watching the output in the <port>
is the port configured in /etc/mongod.conf
, 27017
by default.Stop MongoDB.
mongod
process by issuing the following command:copycopiedRestart MongoDB.
mongod
process by issuing the following command:copycopied/var/log/mongodb/mongod.log
file.