Home > AI > Database > MongoDB >

CentOS install mongoDB

$ sudo yum reinstall -y mongodb-org

Step 1: Create a /etc/yum.repos.d/mongodb-org-4.4.repo file so that you can install MongoDB directly using yum:

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

Step 2: install with yum

$ sudo yum install -y mongodb-org

Step 3: However yum upgrades the packages when a newer version becomes available. To prevent unintended upgrades, pin the package. To pin a package, add the following exclude directive to your /etc/yum.conf file:

exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

Step 4: start mongo server

$ sudo service mongod start  

Step 5: relevant files

/var/lib/mongo (the data directory)
/var/log/mongodb (the log directory)

Leave a Reply