• Ubuntu14.04下Mongodb(在线安装方式|apt-get)安装部署步骤(图文详解)(博主推荐)


      不多说,直接上干货!

    本博文介绍了MongoDB,并详细指引读者在Ubuntu下MongoDB的安装和使用。本教程在Ubuntu14.04下测试通过。 

    一、MongoDB介绍

      MongoDB 是一个是一个基于分布式文件存储的数据库,介于关系数据库和非关系数据库之间,是非关系数据库当中功能最丰富,最像关系数据库的。他支持的数据结构非常松散,是类似json的bson格式,因此可以存储比较复杂的数据类型。Mongo最大的特点是他支持的查询语言非常强大,其语法有点类似于面向对象的查询语言,几乎可以实现类似关系数据库单表查询的绝大部分功能,而且还支持对数据建立索引。

    二、安装MongoDB

      MongoDB安装很简单,无需下载源文件,可以直接用apt-get命令进行安装。 

    首先,查看下你的操作系统的版本。 

    root@zhouls-virtual-machine:~# cat /etc/issue
    Ubuntu 14.04.4 LTS 
     l
    
    root@zhouls-virtual-machine:~# 





    root@zhouls-virtual-machine:~# sudo apt-get install mongodb
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    mongodb is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 338 not upgraded.
    root@zhouls-virtual-machine:~# mongo -version
    MongoDB shell version: 2.4.9
    root@zhouls-virtual-machine:~# sudo apt-get --purge remove mongodb mongodb-clients mongodb-server
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      libboost-dev libboost-filesystem1.54.0 libboost-program-options1.54.0
      libboost-thread1.54.0 libboost1.54-dev libgoogle-perftools4 libpcrecpp0
      libsnappy1 libstdc++-4.8-dev libtcmalloc-minimal4 libunwind8 libv8-3.14.5
      mongodb-dev
    Use 'apt-get autoremove' to remove them.
    The following packages will be REMOVED:
      mongodb* mongodb-clients* mongodb-server*
    0 upgraded, 0 newly installed, 3 to remove and 338 not upgraded.
    After this operation, 107 MB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 180474 files and directories currently installed.)
    Removing mongodb (1:2.4.9-1ubuntu2) ...
    Removing mongodb-server (1:2.4.9-1ubuntu2) ...
    arg: remove
    mongodb stop/waiting
    Purging configuration files for mongodb-server (1:2.4.9-1ubuntu2) ...
    dpkg: warning: while removing mongodb-server, directory '/var/log/mongodb' not empty so not removed
    dpkg: warning: while removing mongodb-server, directory '/var/lib/mongodb' not empty so not removed
    Removing mongodb-clients (1:2.4.9-1ubuntu2) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    root@zhouls-virtual-machine:~# clear
    
    root@zhouls-virtual-machine:~# sudo apt-get install mongodb
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following extra packages will be installed:
      mongodb-clients mongodb-server
    The following NEW packages will be installed:
      mongodb mongodb-clients mongodb-server
    0 upgraded, 3 newly installed, 0 to remove and 338 not upgraded.
    Need to get 0 B/12.9 MB of archives.
    After this operation, 107 MB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Selecting previously unselected package mongodb-clients.
    (Reading database ... 180427 files and directories currently installed.)
    Preparing to unpack .../mongodb-clients_1%3a2.4.9-1ubuntu2_amd64.deb ...
    Unpacking mongodb-clients (1:2.4.9-1ubuntu2) ...
    Selecting previously unselected package mongodb-server.
    Preparing to unpack .../mongodb-server_1%3a2.4.9-1ubuntu2_amd64.deb ...
    Unpacking mongodb-server (1:2.4.9-1ubuntu2) ...
    Selecting previously unselected package mongodb.
    Preparing to unpack .../mongodb_1%3a2.4.9-1ubuntu2_amd64.deb ...
    Unpacking mongodb (1:2.4.9-1ubuntu2) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    Processing triggers for ureadahead (0.100.0-16) ...
    ureadahead will be reprofiled on next reboot
    Setting up mongodb-clients (1:2.4.9-1ubuntu2) ...
    Setting up mongodb-server (1:2.4.9-1ubuntu2) ...
    mongodb start/running, process 3594
    Processing triggers for ureadahead (0.100.0-16) ...
    Setting up mongodb (1:2.4.9-1ubuntu2) ...
    root@zhouls-virtual-machine:~# 

      安装完成后,在终端输入以下命令查看MongoDB版本:

    root@zhouls-virtual-machine:~# mongo -version
    MongoDB shell version: 2.4.9

      启动和关闭mongodb命令如下:

    root@zhouls-virtual-machine:~# service mongodb start
    start: Job is already running: mongodb
    root@zhouls-virtual-machine:~# service mongodb stop
    mongodb stop/waiting
    root@zhouls-virtual-machine:~# 

       默认设置MongoDB是随Ubuntu启动自动启动的。 

      输入以下命令查看是否启动成功:

    pgrep mongo -l   #注意:-l是英文字母l,不是阿拉伯数字1

      卸载MongoDB

    root@zhouls-virtual-machine:~# sudo apt-get --purge remove mongodb mongodb-clients mongodb-server
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      libboost-dev libboost-filesystem1.54.0 libboost-program-options1.54.0
      libboost-thread1.54.0 libboost1.54-dev libgoogle-perftools4 libpcrecpp0
      libsnappy1 libstdc++-4.8-dev libtcmalloc-minimal4 libunwind8 libv8-3.14.5
      mongodb-dev
    Use 'apt-get autoremove' to remove them.
    The following packages will be REMOVED:
      mongodb* mongodb-clients* mongodb-server*
    0 upgraded, 0 newly installed, 3 to remove and 338 not upgraded.
    After this operation, 107 MB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 180474 files and directories currently installed.)
    Removing mongodb (1:2.4.9-1ubuntu2) ...
    Removing mongodb-server (1:2.4.9-1ubuntu2) ...
    arg: remove
    mongodb stop/waiting
    Purging configuration files for mongodb-server (1:2.4.9-1ubuntu2) ...
    dpkg: warning: while removing mongodb-server, directory '/var/log/mongodb' not empty so not removed
    dpkg: warning: while removing mongodb-server, directory '/var/lib/mongodb' not empty so not removed
    Removing mongodb-clients (1:2.4.9-1ubuntu2) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    root@zhouls-virtual-machine:~# 
  • 相关阅读:
    编写一个程序的步骤
    vue实现瀑布流
    Vue 解决动态生成列表点击事件无效的问题
    筛选分类列表展示
    php实现类似慕课网,php中文网的分类功能
    在一个页面修改数据,并且ajax刷新数据列表的数据实现。
    记账小程序系统简单规划
    茶叶项目---产品的规格添加
    茶叶商城开发
    后端图片上传
  • 原文地址:https://www.cnblogs.com/zlslch/p/6934971.html
Copyright © 2020-2023  润新知