Win7 下面安装MongoDB

来源:互联网 发布:域名中.net是什么意思 编辑:程序博客网 时间:2024/06/07 05:26

1. MongoDB download

             From website:  https://www.mongodb.org/downloads 

    Download version:   mongodb-win32-x86_64-2008plus-ssl-3.0.1.zip


2. Decompress MongoDB zip file

    Decompress Path:  C:\mongodb-win32-x86_64-2008plus-ssl-3.0.1


3. Before install MongoDB

       Create data directory:    mongod --dbpath C:\MongoDB\mongoadmin\data;

   Create log file directory:   C:\MongoDB\mongoadmin\log , C:\MongoDB\mongoadmin\log\log.txt;


4. Launch MongoDB

    Enter directory:   C:\mongodb-win32-x86_64-2008plus-ssl-3.0.1\bin, and execute Mongod.exe command like below:

         mongod --logpath=C:\MongoDB\mongoadmin\log\log.txt --dbpath=C:\MongoDB\mongoadmin\data;

   Launch MongoDB with configure file:

         mongod --config /data/config/mongod.conf  /*Mongo support YAML format in configuraion*/


5.  Install as a service

     Enter directory with Administrator:   C:\mongodb-win32-x86_64-2008plus-ssl-3.0.1\bin, and exec below Mongod command:

        mongod --install --logpath=C:\MongoDB\mongoadmin\log\log.txt --dbpath=C:\MongoDB\mongoadmin\data 

    Query to see if install successfully:

        sc qc mongodb


6. Enter shell enviornment

    Enter directory:   C:\mongodb-win32-x86_64-2008plus-ssl-3.0.1\bin, type "mongo"

   Type "mongod --help" can browse more detail help info.

        

7. Start and Stop MongoDB

    Enter cmd with administrative privileges:

    Start mongoDB service:  net start mongodb

    Test to see if mongoDB can be connected: mongo

    Stop mongoDB service:  net stop mongodb

                                               /* Check file data\mongod.lock  to see if is a clean shutdown, 

                                                * net start makes file size larger than 1 kB, net stop clean this file, make size as 0

                                                */

    remove it from services if needed: mongod --remove

   Shutdown from shell: 

     1) Enter cmd with administrative privileges:     

     2) Type "mongo" to enter shell environment:

     3) Type "use admin"

     4) Type "db.shutdownServer()"

     5)  Check mongod.lock to see if a clean shutdowm     

  Check MongoDB Status:

    1) Type "db.serverStatus()"                                       

    

8. Dirty Shutdown Recovery

     Enter cmd with administrator privileges:          mongod --port 4000 --dbpath C:\MongoDB\mongoadmin\data;

                                                 /* run mongodb with another non-standard port as 4000, will recover data first */





*******************************************************************************************************************************************

*********                                                                             常见问题

*******************************************************************************************************************************************

1.  由于目标计算机积极拒绝,无法连接


先打开mongoDB service, 才能进行连接 : 1)net start mongodb

                                                                     2)  mongo


2. In File::open(), CreateFileW for 'U:\mongorc.js'系统找不到指定路径


启动shell,会自动加载.mongorc.js,启动时加上mongo --norc就可以跳过此文件加载

0 0
原创粉丝点击