Loading

MongoDB--安装部署

Linux环境下安装MongoDB

说明:这里使用软件版本为:mongodb-linux-x86_64-rhel62-3.2.8.tgz

 

官网下载

本文所使用的安装包下载  提取码:zj43

具体步骤如下:

1)上传软件包到服务器并进行解压

[root@srtAdmin ~]# tar xvzf mongodb-linux-x86_64-rhel62-3.2.8.tgz
[root@srtAdmin ~]# mv mongodb-linux-x86_64-rhel62-3.2.8 /usr/local/mongodb

2)创建配置相关的目录及配置文件

[root@srtAdmin ~]#  cd /usr/local/mongodb/
[root@srtAdmin /usr/local/mongodb]# ll
total 100
drwxr-xr-x 2 root root  4096 Nov 13 16:36 bin
-rw-r--r-- 1 root root 34520 Jul 13  2016 GNU-AGPL-3.0
-rw-r--r-- 1 root root 16726 Jul 13  2016 MPL-2
-rw-r--r-- 1 root root  1359 Jul 13  2016 README
-rw-r--r-- 1 root root 35910 Jul 13  2016 THIRD-PARTY-NOTICES
[root@srtAdmin /usr/local/mongodb]# mkdir {data,conf,log}
[root@srtAdmin /usr/local/mongodb]# ls
bin  conf  data  GNU-AGPL-3.0  log  MPL-2  README  THIRD-PARTY-NOTICES

[root@srtAdmin /usr/local/mongodb]# vim conf/mongodb.conf    #编辑配置文件
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/log/mongodb.log
bind_ip=0.0.0.0
port=27017
logappend=1
fork=1

3)启动mongodb

[root@srtAdmin /usr/local/mongodb]# cp bin/mongod /usr/bin/    #将命令copy到/usr/bin下,方便使用
[root@srtAdmin /usr/local/mongodb]# mongod --config /usr/local/mongodb/conf/mongodb.conf     #启动mongod
about to fork child process, waiting until server is ready for connections.
forked process: 28531
child process started successfully, parent exiting

[root@srtAdmin /usr/local/mongodb]# netstat -nlutp |grep 27017
tcp        0      0 0.0.0.0:27017               0.0.0.0:*                   LISTEN      28531/mongod

[root@srtAdmin /usr/local/mongodb]# echo "mongod --config /usr/local/mongodb/conf/mongodb.conf    #启动MongoDB" >> /etc/rc.local    #写入rc.local文件开机自启动

 

 

 

 

 

 

 

 

 

posted @ 2019-11-13 17:00  别来无恙-  阅读(496)  评论(0编辑  收藏  举报