-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongodb
60 lines (41 loc) · 2.11 KB
/
mongodb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#############################################
Install MongoDB Community Edition in Ubuntu
#############################################
Step 1-: Import the public key used by the package management system
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
Step 2-: Create a list file for MongoDB
Create the /etc/apt/sources.list.d/mongodb-org-4.0.list file for Ubuntu 18.04 (Bionic):
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Create the /etc/apt/sources.list.d/mongodb-org-4.0.list file for Ubuntu 16.04 (Xenial):
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Step 3-: Reload local package database
sudo apt-get update
Step 4-:
To install the latest stable version, issue the following
sudo apt-get install -y mongodb-org
To install a specific release, you must specify each component package individually along with the version number, as in the following example:
sudo apt-get install -y mongodb-org=4.0.10 mongodb-org-server=4.0.10 mongodb-org-shell=4.0.10 mongodb-org-mongos=4.0.10 mongodb-org-tools=4.0.10
#######################################################
Run MongoDB Community Edition
#######################################################
Step 1- : Start MongoDB
sudo service mongod start
Step 2-: Verify that MongoDB has started successfully
cat /var/log/mongodb/mongod.log
check the last line for -:: [initandlisten] waiting for connections on port 27017
Step 3-: Stop MongoDB
sudo service mongod stop
Step 4-: Restart MongoDB
sudo service mongod restart
Step 5-: Begin using MongoDB
mongo
#######################################################
uninstall MongoDB Community Edition in Ubuntu
#######################################################
Step 1-: Stop MongoDB
sudo service mongod stop
Step 2 -: Remove packages
sudo apt-get purge mongodb-org*
Step 3 -: Remove Data Directories
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb