-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathsteps-install-mongodb-on-ubuntu.yaml
157 lines (113 loc) · 4.99 KB
/
steps-install-mongodb-on-ubuntu.yaml
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
title: Import the public key used by the package management system.
stepnum: 1
level: 4
ref: import-key
content: |
From a terminal, issue the following command to import the
MongoDB public GPG Key from `<https://www.mongodb.org/static/pgp/server-{+pgp-version+}.asc>`_:
.. code-block:: bash
wget -qO - https://www.mongodb.org/static/pgp/server-{+pgp-version+}.asc | sudo apt-key add -
The operation should respond with an ``OK``.
However, if you receive an error indicating that ``gnupg`` is not
installed, you can:
#. Install ``gnupg`` and its required libraries using the following command:
.. code-block:: bash
sudo apt-get install gnupg
#. Once installed, retry importing the key:
.. code-block:: bash
wget -qO - https://www.mongodb.org/static/pgp/server-{+pgp-version+}.asc | sudo apt-key add -
Lastly, apt-key is being deprecated. If you receive an error
indicating ``Warning: apt-key is deprecated. Manage keyring files
in trusted.gpg.d instead (see apt-key(8)).``, you can:
#. Use ``wget`` and ``tee`` to install the GPG Key directly.
.. code-block:: bash
wget -O - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo tee /etc/apt/trusted.gpg.d/server-6.0.asc
---
title: Create a list file for MongoDB.
stepnum: 2
level: 4
ref: sources-list
content: |
Create the list file
``/etc/apt/sources.list.d/mongodb-org-{+version+}.list`` for your
version of Ubuntu.
Click on the appropriate tab for your version of Ubuntu.
If you are unsure of what Ubuntu version the host is running,
open a terminal or shell on the host and execute ``lsb_release -dc``.
.. tabs::
tabs:
- id: focal
name: Ubuntu 20.04 (Focal)
content: |
The following instruction is for **Ubuntu 20.04 (Focal)**.
Create the
``/etc/apt/sources.list.d/mongodb-org-{+version+}.list``
file for Ubuntu 20.04 (Focal):
.. code-block:: bash
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/{+version+} multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-{+version+}.list
- id: bionic
name: Ubuntu 18.04 (Bionic)
content: |
The following instruction is for **Ubuntu 18.04
(Bionic)**.
Create the
``/etc/apt/sources.list.d/mongodb-org-{+version+}.list``
file for Ubuntu 18.04 (Bionic):
.. code-block:: bash
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/{+version+} multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-{+version+}.list
- id: xenial
name: Ubuntu 16.04 (Xenial)
content: |
The following instruction is for **Ubuntu 16.04
(Xenial)**.
Create the
``/etc/apt/sources.list.d/mongodb-org-{+version+}.list``
file for Ubuntu 16.04 (Xenial):
.. code-block:: bash
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/{+version+} multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-{+version+}.list
---
title: Reload local package database.
stepnum: 3
level: 4
ref: reload
action:
pre: |
Issue the following command to reload the local package database:
language: sh
copyable: true
code: |
sudo apt-get update
---
title: Install the MongoDB packages.
stepnum: 4
level: 4
ref: install
content: |
You can install either the latest stable version of MongoDB or a
specific version of MongoDB.
.. tabs::
tabs:
- id: latest
name: Install the latest version of MongoDB.
content: |
To install the latest stable version, issue the following
.. code-block:: bash
sudo apt-get install -y {+package-name-org+}
- id: specific
name: Install a specific release of MongoDB.
content: |
.. include:: /includes/release/pin-version-intro.rst
.. include:: /includes/release/pin-repo-to-version-deb.rst
.. include:: /includes/release/pin-version-outro-org.rst
Optional. Although you can specify any available version of MongoDB,
``apt-get`` will upgrade the packages when a newer version becomes
available. To prevent unintended upgrades, you can pin the package
at the currently installed version:
.. code-block:: bash
echo "{+package-name-org+} hold" | sudo dpkg --set-selections
echo "{+package-name-org+}-database hold" | sudo dpkg --set-selections
echo "{+package-name-org+}-server hold" | sudo dpkg --set-selections
echo "{+package-name+}-mongosh hold" | sudo dpkg --set-selections
echo "{+package-name-org+}-mongos hold" | sudo dpkg --set-selections
echo "{+package-name-org+}-tools hold" | sudo dpkg --set-selections
...