MongoDB 提供了 linux 各发行版本 64 位的安装包,你可以在官网下载安装包。
官网下载: https://www.mongodb.com/download-center/community\"在这里插入图片描述\"
下载完安装包,并解压 tgz(以下演示的是 64 位 Linux上的安装) 。

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.4.tgz    # 下载
tar -zxvf mongodb-linux-x86_64-rhel70-4.0.4.tgz    # 解压
mv  mongodb-linux-x86_64-3.0.6/ /usr/local/mongodb       # 将解压包拷贝到指定目录

配置环境变量

vi /etc/profile
增加
export MONGODB_HOME=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.4                                                                        
export PATH=$PATH:$MONGODB_HOME/bin

刷新配置

source /etc/profile

新建配置相关文件

mongodb-linux-x86_64-rhel70-4.0.4目录下

mkdir -p /logs
mkdir -p /data/db
touch /bin/mongod.conf

修改配置文件

# mongod.conf

# for documentation of all options,see:
# http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.4/logs/mongodb.log

# where and how to store data.
storage:
  dbPath: /usr/local/mongodb/mongodb-linux-x86_64-rhel70-4.0.4/data/db
  journal:
    enabled: true

# how the process runs
processManagement:
  fork: true


# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

启动

./mongod -f mongodb.conf 或
./bin/mongod --config conf/mongod.conf

参考文献

https://blog.csdn.net/hwm_life/article/details/82317750
http://www.runoob.com/mongodb/mongodb-linux-install.html

收藏 打印