Mongo installation using Tarball method
1. Install wget tool
yum install -y wget
2. Install the prerequisite dependencies for MongoDB community .tgz tarball
sudo yum install libcurl openssl xz-libs
3. Create a directory for downloading required packages
mkdir /mongodb
4. Download the version specific package from Mongo Download Centre
https://www.mongodb.com/try/download/community
cd /mongodb/
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel90-7.0.14.tgz
5. Extract the tar using below command
tar -zxvf package.tgz
6. Ensure the binaries are in a directory listed in your PATH environment variable.
sudo cp /path/to/the/mongodb-directory/bin/* /usr/local/bin/
7. Install mongosh package from the download centre.
https://www.mongodb.com/try/download/shell
wget https://downloads.mongodb.com/compass/mongodb-mongosh-2.3.1.x86_64.rpm
8. Install mongosh using below command
rpm -ivh mongodb-mongosh-2.3.1.x86_64.rpm
9. Create data and log directory using below commands
mkdir -p /mongodb/data
mkdir -p /mongodb/data/log
(Below step needs to be done only in actual work env, not required for learning purpose)
10. By default mongo using on mongod user account, create a mongod user and group, ensure
that mongod belongs to the group then set the owner and group of the directories
sudo chown -R mongod:mongod /mongodb/data
sudo chown -R mongod:mongod /mongodb/data/log
11. Create a mongod.conf file with below basic configuration requirements
vi mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /mongodb/data/log/mongod.log
# Where and how to store data.
storage:
dbPath: /mongodb/data
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,192.168.134.112 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses
or, alternatively, use the net.bindIpAll setting.
#security:
#replication:
12. Start the mongo service using below command
mongod -f /mongodb/mongod.conf &
13. Check if mongo process is running properly
ps -ef | grep mongo
14. Login to mongosh shell to connect to the database.
mongosh
15. Mongo installation using tarball method is complete.
16. Install mongodb tools for db management.
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel93-x86_64-
100.10.0.tgz
17. Untar the file using below command
tar -xvzf mongodb-database-tools-rhel93-x86_64-100.10.0.tgz
18. Copy the binaries from bin folder to /usr/local/bin
cp /mongodb/mongodb-database-tools-rhel93-x86_64-100.10.0/bin/* /usr/local/bin
19. Type mongodump and check if the output is shown as below