• 【一】MongoDB安装及配置


    一、MongoDB安装

    1、下载并解压

    wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.0.tgz
    tar zxvf mongodb-linux-x86_64-rhel62-3.2.0.tgz

    2、移动到指定目录下

    mv mongodb-linux-x86_64-rhel62-3.2.0 /usr/local/mongodb

    3、添加到PATH中

    vim /etc/profile
    export PATH=/usr/local/mongodb/bin:$PATH
    source /etc/profile

    二、MongoDB配置启动

    1、创建数据目录和日志目录

    默认下,mongodb的数据目录在/data/db,如果放到其他目录启动时需要指定--dbpath参数。

    mkdir -p /data/db
    mkdir -p /data/log
    touch /data/log/mongodb.log

    2、启动mongod服务

    [root@node1 log]# mongod --dbpath=/data/db --fork --logpath=/data/log/mongodb.log  #默认启动27017端口
    about to fork child process, waiting until server is ready for connections.
    forked process: 45134
    child process started successfully, parent exiting

    参数说明:

    --dbpath           #数据文件存储路径
    --fork             #用子进程在后台启动,否则一直占有终端,用该参数时,必须指定logpath参数
    --logpath          #日志文件的存储路径
    --httpinterface    #网页管理mongodb接口,之前版本默认是开启的,由于安全性,本版本默认是关闭的,如需要加上该参数启动

    3、连接到mongodb

    [root@node1 ~]# mongo
    MongoDB shell version: 3.2.0
    connecting to: test
    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
    Server has startup warnings: 
    2015-11-29T11:04:05.002+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
    2015-11-29T11:04:05.002+0800 I CONTROL  [initandlisten] 
    2015-11-29T11:04:05.002+0800 I CONTROL  [initandlisten] 
    2015-11-29T11:04:05.003+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
    2015-11-29T11:04:05.003+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
    2015-11-29T11:04:05.003+0800 I CONTROL  [initandlisten] 
    2015-11-29T11:04:05.003+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
    2015-11-29T11:04:05.003+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
    2015-11-29T11:04:05.003+0800 I CONTROL  [initandlisten] 
    > 2+3
    5

    4、关闭mongod服务

    mongod --dbpath=/data/db --fork --logpath=/data/log/mongodb.log --shutdown
  • 相关阅读:
    (转载)5分钟安装Linux系统到U盘
    (原创)LAMP搭建之二:apache配置文件详解(中英文对照版)
    (原创)LAMP搭建之一:图解如何安装并检查LAMP
    OpenGL-渲染管线的流程(有图有真相)
    判断点在直线上
    使用QT开发GoogleMap瓦片显示和下载工具
    转:PCL+VS2010环境配置
    error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项:值“0”不匹配值“2”
    An error occurred during the installation of assembly 'Microsoft.VC90.ATL or 'Microsoft.VC80.ATL'
    如何确定VS编译器版本
  • 原文地址:https://www.cnblogs.com/mysql-dba/p/5033242.html
Copyright © 2020-2023  润新知