详解CentOS 7快速安装Mongodb

运维 系统运维 MongoDB
MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。Mongodb目前应用也比较多,维护也相对简单。

简介

MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。

[[416732]]

环境介绍

操作系统:CentOS 7

CentOS 7 快速安装mongodb

下载、安装

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

CentOS 7 快速安装mongodb
  1. 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 

启动

  1. systemctl enable mongod 
  2. systemctl start mongod 

 查看启动文件

  1. systemctl cat mongod 
  1. [Unit] 
  2. Description=MongoDB Database Server 
  3. Documentation=https://docs.mongodb.org/manual 
  4. After=network-online.target 
  5. Wants=network-online.target 
  6.  
  7. [Service] 
  8. User=mongod 
  9. Group=mongod 
  10. Environment="OPTIONS=-f /etc/mongod.conf" 
  11. EnvironmentFile=-/etc/sysconfig/mongod 
  12. ExecStart=/usr/bin/mongod $OPTIONS 
  13. ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb 
  14. ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb 
  15. ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb 
  16. PermissionsStartOnly=true 
  17. PIDFile=/var/run/mongodb/mongod.pid 
  18. Type=forking 
  19. # file size 
  20. LimitFSIZE=infinity 
  21. # cpu time 
  22. LimitCPU=infinity 
  23. # virtual memory size 
  24. LimitAS=infinity 
  25. open files 
  26. LimitNOFILE=64000 
  27. # processes/threads 
  28. LimitNPROC=64000 
  29. # locked memory 
  30. LimitMEMLOCK=infinity 
  31. # total threads (user+kernel) 
  32. TasksMax=infinity 
  33. TasksAccounting=false 
  34. # Recommended limits for mongod as specified in 
  35. # https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings 
  36.  
  37. [Install] 
  38. WantedBy=multi-user.target 

可以看出数据目录文件/var/run/mongodb,配置文件是/etc/mongod.conf

设置密码验证

默认是没有设置密码,可以直接输入mongo命令就可以直接登陆shell进行操作。

  1. mongo 

创建管理用户

  1. use admin 
  2. db.createUser({user:"root",pwd:"opcai.TOP",roles:["root"]}) 

修改配置文件

  1. vim /etc/mongod.conf 

配置security启用验证。

  1. ... 
  2. security: 
  3.   authorization: enabled 
  4. ... 

重启服务生效

  1. systemctl restart mongod 

总结

Mongodb目前应用也比较多,维护也相对简单。

 

责任编辑:姜华 来源: 今日头条
相关推荐

2020-11-06 08:05:05

CentOS

2010-03-30 10:58:29

2015-02-03 03:00:51

CentOSJetty

2010-03-31 13:04:37

CentOS安装

2014-12-01 11:27:54

CentOS 7Docker

2023-08-28 09:14:20

ScrapyPython

2024-03-01 20:28:54

CentOS 7文件操作search

2021-06-29 12:10:48

CentOSMySQL工具

2009-12-08 13:19:13

安装Windows 7

2017-05-03 14:00:00

LinuxCentOSElastic Sta

2021-05-12 07:42:41

CentOS7Python3系统

2020-08-28 11:20:01

CentOS7RocketMQ 4.运维

2022-08-03 08:03:01

OracleRPM形式

2021-01-04 08:15:16

CentOS 7Python3.9Python

2019-04-08 09:00:00

CentOS 7ElasticsearLinux

2012-07-11 17:09:34

Windows 7CentOS

2010-03-25 14:42:33

2009-09-24 10:10:07

Visual Stud

2011-03-31 10:21:52

CentosCactishell

2019-10-14 11:20:27

centos7Centos 6tmp
点赞
收藏

51CTO技术栈公众号