详解CentOS 7快速安装Mongodb
发布时间:2025-05-16 11:18:42
作者:益华网络
来源:undefined
浏览量(2)
点赞(3)
摘要:简介 MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。 环境介绍 操作系统:CentOS 7 下载、安装 在mongodb的官网可以直接下载到对应的rpm包,然后使用yum进行安装。 yum-ylocalinstall&
简介
MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。

环境介绍
操作系统:CentOS 7

下载、安装
在mongodb的官网可以直接下载到对应的rpm包,然后使用yum进行安装。

启动
systemctl enable mongod systemctl start mongod查看启动文件
systemctl cat mongod [Unit] Description=MongoDB Database Server Documentation=https://docs.mongodb.org/manual After=network-online.target Wants=network-online.target [Service] User=mongod Group=mongod Environment="OPTIONS=-f /etc/mongod.conf" EnvironmentFile=-/etc/sysconfig/mongod ExecStart=/usr/bin/mongod $OPTIONS ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb PermissionsStartOnly=true PIDFile=/var/run/mongodb/mongod.pid Type=forking # file size LimitFSIZE=infinity # cpu time LimitCPU=infinity # virtual memory size LimitAS=infinity # open files LimitNOFILE=64000 # processes/threads LimitNPROC=64000 # locked memory LimitMEMLOCK=infinity # total threads (user+kernel) TasksMax=infinity TasksAccounting=false # Recommended limits for mongod as specified in # https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings [Install] WantedBy=multi-user.target可以看出数据目录文件/var/run/mongodb,配置文件是/etc/mongod.conf
设置密码验证
默认是没有设置密码,可以直接输入mongo命令就可以直接登陆shell进行操作。
mongo创建管理用户
use admin db.createUser({user:"root",pwd:"opcai.TOP",roles:["root"]})修改配置文件
vim /etc/mongod.conf配置security启用验证。
... security: authorization: enabled ...重启服务生效
systemctl restart mongod总结
Mongodb目前应用也比较多,维护也相对简单。
扫一扫,关注我们
声明:本文由【益华网络】编辑上传发布,转载此文章须经作者同意,并请附上出处【益华网络】及本页链接。如内容、图片有任何版权问题,请联系我们进行处理。
3