# Install MongoDB Community Edition
Modify from MongoDB Help doc Install MongoDB Community Edition on Red Hat Enterprise or CentOS Linux
STEP 1: Configure the package management system(yum).
STEP 2: Install the MongoDB packages and associated tools.
STEP 3: Run MongoDB Community editions
### Configure SELinux Prerequisites
- Set SELinux to permissive mode in /etc/selinux/config by setting the
- You must reboot the system for the changes to take effect.
Data Directories and Permissions
WARNING >On RHEL 7.0, if you change the data path, the default SELinux policies will prevent mongod from having write access on the new data path if you do not change the security context.
The MongoDB instance stores its data files in /var/lib/mongo and its log files in /var/log/mongodb by default, and runs using the mongod user account. You can specify alternate log and data file directories in /etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.
If you change the user that runs the MongoDB process, you must modify the access control rights to the /var/lib/mongo and /var/log/mongodb directories to give this user access to these directories.
STEP 4: Procedure
-1 Start MongoDB. You can start the mongod process by issuing the following command:
-2 Verify that MongoDB has started successfully You can verify that the mongod process has started successfully by checking the contents of the log file at /var/log/mongodb/mongod.log for a line reading
[initandlisten] waiting for connections on port
You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:
-3 Stop MongoDB.
As needed, you can stop the mongod process by issuing the following command:
-4 Restart MongoDB. You can restart the mongod process by issuing the following command:
You can follow the state of the process for errors or important messages by watching the output in the /var/log/mongodb/mongod.log file.
-5 Begin using MongoDB. To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.
Before deploying MongoDB in a production environment, consider the Production Notes document.
Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.
- errno:13 Permission denied Is a mongod instance already running service mongod stop ls -la to see what group & owner mongodb assigned to /var/lib/mongodb and I changed the /data/mongo with chown and chgrp to match. chown -R mongod:mongod /data/db Then I ran service mongodb start and waited about a minute. If you try to connect to 27017 immediately you won’t be able to
- Address already in use for socket:0.0.0.0:27017
You should see somethin that looks like this User 31936 0.5 0.4 2719784 35624 ?? S 7:34pm 0:09.98 mongod User 31945 0.0 0.0 2423368 184 s000 R+ 8:24pm 0:00.00 grep mongo Now enter the kill command for the mongod instance(31936 in this case):
- How to avoid transparent_hugepage/defrag warning from mongodb
STEP1. Open /etc/init.d/mongod file STEP2. Add script to the start fuction Here are the lines to add to /etc/init.d/mongod:
STEP3. restart mongod
WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
STEP1. Open vim /etc/security/limits.conf STEP2. Add script to the start fuction Here are the lines to add to /etc/security/limits.conf
STEP3. restart mongod
- Other client connection mongo Server is CentOS7 STEP1. firewall to and port
STEP2. Then remember to reload the firewall for changes to take effect.
STEP3. Check file /etc/mongo.conf
If don’t like this config ,Change it and restart mongod