Installing MongoDB database under CentOS 6.5_x64

Source: Internet
Author: User

1. Download MongoDB

Official website: https://www.mongodb.org/downloads

Specific Link: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.10.tgz

Download the file to the specified location, for example, my downloaded file is placed in the/USR/LOCAL/SRC

2. Installing MongoDB

Command-line window to execute the

$> cd/usr/local/src/   #定位到文件目录 $> tar zxvf mongodb-linux-x86_64-3.2.10.tgz  #解压 $> mv MongoDB -linux-x86_64-3.2.  /usr/local/mongodb  #移动解压文件夹到上层的mongodb目录

#接着创建数据库配置相关的一些目录, it's going to be used when it starts.
$> mkdir-p/data/mongodb/data/#创建MongoDB数据库存放路径 $> mkdir-p/data/mongodb/log/#创建MongoDB数据库日志存放路径
3. Start MongoDB
#启动MongoDB
27017 --fork--dbpath=/data/mongodb/data/--logpath=/data/mongodb/log/mongodb.log--logappend

$> NETSTAT-NTPL #查看MongoDB是否启动

Resolution: Mongod--dbpath command is to create a database file storage location, the start of the MongoDB service needs to determine the location of the database files, or the system will not be automatically created, startup will not be successful.

--logpath indicates the path where the log file is stored

--logappend indicates that the log file is written in append mode

#其它操作 $> cd/usr/local/mongodb/bin/$>./MONGO  #进入MongoDB数据库控制台 $> Use Admin  #进入admin数据库 $> db.shutdownserver () #关闭MongoDB数据库 $> Exit #退出
4. Database Configuration

#下面配置数据库文件

 $> cd/usr/local/mongodb/ #进入MongoDB安装目录 $> VI /usr/local/mongodb/< Span style= "color: #000000;" >mongodb.conf #编辑port  =27017   #端口号dbpath  =/data/mongodb/data/ #数据库路径logpath  =/data/mongodb/log/mongodb.log #日志输出文件路径pidfilepath  =/usr/local/mongodb/mongo.pidfork  = true   #设置后台运行logappend  =true   #日志输出方式shardsvr  =true  directoryperdb  =true   #auth  =true   #开启认证: Wq  #保存退出 

Start MongoDB as a configuration file
$>/usr/local/mongodb/bin/mongod--config/usr/local/mongodb/mongodb.conf

#远程访问防火墙开放27017端口
Iptables-a input-p tcp-m State--state new-m TCP--dport 27017-j ACCEPT

Installing MongoDB database under CentOS 6.5_x64

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.