mongodb 在 Ubuntu系统上的安装及卸载

Posted limeOracle

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mongodb 在 Ubuntu系统上的安装及卸载相关的知识,希望对你有一定的参考价值。

mongodb官网

 

The mongodb-org-server package provides an initialization script that starts mongod with the /etc/mongod.conf configuration file.

See Run MongoDB Community Edition for details on using this initialization script.

These packages conflict with the mongodbmongodb-server, and mongodb-clients packages provided by Ubuntu.

The default /etc/mongod.conf configuration file supplied by the packages have bind_ip set to 127.0.0.1 by default. Modify this setting as needed for your environment before initializing a replica set.

Install MongoDB Community Edition

 

Import the public key used by the package management system.

    The Ubuntu package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
Create a list file for MongoDB.

    Create the /etc/apt/sources.list.d/mongodb-org-3.4.list list file using the command appropriate for your version of Ubuntu:

Ubuntu 16.04
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Reload local package database.
    Issue the following command to reload the local package database:
sudo apt-get update
Install the MongoDB packages.

    Install the latest stable version of MongoDB.

    Issue the following command:

sudo apt-get install -y mongodb-org

Run MongoDB Community Edition

Most Unix-like operating systems limit the system resources that a session may use. These limits may negatively impact MongoDB operation. See UNIX ulimit Settings for more information.

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodbby default,  and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.

If you change the user that runs the MongoDB process, you must modify the access control rights to the /var/lib/mongodb and /var/log/mongodb directories to give this user access to these directories.

Start MongoDB.

    Issue the following command to start mongod:

sudo service mongod start
Verify that MongoDB has started successfully

    Verify that the mongod process has started successfully by checking the contents of the log file at/var/log/mongodb/mongod.log for a line reading

[initandlisten] waiting for connections on port <port>

 

Verify that MongoDB has started successfully

    Verify that the mongod process has started successfully by checking the contents of the log file at/var/log/mongodb/mongod.log for a line reading

[initandlisten] waiting for connections on port <port>

    where <port> is the port configured in /etc/mongod.conf27017 by default.

Stop MongoDB.

    As needed, you can stop the mongod process by issuing the following command:

sudo service mongod stop
Restart MongoDB.

    Issue the following command to restart mongod:

sudo service mongod restart
Begin using MongoDB.

    To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.

    Before deploying MongoDB in a production environment, consider the Production Notes document.

    Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.

Uninstall MongoDB Community Edition

    To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.

Stop MongoDB.

    Stop the mongod process by issuing the following command:

sudo service mongod stop
Remove Packages.

    Remove any MongoDB packages that you had previously installed.

sudo apt-get purge mongodb-org*
Remove Data Directories.

    Remove MongoDB databases and log files.

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

啦啦啦

以上是关于mongodb 在 Ubuntu系统上的安装及卸载的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu操作系统中mongodb的安装与卸载

从 ubuntu 卸载 mongoDB

如何在 Ubuntu 操作系统中安装及卸载软件

如何删除ubuntu系统安装的应用软件

Ubuntu下MongoDB的安装和卸载

Mac brew安装MongoDB