MongoDB website
The package mongodb-org-server
provides a initialization script that starts with the mongod
/etc/mongod.conf
configuration file.
See Run MongoDB Community Edition for details on using the this initialization script.
These packages conflict with mongodb
the, mongodb-server
, and mongodb-clients
packages provided by Ubuntu.
The default /etc/mongod.conf
configuration file supplied by the packages has bind_ip
set to by 127.0.0.1
default. Modify This setting as needed for your environment before initializing a replica set.
Install MongoDB Community Edition
1Import 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 D Istributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key:
-- keyserver hkp://keyserver.ubuntu.com:80--recv 0c49f3730359a14518585931bc711f9ba15703c6
2Create 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
" 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
3Reload Local package database.Issue The following command to reload the local package database:
sudo apt-get update
4Install 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, a session may use. These limits may negatively impact MongoDB operation. See UNIX Ulimit Settings for more information.
The MongoDB instance stores their data files /var/lib/mongodb
in and their log files /var/log/mongodb
in by default, and runs using the mongodb
User A Ccount. You can specify alternate log and the data file directories in /etc/mongod.conf
. See and for systemLog.path
storage.dbPath
additional information.
If you change the user of the runs the MongoDB process, you must modify the access control rights to the and /var/lib/mongodb
/var/log/mongodb
dir Ectories to give the user access to these directories.
1Start MongoDB.
Issue the following command to start mongod
:
sudo service Mongod start
2Verify that MongoDB have started successfully
Verify that the process had started successfully by checking the contents of the "log file at for a" line mongod
/var/log/mongodb/mongod.log
Reading
for connections on port <port>
Verify that MongoDB have started successfully
Verify that the process had started successfully by checking the contents of the "log file at for a" line mongod
/var/log/mongodb/mongod.log
Reading
for connections on port <port>
Where <port>
/etc/mongod.conf
is the port configured in, by 27017
default.
3Stop MongoDB.
As needed, you can stop the mongod
process by issuing the following command:
sudo service Mongod stop
4Restart MongoDB.
Issue The following command to restart mongod
:
sudo service mongod restart
5Begin using MongoDB.
To the 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 in the Control+C
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.
1Stop MongoDB.
Stop the mongod
process by issuing the following command:
sudo service Mongod stop
2Remove Packages.
Remove any MongoDB packages so you had previously installed.
sudo apt-get purge mongodb-org*
3Remove Data directories.
Remove MongoDB databases and log files.
sudo rm-r/var/log/-r/var/lib/mongodb
La La la
The installation and uninstallation of MongoDB on Ubuntu system