Installing MongoDB with Yum in CentOS

Source: Internet
Author: User

The following is an example of installing mongodb3.x. MongoDB formally provides PACKGE installation support, which includes the following packages in their warehouses:
Mongodb-org: This package will automatically install all of the following component packages
Mongodb-org-server: Contains Mongod, and related configuration and initial scripts
Mongodb-org-mongos: Includes MONGOs
Mongodb-org-shell: Contains MONGO scripts
Mongodb-org-tools: Contains the following MongoDB tools: Mongoimport Bsondump,mongodump,mongoexport,mongofiles,mongoplog,mongoperf, Mongorestore,mongostat and Mongotop.

1. Configure Yum

Create a yum warehouse file repo

Vi/etc/yum.repos.d/mongodb-org-3.2.repo1

The contents of the repo file are as follows:

[MongoDB]
Name=mongodb Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

2. Installing MongoDB packages and related tools

To install all MONGODB components:

Yum Install-y mongodb-org1

You can also install the specified MongoDB components:

Yum install-y mongodb-org-3.2.5 mongodb-org-server-3.2.5 mongodb-org-shell-3.2.5 mongodb-org-mongos-3.2.5 mongodb-org-tools-3.2.51

After the installation is complete, to prevent accidental escalation, you can add the following configuration in/etc/yum.conf to prevent accidental escalation:

Exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools1
3. Configure SELinux

There are 2 ways to view the SELinux status as follows:
Command 1:

/usr/sbin/sestatus-v 1

Command 2:

Getenforce1

There are 2 ways to turn off SELinux:
1. Temporarily shut down (without restarting the machine):
Command:

Setenforce 0 1

The above command sets SELinux to become permissive mode
Setenforce 1 setting SELinux to become enforcing mode

2. Modify the configuration file to restart the machine:
Modify the/etc/selinux/config file
Change selinux=enforcing to selinux=disabled or permissive
Restart the machine

4. Modify the data storage location

MongoDB defaults to prevent data files from/var/lib/mongo, and log files are stored in/var/log/mongodb. Modify the Systemlog.path and Storage.dbpath add information in the configuration file/etc/mongd.conf.

5. Start MongoDB

To start the MONGO service:

Systemctl Start Mongod1

Or

Service Mongod Start1

View the/var/log/mongdb/mongd.log file to see if there is a line below the log if there is a MONGO boot success.
[Initandlisten] Waiting for connections on port

The port number is configured in/etc/mongd.conf and defaults to 27017.

To configure boot boot:

Systemctl Enable Mongod1

Or

Chkconfig Mongod On1
6. Stop restarting MongoDB

To stop the MongoDB service:

Systemctl Stop Mongod1

Or

Service Mongod STOP1

To restart the MongoDB service:

Systemctl Restart Mongod1

Or

Service Mongod Restart1
7. Uninstalling MongoDB

To stop the MongoDB service:

Systemctl Stop Mongod1

Or

Service Mongod STOP1

To delete a previously installed MONGODB related package:

Yum Erase $ (rpm-qa | grep mongodb-org) 1

To delete a data folder:

sudo rm-r/var/log/mongodbsudo rm-r/var/lib/mongo12


Installing MongoDB with Yum in CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.