用户登录
用户注册

分享至

linux下安装mongodb

  • 作者: Once丶owned
  • 来源: 51数据库
  • 2020-08-14

安装环境为centos6.3 64bit

mongodb版本:mongodb2.2

配置文件:/etc/mongod.conf

服务启动脚本:/etc/init.d/mongod

总体步骤:

1.配置yum源

2.yum install....

3.测试是否安装成功

若是32位的系统,yum如下配置

 

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

 

过程如下:

 

[plain] view plaincopy
  1. [chen@localhost ~]$ su - root  
  2. Password:   
  3. [root@localhost ~]# cd /etc/yum.repos.d/  
  4. [root@localhost yum.repos.d]# touch 10gen.repo  #名字随便,以.repo结尾  
  5. [root@localhost yum.repos.d]# ls  
  6. 10gen.repo               CentOS-Base.repo       CentOS-Media.repo  
  7. adobe-linux-x86_64.repo  CentOS-Debuginfo.repo  CentOS-Vault.repo  
  8. [root@localhost yum.repos.d]# vim 10gen.repo   
  9. [root@localhost yum.repos.d]# cat 10gen.repo   
  10. [mongodb-10gen]  
  11. name=10gen Repository  
  12. baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64  
  13. gpgcheck=0  
  14. enabled=1  
  15.   
  16. [root@localhost yum.repos.d]# yum list|grep mongo  
  17. mongo-10gen.x86_64                   2.2.0-mongodb_1           @mongodb-10gen     
  18. mongo-10gen-server.x86_64            2.2.0-mongodb_1           @mongodb-10gen     
  19. mongo18-10gen.x86_64                 1.8.5-mongodb_1           mongodb-10gen      
  20. mongo18-10gen-server.x86_64          1.8.5-mongodb_1           mongodb-10gen      
  21. mongo20-10gen.x86_64                 2.0.7-mongodb_1           mongodb-10gen      
  22. mongo20-10gen-server.x86_64          2.0.7-mongodb_1           mongodb-10gen      
  23. [root@localhost yum.repos.d]# cd  
  24. [root@localhost ~]# yum install mongo-10gen mongo-10gen-server  
  25. Loaded plugins: fastestmirror, refresh-packagekit, security  
  26. Loading mirror speeds from cached hostfile  
  27.  * 163-source: mirror.neu.edu.cn  
  28.  * extras: mirror.neu.edu.cn  
  29.  * updates: mirror.neu.edu.cn  
  30. Setting up Install Process  
  31. Resolving Dependencies  
  32. --> Running transaction check  
  33. ---> Package mongo-10gen.x86_64 0:2.2.0-mongodb_1 will be installed  
  34. ---> Package mongo-10gen-server.x86_64 0:2.2.0-mongodb_1 will be installed  
  35. --> Finished Dependency Resolution  
  36.   
  37. Dependencies Resolved  
  38.   
  39. ================================================================================  
  40.  Package                Arch       Version              Repository         Size  
  41. ================================================================================  
  42. Installing:  
  43.  mongo-10gen            x86_64     2.2.0-mongodb_1      mongodb-10gen      43 M  
  44.  mongo-10gen-server     x86_64     2.2.0-mongodb_1      mongodb-10gen     6.7 M  
  45.   
  46. Transaction Summary  
  47. ================================================================================  
  48. Install       2 Package(s)  
  49.   
  50. Total download size: 50 M  
  51. Installed size: 120 M  
  52. Is this ok [y/N]: y  
  53. Downloading Packages:  
  54. (1/2): mongo-10gen-2.2.0-mongodb_1.x86_64.rpm            |  43 MB     02:57       
  55. (2/2): mongo-10gen-server-2.2.0-mongodb_1.x86_64.rpm     | 6.7 MB     00:29       
  56. --------------------------------------------------------------------------------  
  57. Total                                           244 kB/s |  50 MB     03:28       
  58. Running rpm_check_debug  
  59. Running Transaction Test  
  60. Transaction Test Succeeded  
  61. Running Transaction  
  62. Warning: RPMDB altered outside of yum.  
  63.   Installing : mongo-10gen-2.2.0-mongodb_1.x86_64                           1/2   
  64.   Installing : mongo-10gen-server-2.2.0-mongodb_1.x86_64                    2/2   
  65.   Verifying  : mongo-10gen-server-2.2.0-mongodb_1.x86_64                    1/2   
  66.   Verifying  : mongo-10gen-2.2.0-mongodb_1.x86_64                           2/2   
  67.   
  68. Installed:  
  69.   mongo-10gen.x86_64 0:2.2.0-mongodb_1                                            
  70.   mongo-10gen-server.x86_64 0:2.2.0-mongodb_1                                     
  71.   
  72. Complete!  
  73. [root@localhost ~]# chkconfig --list|grep mongo     #查看一下mongo服务  
  74. mongod          0:off   1:off   2:off   3:on    4:off   5:on    6:off  
  75. [root@localhost ~]# chkconfig mongod on     #开机启动  
  76. [root@localhost ~]# chkconfig --list|grep mongo  
  77. mongod          0:off   1:off   2:on    3:on    4:on    5:on    6:off  
  78. [root@localhost ~]# service mongod start    #启动mongodb  
  79. Starting mongod: forked process: 3205  
  80. all output going to: /var/log/mongo/mongod.log  
  81. child process started successfully, parent exiting  
  82.                                                            [  OK  ]  
  83. [root@localhost ~]# service mongod status  
  84. mongod (pid 3205) is running...  
  85. [root@localhost ~]# mongo   #连接测试,安装成功。  
  86. MongoDB shell version: 2.2.0  
  87. connecting to: test  
  88. Welcome to the MongoDB shell.  
  89. For interactive help, type "help".  
  90. For more comprehensive documentation, see  
  91.     http://docs.mongodb.org/  
  92. Questions? Try the support group  
  93.     http://groups.google.com/group/mongodb-user  
  94. >   



软件
前端设计
程序设计
Java相关