MongoDB安装手册(rpm)

安装包rpm下载地址

必要条件

关闭SELinux

# 状态查看
sestatus

# 关闭
setenforce 0

安装

上传rpm包到服务器目录

yum install ./*.rpm

配置

  • 配置文件目录:/etc/mongod.conf

  • 配置文件

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
  # default port 27017
  port: 57017
  bindIp: 0.0.0.0

启动服务

# 启动服务
systemctl start mongod

# 查看服务状态
systemctl status mongod

添加用户,开启连接验证

添加用户

# 连接
mongo --host 127.0.0.1 --port 57017

# 切换admin
use admin

# 显示用户
show users

# 添加用户,user:用户,pwd:密码,roles:角色
db.createUser({user:"vitas",pwd:"A1B2C3D4E5F6",roles:["root"]})

# 退出连接
exit
示例

在这里插入图片描述

添加配置

  • 配置文件目录:/etc/mongod.conf
  • 添加配置
security:
  authorization: enabled

重启服务

systemctl restart mongod

连接验证

mongo --host 127.0.0.1 --port 57017 -u vitas -p A1B2C3D4E5F6

附录

系统环境:

Operating System: CentOS Linux 7 (Core)
System Version: 7.6.1810
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.62.1.el7.x86_64
Architecture: x86-64

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值