• 安装mongodb


    一。安装

        1.    下载编译好的二进制

    [root@VM_14_49_centos mongodb_01]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.6.0.tgz
    --2017-12-17 11:24:01--  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.6.0.tgz
    Resolving fastdl.mongodb.org... 52.222.211.118, 52.222.211.146, 52.222.211.226, ...

        2.   解压缩

    [root@VM_14_49_centos mongodb_01]# ls
    mongodb-linux-x86_64-rhel62-3.6.0.tgz
    [root@VM_14_49_centos mongodb_01]# tar -xvf mongodb-linux-x86_64-rhel62-3.6.0.tgz 
    mongodb-linux-x86_64-rhel62-3.6.0/README
    mongodb-linux-x86_64-rhel62-3.6.0/THIRD-PARTY-NOTICES
    mongodb-linux-x86_64-rhel62-3.6.0/MPL-2
    mongodb-linux-x86_64-rhel62-3.6.0/GNU-AGPL-3.0

        3.   配置环境

    [root@VM_14_49_centos mongodb_01]# ls
    mongodb-linux-x86_64-rhel62-3.6.0  mongodb-linux-x86_64-rhel62-3.6.0.tgz
    [root@VM_14_49_centos mongodb_01]# cd mongodb-linux-x86_64-rhel62-3.6.0
    [root@VM_14_49_centos mongodb-linux-x86_64-rhel62-3.6.0]# ls
    bin  GNU-AGPL-3.0  MPL-2  README  THIRD-PARTY-NOTICES
    [root@VM_14_49_centos mongodb-linux-x86_64-rhel62-3.6.0]# $PATH
    -bash: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory
    [root@VM_14_49_centos mongodb-linux-x86_64-rhel62-3.6.0]# cp ./bin/* /usr/local/bin
    [root@VM_14_49_centos mongodb-linux-x86_64-rhel62-3.6.0]# 

         4.   查看权限

    [root@VM_14_49_centos mongodb-linux-x86_64-rhel62-3.6.0]# ls -ahl /usr/local/bin
    total 278M
    drwxr-xr-x.  2 root root 4.0K Dec 17 11:40 .
    drwxr-xr-x. 13 root root 4.0K Dec  3 10:58 ..
    -rwxr-xr-x   1 root root  10M Dec 17 11:40 bsondump
    -rwxr-xr-x   1 root root 5.2K Dec 17 11:40 install_compass
    -rwxr-xr-x   1 root root  33M Dec 17 11:40 mongo
    -rwxr-xr-x   1 root root  57M Dec 17 11:40 mongod
    -rwxr-xr-x   1 root root  13M Dec 17 11:40 mongodump
    -rwxr-xr-x   1 root root  11M Dec 17 11:40 mongoexport
    -rwxr-xr-x   1 root root  11M Dec 17 11:40 mongofiles
    -rwxr-xr-x   1 root root  11M Dec 17 11:40 mongoimport
    -rwxr-xr-x   1 root root  56M Dec 17 11:40 mongoperf
    -rwxr-xr-x   1 root root  14M Dec 17 11:40 mongoreplay
    -rwxr-xr-x   1 root root  14M Dec 17 11:40 mongorestore
    -rwxr-xr-x   1 root root  33M Dec 17 11:40 mongos
    -rwxr-xr-x   1 root root  11M Dec 17 11:40 mongostat
    -rwxr-xr-x   1 root root  11M Dec 17 11:40 mongotop
    [root@VM_14_49_centos mongodb-linux-x86_64-rhel62-3.6.0]# 

          5.   配置conf文件

    [root@VM_14_49_centos ~]# mkdir DB
    [root@VM_14_49_centos ~]# cd DB/
    [root@VM_14_49_centos DB]# mkdir mongodb
    [root@VM_14_49_centos DB]# cd mongodb/
    [root@VM_14_49_centos mongodb]# mkdir conf
    [root@VM_14_49_centos mongodb]# mkdir data
    [root@VM_14_49_centos mongodb]# mkdir log
    [root@VM_14_49_centos mongodb]# vim conf/mongod.conf
    [root@VM_14_49_centos mongodb]# cat conf/mongod.conf 
    port = 12345
    dbpath = /root/DB/mongodb/data
    logpath = /root/DB/mongodb/log/mongod.log
    fork = true
    logappend = true
    bind_ip = 127.0.0.1
    
    [root@VM_14_49_centos mongodb]# 

        6.  启动mongodb

    [root@VM_14_49_centos mongodb]# mongod -f conf/mongod.conf 
    about to fork child process, waiting until server is ready for connections.
    forked process: 27999
    child process started successfully, parent exiting
    [root@VM_14_49_centos mongodb]# 

         7.  登录

    [root@VM_14_49_centos mongodb]# mongo 127.0.0.1:12345/myTest
    MongoDB shell version v3.6.0
    connecting to: mongodb://127.0.0.1:12345/myTest
    MongoDB server version: 3.6.0
    Welcome to the MongoDB shell.

         8.  查看数据库

    > show dbs
    admin  0.000GB
    local  0.000GB
    > 
  • 相关阅读:
    一篇笔记整理JVM工作原理
    深入理解java异常处理机制
    Javaee----重新回顾servlet
    dubbo框架----探索-大型系统架构设计(图解)
    Java 中浮点数---------BigDecimal和double(初探)
    dubbo框架----初探索-配置
    ConcurrentHashMap-----不安全线程hashmap-安全线程-hashtable
    Maven Eclipse (m2e) SCM connector for subclipse 1.10 (svn 1.8) 无法检测
    从svn检出项目---------不是web项目
    Java当中的内存分配以及值传递问题内存解析
  • 原文地址:https://www.cnblogs.com/GH-123/p/8051679.html
Copyright © 2020-2023  润新知