centos6.x Installing MongoDB

Source: Internet
Author: User

1, look at the Linux version, the reason to view the Linux version, because Centos7 and the previous version of the firewall is not the same, after the installation of MongoDB, the need to turn off the firewall (or other methods, professional OPS personnel use, we here for the simple, can be accessed directly by other computers,

Cat/etc/redhat-release

2. The following steps are fully followed by the MongoDB official documentation:

Configure the Package management system (yum).

Create A/etc/yum.repos.d/mongodb-org-3.2.repo file So, can install MongoDB directly, using Yum.

Touch/etc/yum.repos.d/mongodb-org-3.2.repo #新建文件

Vi/etc/yum.repos.d/mongodb-org-3.2.repo #编辑文件

Run the above command, open the file, press the keyboard i key, edit this file, directly copy the following files with the file, and then press ESC, and then press shift+: The key is to shoot a colon, and then press the X key, save, not familiar with the VI command of children's shoes to see this, familiar drifting over

[mongodb-org-3.2]

Name=mongodb Repository

baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/

Gpgcheck=1

Enabled=1

Gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

3, install the latest version of MongoDB

To install the latest stable version of MongoDB, issue the following command:

sudo yum install-y mongodb-org

4. Start MongoDB

You can start the mongod process by issuing the following command:

sudo service Mongod start

sudo service mongod status # view MongoDB status

5. Set Boot start

You can optionally ensure that MongoDB would start following a system reboot by issuing the following command:

sudo chkconfig mongod on

6. Stop MongoDB

Stop MongoDB.

As needed, you can stop the mongod process by issuing the following command:

sudo service Mongod stop

7. Restart MongoDB

Restart MongoDB.

You can restart the mongod process by issuing the following command:

sudo service mongod restart

8, set up LAN other computers can access (focus)

sudo vi/etc/mongod.conf

Find this section and change the default 127.0.0.1 to 0.0.0.0

Net
port:27017
bindip:0.0.0.0 # Listen to local interface only, comment to Listen on all interfaces.

9. Turn off the firewall

sudo service iptables stop #即时生效, will fail after reboot, firewall is turned on by default

sudo chkconfig iptables off #防火墙关闭, also off after reboot

sudo service iptables start # Open Firewall

sudo chkconfig iptables on #防火墙开启

sudo service iptables status #查看防火墙状态

10, the official website has such a paragraph:

To configure SELinux, administrators has the three options:

    • If SELinux is in enforcing mode, enable access to the relevant ports that the MongoDB deployment would use (e.g. 27017). See Default MongoDB Port for more information on MongoDB ' s default ports. For default settings, this can is accomplished by running

Semanage port-a-t mongod_port_t-p TCP 27017

After I test, no need to ignore, can be ignored, if some students perform this command prompt:

semanage SELinux Command not Found

, you can follow these steps to install Semanage, run any of the following two commands,

 yum provides /usr/sbin/semanage
Or:
 yum whatprovides /usr/sbin/semanage

After execution, output something like this:

Loaded Plugins:rhnplugin

Policycoreutils-python-2.0.83-19.8.el6_0.x86_64:selinux Policy Core Python utilities

Repo:rhel-x86_64-server-6

Matched from:

Filename:/usr/sbin/semanage

Policycoreutils-python-2.0.83-19.1.el6.x86_64:selinux Policy Core Python utilities

Repo:rhel-x86_64-server-6

Matched from:

Filename:/usr/sbin/semanage

Then execute the following command:

yum -y install policycoreutils-python

centos6.x Installing MongoDB

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.