文档章节

how to install mongodb in centos7

qwfys
 qwfys
发布于 07/14 17:48
字数 1220
阅读 58
收藏 0

行业解决方案、产品招募中!想赚钱就来传!>>>

[root@xtwj88 ~]# cat /etc/yum.repos.d/mongodb-org-4.2.repo 
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
[root@xtwj88 ~]# dnf list |grep mongodb
collectd-write_mongodb.x86_64                                       5.8.1-1.el7                                                   epel            
mongocli.x86_64                                                     1.1.0-1                                                       mongodb-org-4.2 
mongodb.x86_64                                                      2.6.12-6.el7                                                  epel            
mongodb-org.x86_64                                                  4.2.8-1.el7                                                   mongodb-org-4.2 
mongodb-org-mongos.x86_64                                           4.2.8-1.el7                                                   mongodb-org-4.2 
mongodb-org-server.x86_64                                           4.2.8-1.el7                                                   mongodb-org-4.2 
mongodb-org-shell.x86_64                                            4.2.8-1.el7                                                   mongodb-org-4.2 
mongodb-org-tools.x86_64                                            4.2.8-1.el7                                                   mongodb-org-4.2 
mongodb-server.x86_64                                               2.6.12-6.el7                                                  epel            
mongodb-test.x86_64                                                 2.6.12-6.el7                                                  epel            
nodejs-mongodb.noarch                                               1.4.7-1.el7                                                   epel            
php-mongodb.noarch                                                  1.0.4-1.el7                                                   epel            
php-pecl-mongodb.x86_64                                             1.1.10-1.el7                                                  epel            
poco-mongodb.x86_64                                                 1.6.1-3.el7                                                   epel            
syslog-ng-mongodb.x86_64                                            3.5.6-3.el7                                                   epel            
[root@xtwj88 ~]# dnf install mongodb-org
Extra Packages for Enterprise Linux 7 - x86_64                                                                                                                                                                0.0  B/s |   0  B     00:00    
Docker CE Stable - x86_64                                                                                                                                                                                     0.0  B/s |   0  B     00:00    
Kubernetes                                                                                                                                                                                                    0.0  B/s |   0  B     00:00    
CentOS-7 - Base                                                                                                                                                                                               0.0  B/s |   0  B     00:00    
CentOS-7 - Updates                                                                                                                                                                                            0.0  B/s |   0  B     00:00    
CentOS-7 - Extras                                                                                                                                                                                             0.0  B/s |   0  B     00:00    
Dependencies resolved.
==============================================================================================================================================================================================================================================
 Package                                                        Arch                                               Version                                                  Repository                                                   Size
==============================================================================================================================================================================================================================================
Installing:
 mongodb-org                                                    x86_64                                             4.2.8-1.el7                                              mongodb-org-4.2                                             5.9 k
Installing dependencies:
 mongodb-org-mongos                                             x86_64                                             4.2.8-1.el7                                              mongodb-org-4.2                                              15 M
 mongodb-org-server                                             x86_64                                             4.2.8-1.el7                                              mongodb-org-4.2                                              25 M
 mongodb-org-shell                                              x86_64                                             4.2.8-1.el7                                              mongodb-org-4.2                                              17 M
 mongodb-org-tools                                              x86_64                                             4.2.8-1.el7                                              mongodb-org-4.2                                              62 M

Transaction Summary
==============================================================================================================================================================================================================================================
Install  5 Packages

Total download size: 119 M
Installed size: 283 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): mongodb-org-4.2.8-1.el7.x86_64.rpm                                                                                                                                                                     2.9 kB/s | 5.9 kB     00:02    
(2/5): mongodb-org-shell-4.2.8-1.el7.x86_64.rpm                                                                                                                                                               1.2 MB/s |  17 MB     00:13    
(3/5): mongodb-org-server-4.2.8-1.el7.x86_64.rpm                                                                                                                                                              1.2 MB/s |  25 MB     00:20    
(4/5): mongodb-org-tools-4.2.8-1.el7.x86_64.rpm                                                                                                                                                               1.8 MB/s |  62 MB     00:34    
(5/5): mongodb-org-mongos-4.2.8-1.el7.x86_64.rpm                                                                                                                                                              278 kB/s |  15 MB     00:53    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                         2.2 MB/s | 119 MB     00:53     
warning: /var/cache/dnf/mongodb-org-4.2-083f918c4813188b/packages/mongodb-org-4.2.8-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID 058f8b6b: NOKEY
MongoDB Repository                                                                                                                                                                                            0.0  B/s |   0  B     00:00    
Importing GPG key 0x058F8B6B:
 Userid     : "MongoDB 4.2 Release Signing Key <packaging@mongodb.com>"
 Fingerprint: E162 F504 A20C DF15 827F 718D 4B7C 549A 058F 8B6B
 From       : https://www.mongodb.org/static/pgp/server-4.2.asc
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                      1/1 
  Installing       : mongodb-org-tools-4.2.8-1.el7.x86_64                                                                                                                                                                                 1/5 
  Installing       : mongodb-org-shell-4.2.8-1.el7.x86_64                                                                                                                                                                                 2/5 
  Running scriptlet: mongodb-org-server-4.2.8-1.el7.x86_64                                                                                                                                                                                3/5 
  Installing       : mongodb-org-server-4.2.8-1.el7.x86_64                                                                                                                                                                                3/5 
  Running scriptlet: mongodb-org-server-4.2.8-1.el7.x86_64                                                                                                                                                                                3/5 
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.

  Installing       : mongodb-org-mongos-4.2.8-1.el7.x86_64                                                                                                                                                                                4/5 
  Installing       : mongodb-org-4.2.8-1.el7.x86_64                                                                                                                                                                                       5/5 
  Verifying        : mongodb-org-4.2.8-1.el7.x86_64                                                                                                                                                                                       1/5 
  Verifying        : mongodb-org-mongos-4.2.8-1.el7.x86_64                                                                                                                                                                                2/5 
  Verifying        : mongodb-org-server-4.2.8-1.el7.x86_64                                                                                                                                                                                3/5 
  Verifying        : mongodb-org-shell-4.2.8-1.el7.x86_64                                                                                                                                                                                 4/5 
  Verifying        : mongodb-org-tools-4.2.8-1.el7.x86_64                                                                                                                                                                                 5/5 

Installed:
  mongodb-org-4.2.8-1.el7.x86_64            mongodb-org-mongos-4.2.8-1.el7.x86_64            mongodb-org-server-4.2.8-1.el7.x86_64            mongodb-org-shell-4.2.8-1.el7.x86_64            mongodb-org-tools-4.2.8-1.el7.x86_64           

Complete!
[root@xtwj88 ~]# cat /etc/mongod.conf 
# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# 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
#  engine:
#  wiredTiger:

# 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:
  port: 27017
# bindIp: 127.0.0.1  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
  bindIp: 0.0.0.0  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.


#security:

security:
  authorization: enabled

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:
[root@xtwj88 ~]# echo "mongod     soft    nofiles   64000" >> /etc/security/limits.conf
[root@xtwj88 ~]# echo "mongod     soft    nproc     64000" >> /etc/security/limits.conf
[root@xtwj88 ~]# systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.mongodb.org/manual
[root@xtwj88 ~]# systemctl restart mongod
[root@xtwj88 ~]# systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-07-14 17:30:24 CST; 2s ago
     Docs: https://docs.mongodb.org/manual
  Process: 13860 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
  Process: 13857 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 13855 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 13852 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
 Main PID: 13863 (mongod)
    Tasks: 32
   Memory: 69.4M
   CGroup: /system.slice/mongod.service
           └─13863 /usr/bin/mongod -f /etc/mongod.conf

Jul 14 17:30:21 xtwj88 systemd[1]: Starting MongoDB Database Server...
Jul 14 17:30:21 xtwj88 mongod[13860]: about to fork child process, waiting until server is ready for connections.
Jul 14 17:30:21 xtwj88 mongod[13860]: forked process: 13863
Jul 14 17:30:24 xtwj88 mongod[13860]: child process started successfully, parent exiting
Jul 14 17:30:24 xtwj88 systemd[1]: Started MongoDB Database Server.
[root@xtwj88 ~]# mongo
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("78b1f7be-dac2-4a29-8cdd-72bbaf68963b") }
MongoDB server version: 4.2.8
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
> use admin
switched to db admin
> db.createUser({user: "dragon", pwd: "Gah6kuP7ohfio4", roles:[{role: "userAdminAnyDatabase", db: "admin"}]})
Successfully added user: {
	"user" : "dragon",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		}
	]
}
> quit
function quit() {
    [native code]
}
> quit()
[root@xtwj88 ~]# 

use dragon to connect mongodb database

[root@xtwj88 ~]# mongo -u dragon -p --authenticationDatabase admin
MongoDB shell version v4.2.8
Enter password: 
connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("1708573f-835c-43fe-998e-df9bf03246b6") }
MongoDB server version: 4.2.8
> use lanzhou
switched to db lanzhou
> db.createUser({user: "lanzhou", pwd: "Gah6kuP7ohfio4", roles:[{role: "readwrite", db: "lanzhou"}]})
2020-07-14T17:55:47.600+0800 E  QUERY    [js] uncaught exception: Error: couldn't add user: No role named readwrite@lanzhou :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1370:11
@(shell):1:1
> db.createUser({user: "lanzhou", pwd: "Gah6kuP7ohfio4", roles:[{role: "readWrite", db: "lanzhou"}]})
Successfully added user: {
	"user" : "lanzhou",
	"roles" : [
		{
			"role" : "readWrite",
			"db" : "lanzhou"
		}
	]
}
> quit()
[root@xtwj88 ~]# 
qwfys

qwfys

粉丝 6
博文 362
码字总数 206793
作品 0
杭州
架构师
私信 提问
加载中
请先登录后再评论。
用vertx实现高吞吐量的站点计数器

工具:vertx,redis,mongodb,log4j 源代码地址:https://github.com/jianglibo/visitrank 先看架构图: 如果你不熟悉vertx,请先google一下。我这里将vertx当作一个容器,上面所有的圆圈要...

jianglibo
2014/04/03
3.9K
3
Rails 测试工具--RailsBench

Railsbench是一款专门用于rails的测试工具。 1. 安装Railsbench # gem install railsbench # gem install gruff # gem install rmagick...

匿名
2013/02/17
346
0
PHP框架--XiunoPHP

XiunoPHP 是一款面向高负载应用的 PHP 开发框架,PHPer 通过它可以快速的简单的开发出高负载项目。 XiunoPHP 前身名为 Xiuno Framework,更名后版本号从 v1.0 开始计算。已经经过了多年的实际...

匿名
2013/03/20
2.5K
0
c-string转换工具集合--stringencoders

c-string转换工具集合,比标准实现快2倍以上(如果有的话)。——该项目被Google Chrome使用。 包括以下C字符串转换工具 base64, standard base64, web/url safe, with configurable alphabe...

江斌
2012/11/07
4.8K
1
嵌入式NoSQL引擎--UnQLite

UnQLite 是一个嵌入式的软件库,实现了自容器、无服务端、零配置和支持事务的 NoSQL 数据库引擎。UnQLite 是一个文档存储数据库,类似于 MongoDB, Redis, CouchDB 等。同时也是一个标准的 Ke...

匿名
2013/05/23
1W
6

没有更多内容

加载失败,请刷新页面

加载更多

教你几个白嫖百度文库的方法,亲测可用!建议收藏!

后台经常有小伙伴问能不能下载百度文库的 于是,我就随手搜了一下百度文库下载 结果网上各种方法 但是其中靠谱的并不多 要么就是需要充钱买点 要么就是下载下来格式混乱 我亲手试了十多款免费...

少年强
2019/10/21
0
0
实用教程!验证性因子分析思路总结

验证性因子分析,是用于测量因子与测量项(量表题项)之间的对应关系是否与研究者预测保持一致的一种研究方法。尽管因子分析适合任何学科使用,但以社会科学居多。 目前有很多软件都可以非常便...

SPSSAU
2019/12/25
0
0
笑联 x mPaaS | 12 个模块,全面小程序化,如何打造真正的一次开发复用多端?

简介: 一款 App 基于 mPaaS 小程序如何进行改造? 这篇故事围绕着一款 App 基于 mPaaS 小程序进行改造娓娓展开。 作为国内校园服务场景最丰富的平台,笑联 App 已覆盖国内 130 所高校,服务...

一肥仔
28分钟前
15
0
5个步骤实现目标检测

作者|DR. VAIBHAV KUMAR 编译|VK 来源|Analytics In Diamag 目标检测技术是当今计算机视觉领域的发展趋势。在场景图像和视频中,有许多方法被用来检测物体。在资源和执行时间方面,每种技术都...

人工智能遇见磐创
28分钟前
7
0
C++ string 内存增长策略

朝花夕拾系列缘起 时光荏苒,转眼已经毕业三年多了,而在这三年中,自己得过且过,在技术上45并无长足的长进,并且还把以往学过的知识忘记的差不多了,因此有了这个朝花夕拾的系列。寄希望于...

shzwork
30分钟前
11
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部