zoukankan      html  css  js  c++  java
  • MongoDB入门(2)- MongoDB安装

    windows安装

    下载文件,解压缩即可。下载地址

    每次运行mongod --dbpath D:/MongoDB/data 命令行来启动MongoDB实在是不方便,把它作为Windows服务,这样就方便多了。

    D:MongoDBin>mongod --logpath D:MongoDBlogsMongoDB.log --logappend --dbpath D:MongoDBdata --directoryperdb --serviceName MongoDB --install
    all output going to: D:MongoDBlogsMongoDB.log
    Creating service MongoDB.
    Service creation successful.
    Service can be started from the command line via 'net start "MongoDB"'.
    

    强调1:log一定要指定一个xxx.log文件(文件不存在也要这么写,会自动创建,写成这样是不可以的--logpath d:mongodblogs)

    2:注意:logs文件夹和data文件夹要先新建好;serviceName的N字母要大写

    该命令行指定了日志文件:D:MongoDBlogsMongoDB.log,日志是以追加的方式输出的;

    数据文件目录:D:MongoDBdata,并且参数--directoryperdb说明每个DB都会新建一个目录;

    Windows服务的名称:MongoDB;

    以上的三个参数都是可以根据自己的情况而定的,呵呵。

    最后是安装参数:--install,与之相对的是--remove

    启动MongoDB:net start MongoDB

    停止MongoDB:net stop MongoDB

    (突然停电等情况容易造成Mongo服务出错,可以先删除data目录下的log和lock文件然后重新启动服务)

    Linux安装

    1. Configure the package management system (YUM)

    Create a /etc/yum.repos.d/mongodb.repo file to hold the following configuration information for the MongoDB repository:

    If you are running a 64-bit system, use the following configuration:

    [mongodb]
    name=MongoDB Repository
    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
    gpgcheck=0
    enabled=1
    

    If you are running a 32-bit system, which is not recommended for production deployments, use the following configuration:

    [mongodb]
    name=MongoDB Repository
    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
    gpgcheck=0
    enabled=1
    

    2. Install the MongoDB packages and associated tools.

    To install the latest stable version of MongoDB, issue the following command:

    sudo yum install -y mongodb-org
    

    3. Start MongoDB

    sudo service mongod start
    

    You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:

    sudo chkconfig mongod on
    

    4. Stop MongoDB

    sudo service mongod stop
    

    5. Restart MongoDB

    sudo service mongod restart
    

    6.modify /etc/mongo.conf

    change
    bind_ip=127.0.0.1
    to
    bind_ip=0.0.0.0
    
  • 相关阅读:
    OA开发中下载模板文件的方法之xml篇
    使用不同的doctype造成不同的显示效果
    反射发送实战(-)InvokeMember [转载]
    浅谈DataGridTableStyle心得
    动态加载控件疑惑。。。。
    不同语言中的关键字的比较
    利用mask在PhotoShop完成渐变的图片。
    碰撞代码
    接近感应传感器
    SQLite在多线程环境下的应用
  • 原文地址:https://www.cnblogs.com/wardensky/p/5799274.html
Copyright © 2011-2022 走看看