zoukankan      html  css  js  c++  java
  • 【一】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
  • 相关阅读:
    [POJ3111]K Best(分数规划, 二分)
    [Python]实现简单决策树
    HDU 1269.迷宫城堡-Tarjan or 双向DFS
    HDU 2586.How far away ?-在线LCA(ST)-代码很认真的写了注释(捞到变形)
    HDU 5727.Necklace-二分图匹配匈牙利
    ZOJ 3593.One Person Game-扩展欧几里得(exgcd)
    牛客网 牛客小白月赛2 H.武-最短路(Dijkstra)
    牛客网 牛客小白月赛2 G.文
    牛客网 牛客小白月赛2 E.是是非非-尼姆博奕
    牛客网 牛客小白月赛2 D.虚虚实实-无向图判欧拉路径
  • 原文地址:https://www.cnblogs.com/mysql-dba/p/5033242.html
Copyright © 2011-2022 走看看