非root用户安装MongoDB
在实验室的服务器上安装MongoDB,然而没有sudo权限,只能安装已编译的程序了。 步骤如下:
去官网查看下载并解压最新版4.0.0的MongoDB包
1
2$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-4.0.0.tgz
$ tar -zxvf mongodb-linux-x86_64-ubuntu1404-4.0.0.tgz官网说需要安装OpenSSL >The binary of this version has been compiled with SSL enabled and dynamically linked. This requires that SSL libraries be installed separately. See here for more information on installing OpenSSL. 安装方法参考:这个
将路径添加到PATH
1
2$ export PATH="/path/to/dir/:$PATH"
$ source ~/.bashrc在合适位置新建
mongod.conf
配置文件,主要是设置db和log文件夹,以及fork
(后台运行),参考配置:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /home/duhaihua/mongo/db
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /home/duhaihua/mongo/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
fork: true
# security.
security:
authorization: enabled启动mongod服务
可以用以下命令查看mongod是否已启动:1
mongod --config ~/mongo/mongod.conf
1
ps -ef|grep mogod
打开mongo shell,使用mongoDB
1
mongo