centos7安装MongoDB以及配置启动

1.下载MongoDB

使用wget从官网进行下载对应系统的MongoDB版本
选择MongoDB版本页面,官网链接,选择后直接点击Copy link复制压缩包链接

[root@localhost mnt]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.24.tgz

2. 解压并重命名

[root@localhost mnt]# tar -zvf mongodb-linux-x86_64-rhel70-4.4.24.tgz
[root@localhost mnt]# mv mongodb-linux-x86_64-rhel70-4.4.24.tgz mongodb

3. 创建存储文件夹和日志文件

[root@localhost mnt]# mkdir -p data/db/
[root@localhost mnt]# mkdir -p data/logs/
[root@localhost mnt]# touch data/logs/mongologs.log

4.创建并编辑配置文件

[root@localhost mnt]# cd data
[root@localhost mnt]# vim mongodb.conf
#日志存储位置
logpath=/mnt/mongodb/data/logs/mongologs.log
# 以追加方式写入日志
logappend=true
#数据库存储位置
dbpath=/mnt/mongodb/data/db
#默认端口
port=27017
#是否以守护进程方式后台运行
fork=true

5.启动MongoDB服务

[root@localhost /]# /mnt/mongodb/bin/mongod --config /mnt/mongodb/data/mongodb.conf

about to fork child process, waiting until server is ready for connections.
forked process: 10483
child process started

6. 添加配置环境

[root@localhost /]# export PATH =/mnt/mongodb/bin:$PATH

7. 关闭MongoDB服务(需要使用MongoDB时不要关闭)

[root@localhost /]# /mnt/mongodb/bin/mongod --config /mnt/mongodb/data/mongodb.conf

8.进入MongoDB的shell模式

[root@localhost /]# mongo
MongoDB shell version v4.4.24
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("7346e7d7-96ab-4eff-a2ee-2e21c0592536") }
MongoDB server version: 4.4.24
---
The server generated these startup warnings when booting: 
        2023-09-26T20:07:13.604-07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
        2023-09-26T20:07:13.604-07:00: You are running this process as the root user, which is not recommended
        2023-09-26T20:07:13.604-07:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
        2023-09-26T20:07:13.605-07:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
        2023-09-26T20:07:13.605-07:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
        2023-09-26T20:07:13.605-07:00: Soft rlimits too low
        2023-09-26T20:07:13.605-07:00:         currentValue: 1024
        2023-09-26T20:07:13.605-07:00:         recommendedMinimum: 64000
---
> exit
bye
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值