设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 手机 数据
当前位置: 首页 > 服务器 > 系统 > 正文

详解CentOS 7迅速安装Mongodb

发布时间:2021-10-29 11:30 所属栏目:52 来源:互联网
导读:简介 MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。 环境介绍 操作系统:CentOS 7 CentOS 7 快速安装mongodb 下载、安装 在mongodb的官网可以直接下载到对应的rpm包,然后使用yum进行安装。 CentOS 7 快速安装mongodb yum -y loca
简介
MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。
 
 
环境介绍
操作系统:CentOS 7
 
CentOS 7 快速安装mongodb
下载、安装
在mongodb的官网可以直接下载到对应的rpm包,然后使用yum进行安装。
 
CentOS 7 快速安装mongodb
yum -y localinstall mongodb-org-mongos-4.4.8-1.el7.x86_64.rpm  mongodb-org-server-4.4.8-1.el7.x86_64.rpm  mongodb-org-shell-4.4.8-1.el7.x86_64.rpm 
启动
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目前应用也比较多,维护也相对简单。

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读