Linux安装mongodb详细步骤

1.安装centos系统

没有安装的小伙伴可以看一下 centos详细安装步骤

2.下载mongodb-linux版安装包

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.1.tgz

3.下载完成之后放到你的linux文件下进行解压

 tar -zxvf mongodb-linux-x86_64-rhel70-4.0.1.tgz -C /opt/

可以修改一下安装夹的名称

mv mongodb-linux-x86_64-rhel70-4.0.0 mongodb

4.创建数据存储目录和日志文件目录

mkdir -p /opt/mongodb/data/db 
mkdir -p /opt/mongodb/logs

5、编辑MongoDB启动配置文件

在/opt/mongodb/bin文件夹下创建一个mongodb.conf文件,手动创建并编辑。

vim /opt/mongodb/bin/mongodb.conf

添加上下面配置

dbpath = /opt/mongodb/data/db //数据存储目录 
logpath =/opt/mongodb/logs/mongodb.log //日志文件目录 
fork = true //后台运行 
auth=true 
bind_ip=0.0.0.0

6、添加到 PATH 路径

vim /etc/profile 
export MONGODB_HOME=/opt/mongodb
export PATH=$PATH:$MONGODB_HOME/bin
source /etc/profile //重新加载环境变量 

7、启动MongoDB

进入MongoDB启动

cd /opt/mongodb/bin 
mongod -f mongodb.conf

一般这里会报错

2021-07-29T14:31:33.220+0800 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
about to fork child process, waiting until server is ready for connections.
forked process: 16751
ERROR: child process failed, exited with error number 1
To see additional information in this output, start without the "--fork" option.

解决方案:
指向data文件和log日志文件的问题 运行下边脚本就OK

/opt/mongodb/bin/mongod --dbpath /opt/mongodb/data/db/ --logpath /opt/mongodb/log/mongod.log --fork

然后进入

cd /opt/mongodb/bin 

运行命令

./mongo

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值