MongoDB is included in Ubuntu package repositories, but official MongoDB repository provides most upto date version.
We use official version of MongoDB
The output should look like this
Output:
Enable process start for MongoDB when system reboot
We use official version of MongoDB
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
The output should look like this
ubuntu@ip-192-41-15-154:~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927Executing: /tmp/tmp.u96cXK2VEb/gpg.1.sh --keyserverhkp://keyserver.ubuntu.com:80--recvEA312927gpg: requesting key EA312927 from hkp server keyserver.ubuntu.comgpg: key EA312927: public key "MongoDB 3.2 Release Signing Key <packaging@mongodb.com>" importedgpg: Total number processed: 1gpg: imported: 1 (RSA: 1)
We add MongoDB repository to Apt, so that apt know where to download the repository
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
Output:
deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse
Update the Apt
$ sudo apt-get update
Output:Install MongoDBHit:1 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial InReleaseGet:2 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]Ign:3 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 InReleaseGet:4 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]Get:5 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release [3,457 B]Get:6 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release.gpg [801 B]Get:7 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main Sources [258 kB]Get:8 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [573 kB]Get:9 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [504 kB]Ign:6 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release.gpgHit:10 http://ppa.launchpad.net/webupd8team/atom/ubuntu xenial InReleaseGet:11 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]Get:12 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages [5,870 B]Get:13 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse arm64 Packages [5,872 B]Fetched 1,658 kB in 1s (938 kB/s)Reading package lists... DoneW: GPG error: http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AC711F9BA35703V6W: The repository 'http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release' is not signed.N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.N: See apt-secure(8) manpage for repository creation and user configuration details.
$ sudo apt-get install mongodb-org
Output:
Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools The following NEW packages will be installed: mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 66.8 MB of archives. After this operation, 270 MB of additional disk space will be used. Do you want to continue? [Y/n] Y WARNING: The following packages cannot be authenticated! mongodb-org-shell mongodb-org-server mongodb-org-mongos mongodb-org-tools mongodb-org Install these packages without verification? [y/N] Y Get:1 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-shell amd64 3.4.6 [7,981 kB] Get:2 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-server amd64 3.4.6 [14.2 MB] Get:3 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-mongos amd64 3.4.6 [8,110 kB] Get:4 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-tools amd64 3.4.6 [36.5 MB] Get:5 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 mongodb-org amd64 3.4.6 [3,556 B] Fetched 66.8 MB in 3s (20.3 MB/s) Selecting previously unselected package mongodb-org-shell. (Reading database ... 108006 files and directories currently installed.) Preparing to unpack .../mongodb-org-shell_3.4.6_amd64.deb ... Unpacking mongodb-org-shell (3.4.6) ... Selecting previously unselected package mongodb-org-server. Preparing to unpack .../mongodb-org-server_3.4.6_amd64.deb ... Unpacking mongodb-org-server (3.4.6) ... Selecting previously unselected package mongodb-org-mongos. Preparing to unpack .../mongodb-org-mongos_3.4.6_amd64.deb ... Unpacking mongodb-org-mongos (3.4.6) ... Selecting previously unselected package mongodb-org-tools. Preparing to unpack .../mongodb-org-tools_3.4.6_amd64.deb ... Unpacking mongodb-org-tools (3.4.6) ... Selecting previously unselected package mongodb-org. Preparing to unpack .../mongodb-org_3.4.6_amd64.deb ... Unpacking mongodb-org (3.4.6) ... Processing triggers for man-db (2.7.5-1) ... Setting up mongodb-org-shell (3.4.6) ... Setting up mongodb-org-server (3.4.6) ... Adding system user `mongodb' (UID 113) ... Adding new user `mongodb' (UID 113) with group `nogroup' ... Not creating home directory `/home/mongodb'. Adding group `mongodb' (GID 118) ... Done. Adding user `mongodb' to group `mongodb' ... Adding user mongodb to group mongodb Done. Setting up mongodb-org-mongos (3.4.6) ... Setting up mongodb-org-tools (3.4.6) ... Setting up mongodb-org (3.4.6) ...
Create mongodb.service configuration file
$ sudo nano /etc/systemd/system/mongodb.service
Start MongoDB as Daemon
$ sudo systemctl start mongodCheck status of MongoDB
$ sudo systemctl status mongodOutput:
mongodb.service - High-performance, schema-free document-oriented databaseLoaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled)Active: active (running) since Thu 2019-07-16 03:25:42 UTC; 1min 43s agoMain PID: 13102 (mongod)Tasks: 20Memory: 34.8MCPU: 408msCGroup: /system.slice/mongodb.service└─13102 /usr/bin/mongod --quiet --config /etc/mongod.confJul 13 03:25:42 ip-192-31-13-143 systemd[1]: Started High-performance, schema-free document-oriented database.
Enable process start for MongoDB when system reboot
$ sudo systemctl enable mongodb
Output:Created symlink from /etc/systemd/system/multi-user.target.wants/mongodb.service to /etc/systemd/system/mongodb.service.
0 coment�rios:
Post a Comment