MongoDB Install
Docs
MongoDB installUbuntu
install Docs
add key
- Create a list file for MongoDB '/etc/apt/sources.list.d/mongodb-org-4.4.list'
- Reload local package database
- Install the MongoDB packages
- To prevent unintended upgrades, you can pin the package at the currently installed version
Redhat/ centos
-install Docs
Configure Package Management System
Create a /etc/yum.repos.d/mongodb-org-4.0.repo file with following content so that you can install MongoDB directly using yum
Install the MongoDB packages
To install the latest stable version of MongoDB, issue the following command:
Note : mongodb-org is a meta package
Exclude MongoDB packages
(from auto update)
You can specify any available version of MongoDB. 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:
Settings
Increase user limit settings
To increase processes limit
(for mongod server)
Go to following folder
cd /etc/security/limits.dCreate following new file
cat > 99-mongodb-nproc.confAdd following content (soft is like >= lower limit, hard is upper limit)
mongod soft nofile 64000mongod hard nofile 64000mongod soft nproc 64000mongod hard nproc 64000Note : these limits.d settings will override ulimit settings
For example in limits.d, there is one more file 20-nproc.conf (which set process limit for user accounts), so similar syntax for mongod also
* soft nproc 4096root soft nproc unlimited
To increase user resources limit
To check per-user limitations for various resources
To modify paticular user limit settings (say open files)
Run following for recommended ulimit Settings
#file sizeulimit -f unlimited#cpu timeulimit -t unlimited#virtual memoryulimit -v unlimited#locked-in-memory sizeulimit -l unlimited#memory sizeulimit -m unlimited#open filesulimit -n 64000#processes/threadsulimit -u 64000
Always remember to restart your mongod and mongos instances after changing the ulimit settings to ensure that the changes take effect.
To change Default Directories
Edit the the configuration file /etc/mongod.conf
storage.dbPath=/some/data/directorysystemLog.path=/some/log/directory/mongod.log
Config file options Docs
Note: (mongod user is created by MONGO DB installation, this user must have access to the path defined by you for storage)
- configured db path folder must exist
- also configure port & ip address
Start/ stop MongoDB
Verify that MongoDB has started successfully
Optionally ensure that MongoDB will start following a system reboot by issuing the following command:
Stop MongoDB
Restart MongoDB