CentOS6.5 Installing MongoDB

Source: Internet
Author: User
Tags mkdir mongodb port number

1 , download MongoDB

Http://www.mongodb.org/downloads

Mongodb-linux-x86_64-3.2.8.tgz #目前最新版

2 , recommended to close SELinux

[[Email protected] ~] # Vi/etc/selinux/config SELINUX=disabled

3 , shutting down the firewall, or adding MongoDB ports

#清空防火墙

[[Email protected] ~] # iptables-f

#增加端口

[[Email protected] ~] # vi/etc/sysconfig/iptables-A rh-firewall-l-input-p tcp-m TCP--dport 27017 (MongoDB port number)-j ACCEPT    # allows 27017 ports to pass through the firewall [root@mycentos ~]#  /etc/init.d/iptables Restart    #重启防火墙使配置生效 

4 , unzip MongoDB

[[email protected] mypackages] # tar xzf mongodb-linux-x86_64-3.2.8.tgz [Root@mycentos mypackages] # MV Mongodb-linux-x86_64-3.2.8/usr/local/mongodb

5 , creating database and log storage paths

[[Email protected] ~] # mkdir-p/data/mongodb_data [root@mycentos ~] # mkdir-p/data/mongodb_log

6 , start MongoDB

[[Email protected] ~] # /usr/local/mongodb/bin/mongod--port 27017--fork--dbpath=/data/mongodb_data/--logpath=/data/mongodb_log/ Mongodb.log--logappend[root@mycentos Mongodb_log]#  netstat-lanp | grep 27017    # See if MongoDB started successfully

7 , for MongoDB console

[[Email protected] ~] # cd/usr/local/mongodb/bin/ [Root@mycentos bin] # ./mongo  #进入MongoDB数据库控制台> Use admin  # go to admin database > Db.shutdownserver ()  # close MongoDB database # exit

8 , then make a configuration file

[[Email protected] ~]#Cd/usr/local/mongodb[Root@mycentos MongoDB]#VI mongodb.confPort=27017#Port numberDBPath=/data/mongodb_data/#Database PathLogPath=/data/mongodb_log/mongodb.log#log output file pathPidfilepath=/usr/local/mongodb/mongo.pidfork=true            #set up background runLogappend=true       #Log Output Mode: Wq#Save Exit

The next time you start:

[[email protected] MongoDB] # ./bin/mongod-f mongodb.conf        #启动MongoDB[root@mycentos MongoDB]#  ./bin/ MONGO 127.0.0.1:27017/admin--eval "Db.shutdownserver ()"  #关闭MongoDB

9 , set boot boot

[[Email protected] ~]#Vi/etc/rc.d/init.d/mongodUlimit-shn 655350#!/bin/sh#chkconfig:-#Description:mongod Case $ inchstart)/usr/local/mongodb/bin/mongod--maxconns 20000--config/usr/local/mongodb/mongodb.conf;; Stop)/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin--eval"Db.shutdownserver ()";; Status)/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin--eval"db.stats ()";; Esac:wq!#Save Exit

[[Email protected] ~] # chmod +x/etc/rc.d/init.d/mongod  #添加脚本执行权限[[email protected] ~]#  chkconfig mongod on  # Set boot start [[email protected] ~]#  service mongod start #启动MongoDB

Ten , set environment variables

[[Email protected] ~] # vi/etc/profile  #添加环境变量 export PATH=$PATH:/usr/local/mongodb/bin:wq#  Save Exit [root@mycentos ~]#  source/etc/profile  #使配置立即生效 [root @mycentos ~]#  MONGO  #进入MongoDB控制台, you can use the MongoDB command directly. 

CentOS6.5 Installing MongoDB

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.