• centos7 安装mongodb


    centos7 安装mongodb

    使用清华的源

    新建 /etc/yum.repos.d/mongodb.repo,内容为

    [mongodb-org]
    name=MongoDB Repository
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el$releasever/
    gpgcheck=0
    enabled=1
    

    刷新缓存并安装 mongodb-org 即可。

    sudo yum makecache
    sudo yum install mongodb-org
    
    [root@localhost yum.repos.d]# yum install mongodb-org
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    Resolving Dependencies
    --> Running transaction check
    ---> Package mongodb-org.x86_64 0:4.4.6-1.el7 will be installed
    --> Processing Dependency: mongodb-org-tools = 4.4.6 for package: mongodb-org-4.4.6-1.el7.x86_64
    --> Processing Dependency: mongodb-org-mongos = 4.4.6 for package: mongodb-org-4.4.6-1.el7.x86_64
    --> Processing Dependency: mongodb-org-shell = 4.4.6 for package: mongodb-org-4.4.6-1.el7.x86_64
    --> Processing Dependency: mongodb-org-server = 4.4.6 for package: mongodb-org-4.4.6-1.el7.x86_64
    --> Running transaction check
    ---> Package mongodb-org-mongos.x86_64 0:4.4.6-1.el7 will be installed
    ---> Package mongodb-org-server.x86_64 0:4.4.6-1.el7 will be installed
    ---> Package mongodb-org-shell.x86_64 0:4.4.6-1.el7 will be installed
    ---> Package mongodb-org-tools.x86_64 0:4.4.6-1.el7 will be installed
    --> Processing Dependency: mongodb-org-database-tools-extra = 4.4.6 for package: mongodb-org-tools-4.4.6-1.el7.x86_64
    --> Processing Dependency: mongodb-database-tools for package: mongodb-org-tools-4.4.6-1.el7.x86_64
    --> Running transaction check
    ---> Package mongodb-database-tools.x86_64 0:100.3.1-1 will be installed
    --> Processing Dependency: cyrus-sasl-plain for package: mongodb-database-tools-100.3.1-1.x86_64
    --> Processing Dependency: cyrus-sasl for package: mongodb-database-tools-100.3.1-1.x86_64
    --> Processing Dependency: cyrus-sasl-gssapi for package: mongodb-database-tools-100.3.1-1.x86_64
    ---> Package mongodb-org-database-tools-extra.x86_64 0:4.4.6-1.el7 will be installed
    --> Running transaction check
    ---> Package cyrus-sasl.x86_64 0:2.1.26-23.el7 will be installed
    ---> Package cyrus-sasl-gssapi.x86_64 0:2.1.26-23.el7 will be installed
    ---> Package cyrus-sasl-plain.x86_64 0:2.1.26-23.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =======================================================================================================================================
     Package                                         Arch                  Version                        Repository                  Size
    =======================================================================================================================================
    Installing:
     mongodb-org                                     x86_64                4.4.6-1.el7                    mongodb-org                6.2 k
    Installing for dependencies:
     cyrus-sasl                                      x86_64                2.1.26-23.el7                  base                        88 k
     cyrus-sasl-gssapi                               x86_64                2.1.26-23.el7                  base                        41 k
     cyrus-sasl-plain                                x86_64                2.1.26-23.el7                  base                        39 k
     mongodb-database-tools                          x86_64                100.3.1-1                      mongodb-org                 50 M
     mongodb-org-database-tools-extra                x86_64                4.4.6-1.el7                    mongodb-org                 19 k
     mongodb-org-mongos                              x86_64                4.4.6-1.el7                    mongodb-org                 17 M
     mongodb-org-server                              x86_64                4.4.6-1.el7                    mongodb-org                 22 M
     mongodb-org-shell                               x86_64                4.4.6-1.el7                    mongodb-org                 14 M
     mongodb-org-tools                               x86_64                4.4.6-1.el7                    mongodb-org                6.1 k
    
    Transaction Summary
    =======================================================================================================================================
    Install  1 Package (+9 Dependent packages)
    
    Total download size: 103 M
    Installed size: 103 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/10): cyrus-sasl-2.1.26-23.el7.x86_64.rpm                                                                     |  88 kB  00:00:00     
    (2/10): cyrus-sasl-plain-2.1.26-23.el7.x86_64.rpm                                                               |  39 kB  00:00:00     
    (3/10): cyrus-sasl-gssapi-2.1.26-23.el7.x86_64.rpm                                                              |  41 kB  00:00:00     
    (4/10): mongodb-org-4.4.6-1.el7.x86_64.rpm                                                                      | 6.2 kB  00:00:10     
    (5/10): mongodb-org-database-tools-extra-4.4.6-1.el7.x86_64.rpm                                                 |  19 kB  00:00:00     
    (6/10): mongodb-org-mongos-4.4.6-1.el7.x86_64.rpm                                                               |  17 MB  00:00:00     
    (7/10): mongodb-database-tools-100.3.1.x86_64.rpm                                                               |  50 MB  00:00:47     
    (8/10): mongodb-org-shell-4.4.6-1.el7.x86_64.rpm                                                                |  14 MB  00:00:01     
    (9/10): mongodb-org-tools-4.4.6-1.el7.x86_64.rpm                                                                | 6.1 kB  00:00:00     
    (10/10): mongodb-org-server-4.4.6-1.el7.x86_64.rpm                                                              |  22 MB  00:01:01     
    ---------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                  1.4 MB/s | 103 MB  00:01:13     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : cyrus-sasl-2.1.26-23.el7.x86_64                                                                                    1/10 
      Installing : mongodb-org-database-tools-extra-4.4.6-1.el7.x86_64                                                                2/10 
      Installing : cyrus-sasl-gssapi-2.1.26-23.el7.x86_64                                                                             3/10 
      Installing : mongodb-org-shell-4.4.6-1.el7.x86_64                                                                               4/10 
      Installing : cyrus-sasl-plain-2.1.26-23.el7.x86_64                                                                              5/10 
      Installing : mongodb-database-tools-100.3.1-1.x86_64                                                                            6/10 
      Installing : mongodb-org-tools-4.4.6-1.el7.x86_64                                                                               7/10 
      Installing : mongodb-org-server-4.4.6-1.el7.x86_64                                                                              8/10 
    Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.
      Installing : mongodb-org-mongos-4.4.6-1.el7.x86_64                                                                              9/10 
      Installing : mongodb-org-4.4.6-1.el7.x86_64                                                                                    10/10 
      Verifying  : mongodb-database-tools-100.3.1-1.x86_64                                                                            1/10 
      Verifying  : mongodb-org-4.4.6-1.el7.x86_64                                                                                     2/10 
      Verifying  : mongodb-org-mongos-4.4.6-1.el7.x86_64                                                                              3/10 
      Verifying  : mongodb-org-server-4.4.6-1.el7.x86_64                                                                              4/10 
      Verifying  : cyrus-sasl-plain-2.1.26-23.el7.x86_64                                                                              5/10 
      Verifying  : mongodb-org-shell-4.4.6-1.el7.x86_64                                                                               6/10 
      Verifying  : mongodb-org-tools-4.4.6-1.el7.x86_64                                                                               7/10 
      Verifying  : cyrus-sasl-gssapi-2.1.26-23.el7.x86_64                                                                             8/10 
      Verifying  : mongodb-org-database-tools-extra-4.4.6-1.el7.x86_64                                                                9/10 
      Verifying  : cyrus-sasl-2.1.26-23.el7.x86_64                                                                                   10/10 
    
    Installed:
      mongodb-org.x86_64 0:4.4.6-1.el7                                                                                                     
    
    Dependency Installed:
      cyrus-sasl.x86_64 0:2.1.26-23.el7                                        cyrus-sasl-gssapi.x86_64 0:2.1.26-23.el7                    
      cyrus-sasl-plain.x86_64 0:2.1.26-23.el7                                  mongodb-database-tools.x86_64 0:100.3.1-1                   
      mongodb-org-database-tools-extra.x86_64 0:4.4.6-1.el7                    mongodb-org-mongos.x86_64 0:4.4.6-1.el7                     
      mongodb-org-server.x86_64 0:4.4.6-1.el7                                  mongodb-org-shell.x86_64 0:4.4.6-1.el7                      
      mongodb-org-tools.x86_64 0:4.4.6-1.el7                                  
    
    Complete!
    [root@localhost yum.repos.d]#
    

    启动mongodb

    systemctl start mongod
    
    
    [root@localhost mongodb]# systemctl start mongod
    [root@localhost mongodb]# 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 2021-06-15 13:45:02 CST; 1s ago
         Docs: https://docs.mongodb.org/manual
      Process: 11457 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
      Process: 11454 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
      Process: 11449 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
      Process: 11447 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
     Main PID: 11459 (mongod)
       CGroup: /system.slice/mongod.service
               └─11459 /usr/bin/mongod -f /etc/mongod.conf
    
    Jun 15 13:45:01 localhost.localdomain systemd[1]: Starting MongoDB Database Server...
    Jun 15 13:45:01 localhost.localdomain mongod[11457]: about to fork child process, waiting until server is ready for connections.
    Jun 15 13:45:01 localhost.localdomain mongod[11457]: forked process: 11459
    Jun 15 13:45:02 localhost.localdomain mongod[11457]: child process started successfully, parent exiting
    Jun 15 13:45:02 localhost.localdomain systemd[1]: Started MongoDB Database Server.
    [root@localhost mongodb]#
    

    使用mongodb

    mongodb
    
    [root@localhost mongodb]# mongo
    MongoDB shell version v4.4.6
    connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("ba6e3777-026f-48e5-b66b-9c119f10962a") }
    MongoDB server version: 4.4.6
    Welcome to the MongoDB shell.
    For interactive help, type "help".
    For more comprehensive documentation, see
    	https://docs.mongodb.com/
    Questions? Try the MongoDB Developer Community Forums
    	https://community.mongodb.com
    ---
    The server generated these startup warnings when booting: 
            2021-06-15T13:45:02.595+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
            2021-06-15T13:45:02.596+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
            2021-06-15T13:45:02.596+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
    ---
    ---
            Enable MongoDB's free cloud-based monitoring service, which will then receive and display
            metrics about your deployment (disk utilization, CPU, operation statistics, etc).
    
            The monitoring data will be available on a MongoDB website with a unique URL accessible to you
            and anyone you share the URL with. MongoDB may use this information to make product
            improvements and to suggest MongoDB products and deployment options to you.
    
            To enable free monitoring, run the following command: db.enableFreeMonitoring()
            To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
    ---
    > db
    test
    > use examples
    switched to db examples
    > db
    examples
    > exit
    bye
    [root@localhost mongodb]#
    
  • 相关阅读:
    路由协议
    TDD一示范例
    leetcode-36 + this may be useful when development is performed under newer sdk version
    leetcode-35
    TCP扫盲1
    UDP扫盲
    leetcode-34
    leetcode-33
    leetcode-32
    mysql非常全的和完整的总结
  • 原文地址:https://www.cnblogs.com/fb010001/p/14885234.html
Copyright © 2020-2023  润新知