Linux Platform MongoDB Database installation

Source: Internet
Author: User

With Ruiy brother to play with it;

< One, initialize play turn mongodb>

1, turn off SELinux (Ruiy, according to experience, Red Hat's selinux erection is a mistake, remember that no matter what the structure of the first to shut down is it);

2, set iptables release port=27017;

3, download the software media wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.0.tgz;

4, installation;

Tar zxvf mongodb-linux-x86_64-2.6.0.tgz

MV Mongodb-linux-x86_64-2.6.0/usr/local/mongodb

Mkdir-p/home/data/mongodb/mongodb_data/

Mkdir-p/home/data/mongodb/mongodb_log/

5, command line start;

/usr/local/mongodb/bin/mongod--port 27017 --fork --dbpath=/home/data/mongodb/mongodb_data/-- Logpath=/home/data/mongodb/mongodb_log/mongodb.log--logappend

6, view 27017 port;

Netstat-nalp|grep 27017

7, into the human mongodb shell console;

cd/usr/local/mongodb/bin/

8. View available databases and switch databases (initialize with 2 databases local/admin) show DBS && use admin;

9,mongodb the shell console to shut down the database;

Db.shutdownserver ()

< Two, set up Database >

1. Setting up a MongoDB configuration file

Emacs/usr/local/mongodb/mongodb.conf

The contents are as follows

2. Start MongoDB based on the new configuration file

cd/usr/local/mongodb/bin/

./mongod--config/usr/local/mongodb/mongodb.conf

3, command line shutdown database

./mongo 127.0.0.1:27017/admin--eval "Db.shutdownserver ()"

4. Configure the MongoDB startup script

Vi/etc/rc.d/init.d/mongod

The contents are as follows

5, add Execute permissions

chmod +x/etc/rc.d/init.d/mongod

6, set boot Chkconfig mongod on

7, service-based MongoDB services start

Service Mongod Start

8, setting the MONGODB environment variable

Vi/etc/profile

Join

Export path= $PATH:/usr/local/mongodb/bin

9,source

Source/etc/profile

10,mongo in-person shell console

Simple test

As this article MongoDB can be done, please continue to focus on the HA environment is coming out;

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.