Azure Data Engineer Associate Certification C ...
- 2k Enrolled Learners
- Weekend
- Live Class
Second only to the windows operating system, Linux is by far one of the most popular operating systems in the industry today. But unlike Windows and the Mac OS which some in standard versions, the Linux operating system has a variety of different flavours that users can download depending on their needs. One such flavour of the Linux operating system is Ubuntu, which is by far the most popular flavour of Linux available today. If you want to use MongoDB on your Ubuntu operating system, the first is to install MongoDB on your Ubuntu Operating System and in this article we will discuss about just that.
Following pointers will be covered in this article,
How to Install MongoDB on Ubuntu
In order to install MongoDB on Ubuntu OS follow the steps outlined below.
In this step you need to first import the public key that is used by the ubuntu package management system. One of the best advantages of using the Ubuntu Package Management system is that there is consistency as well as authenticity in all the keys it imports as it verifies that everything is signed using GPG keys.
In order to import the MongoDB public key, make use of the following command.
> sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10
Once this is done, you need to create a source list file for MongoDB
The list that you need to create is, /etc/apt/sources.list.d/mongodb-org-3.4.list and in order to do this you can make use of the following command.
> echo “deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Once this is done, you need to update the local package repository. In order to do this, use the following command.
> sudo apt-get update
Now let us see how to install MongoDB Package
Now that you have successfully imported the MongoDB repository, it is time to install the MongoDB packages.
You need to install the latest stable version of MongoDB for Ubuntu and in order to do this, use the following command.
> sudo apt-get install -y mongodb-org
If in a certain situation, you need to install a specific version of MongoDB for Ubuntu, you can make use of the following command.sudo apt-get install -y mongodb-org=3.4 mongodb-org-server=3.4 mongodb-org-shell=3.4 mongodb-org-mongos=3.4 mongodb-org-tools=3.4
Now that we know how to install MongoDB on Ubuntu, let us see how to launch it,
Now that mongoDb has been successfully installed on your Ubuntu system, it is time to launch it. In order to do this, you can use the code below.
> sudo vim /etc/systemd/system/mongodb.service
In the above example, we have created a configuration file named mongodb.service in /etc/systemd/system and used that to manage all the mongoDb services which we require.
Once the file has been successfully created, open the same and copy-paste the following code into its contents.
#Unit contains the dependencies to be satisfied before the service is started.
[Unit] Description=MongoDB Database After=network.target Documentation=https://docs.mongodb.org/manual # Service tells systemd, how the service should be started. # Key `User` specifies that the server will run under the mongodb user and # `ExecStart` defines the startup command for MongoDB server. [Service] User=mongodb Group=mongodb ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf # Install tells systemd when the service should be automatically started. # `multi-user.target` means the server will be automatically started during boot. [Install] WantedBy=multi-user.target
Once this is done, update the system service by using the command below.
> systemctl daemon-reload
Start the service by using systemcl.
> sudo systemctl start mongodb
You need to make sure that mongoDb has been started on port 27017. In order to do this, make use of the code below.
> netstat -plntu
After this you need to check if the service has started properly. Use the code below to do the same,
> sudo systemctl status mongodb
If the system is up and running as expected, your output should display active (running) along with the PID and Memory/CPU that is being currently consumed.
If in a certain situation, you need to enable auto starting of MongoDb, you need to use the following command.
> sudo systemctl enable mongodb
To stop MongoDB, use this command.
> sudo systemctl stop mongodb
If you need to restart mongoDb use this command.
> sudo systemctl restart mongodb
This brings us to the final bit of this article,
First open the mongoDb shell. In order to do this on your server, use the following command.
> mongo
Once opened, switch to the admin database by using the code below.
> use admin
Now create the root user by using this command.
> db.createUser({user:"admin", pwd:”password", roles:[{role:"root", db:"admin"}]})
Now when all this is done, exit the MongoDb shell.
Restart mongoDb and connect with the user created in the above step.
> mongo -u admin -p admin123 --authenticationDatabase admin
If you want to see the current database that is being connected, use the following command.
Show dbs
This brings us to the of this article. I hope you have learned how to install MongoDB on Ubuntu Operating System.
Now that you have understood what is Big Data, check out the Big Data training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. The Edureka Big Data Hadoop Certification Training course helps learners become expert in HDFS, Yarn, MapReduce, Pig, Hive, HBase, Oozie, Flume and Sqoop using real-time use cases on Retail, Social Media, Aviation, Tourism, Finance domain.
Got a question for us? Mention them in the comments section and we will get back to you.
Course Name | Date | |
---|---|---|
Big Data Hadoop Certification Training Course | Class Starts on 11th February,2023 11th February SAT&SUN (Weekend Batch) | View Details |
Big Data Hadoop Certification Training Course | Class Starts on 8th April,2023 8th April SAT&SUN (Weekend Batch) | View Details |
edureka.co