Ubuntu安装mongodb

直接去官网找:https://www.mongodb.com/download-center#community

但是发现下载太慢,看下官网的说明:

Install MongoDB Community Edition on Ubuntu

PLATFORM SUPPORT

MongoDB only provides packages for 64-bit LTS (long-term support) Ubuntu releases. For example, 12.04 LTS (precise), 14.04 LTS (trusty), 16.04 LTS (xenial), and so on. These packages may work with other Ubuntu releases, however, they are not supported.

了解Ubuntu有3种,结合自己用的版本,选择xenial,

清华大学镜像网站下载速度会快很多,选择3.4.7,最新版进行下载,官网的最新版也是3.4.7: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.4.7.tgz

下载到本地目录,拷贝到同一目录下:

dahu@dahu-desktop:/usr/local/mongodb$ ls
mongodb-org_3.4.7_amd64.deb         mongodb-org-shell_3.4.7_amd64.deb
mongodb-org-mongos_3.4.7_amd64.deb  mongodb-org-tools_3.4.7_amd64.deb
mongodb-org-server_3.4.7_amd64.deb

安装:这一步也可以参考官网给出的安装方式

 

检查是否正常:发现进程中有mongodb了

dahu@dahu-desktop:/usr/local/mongodb$ sudo service mongod start 
dahu@dahu-desktop:/usr/local/mongodb$ top

top - 23:44:55 up  1:29,  1 user,  load average: 0.16, 0.20, 0.17
Tasks: 208 total,   1 running, 207 sleeping,   0 stopped,   0 zombie
%Cpu(s):  5.4 us,  0.1 sy,  0.0 ni, 94.3 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  6071872 total,  3214552 free,  1189624 used,  1667696 buff/cache
KiB Swap:  6252540 total,  6252540 free,        0 used.  4478856 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                          
 2570 dahu      20   0  932412 139488  74668 S   5.6  2.3   0:58.39 chrome                           
  940 root      20   0  398200  72128  48176 S   0.3  1.2   1:04.21 Xorg                             
 4127 mongodb   20   0  949172  63080  29432 S   0.3  1.0   0:00.12 mongod                           
 4147 dahu      20   0   43676   4200   3464 R   0.3  0.1   0:00.01 top                              
    1 root      20   0  185340   6136   4156 S   0.0  0.1   0:01.39 systemd                          
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd

再看下log文件:OK的

dahu@dahu-desktop:/usr/local/mongodb$ cat /var/log/mongodb/mongod.log 
2017-08-08T23:44:40.055+0800 I CONTROL  [initandlisten] MongoDB starting : pid=4127 port=27017 dbpath=/var/lib/mongodb 64-bit host=dahu-desktop
2017-08-08T23:44:40.055+0800 I CONTROL  [initandlisten] db version v3.4.7
2017-08-08T23:44:40.055+0800 I CONTROL  [initandlisten] git version: cf38c1b8a0a8dca4a11737581beafef4fe120bcd
2017-08-08T23:44:40.055+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2017-08-08T23:44:40.055+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2017-08-08T23:44:40.055+0800 I CONTROL  [initandlisten] modules: none
2017-08-08T23:44:40.055+0800 I CONTROL  [initandlisten] build environment:
...
2017-08-08T23:44:41.348+0800 I NETWORK  [thread1] waiting for connections on port 27017

另外mongodb有可视化工具,百度里很多,这里我装了studio3T,用了一段时间还不错,后续还要学习下教程

 

posted @ 2017-08-09 00:09  dahu1  Views(270)  Comments(0Edit  收藏  举报