MongoDB – Installation

Today I am going to try the MongoDB installation on my Linux machine which I installed in my VMware. I am not going to do the same installation on my Windows’ laptop. I am expected to learn and workaround with the MongoDB in my virtual machine only.

Let us get started, it is simple installation and just a small confusion on one of the configuration parts, not to worry about it too much at this point. As I googled how to install MongoDB on Ubuntu, there is a list of guides to follow and I personally followed these two links:
1. From the MongoDB website: https://docs.mongodb.com/v3.2/tutorial/install-mongodb-on-ubuntu/
2. From a tutorial website: https://www.howtoforge.com/tutorial/install-mongodb-on-ubuntu-16.04/

Both are guiding us on how to install on the Ubuntu 16.04. Just follow the commands given in the website and I will just briefly mention what I do on each step.

1. Import the public key.
2. Create source list file MongoDB. I used below command, but using my Ubuntu version, Xenial,

echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

Else, the default command is,

echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

3. Update the repository.
4. Install MongoDB.
At this step, it asks us to create a new mongodb systemd service file in the ‘/lib/systemd/system’ directory. Below is the instruction:
Go to that directory and create the new mongodb service file ‘mongod.service’ with vim.

cd /lib/systemd/system/
vim mongod.service

In the edit mode (command prompt), I am unable to edit anything in which I should paste the setting on it and save. I have no idea how the vim works. Maybe you can enlighten me on this part.

I tried to use the text editor and I am unable to save the file because of permission issue. I did not change the file, anyway, and proceed to update the systemd service using the given command line.
5. Start Mongodb and add it as service to be started at boot time.
6. Now check that Mongodb has been started on port 27017 with the netstat command.

You can check the MongoDB’s log at /var/log/mongodb/mongod.log and the port configured in /etc/mongod.conf, 27017 by default.

The installation is completed. Few commands to be remember:
1. Start service – sudo service mongod start
2. Stop service – sudo service mongod stop (or control-C)
3. Restart service – sudo service mongod restart
4. Go to Mongo shellmongo

Advertisements

Scala Programming – Setup

As a part of the new environment, I start to learn this functional programming language called Scala Programming. I sign up the Coursera’s course, Functional Programming Principles in Scala. The course began in May 2017.

Therefore, most of my write-up on Scala is be based on the Coursera’s course and some of the experience I gained from my hand-on or on-job-training.

Before I start coding, there is a few things need to be installed and configured before I can start the basic print out “Hello World”. Let me walk through the setup processes here. My machine is running on the virtual machine with Ubuntu 16.04 installed.

Installing the JDK

The first thing first is installing the Java Development Kit. At the point of my learning, its latest version is JDK 8.0. To install JDK on the Ubuntu, we need to run a command in the Terminal. So, let’s open the Terminal and put the below code,

sudo apt-get install openjdk-8-jdk

It will prompt you to enter user password of your machine and it will proceed to get it installed. For other Linux operating systems, there are other commands to be run. To check the installed Java version, you can type the below command in the terminal.

java -version

You can expect to see the detail as below,
ubuntu16-04@ubuntu:~$ java -version
openjdk version “1.8.0_121”
OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

Alternatively, you can install the JDK manually by downloading the .tar.gz archived file from the Oracle website, unzipped it at the preferred directory and add the bin/ directory of the extracted JDK to the PATH environment variable.

Installing sbt

Okay, what is sbt?

sbt is an open source build tool for Scala and Java projects, similar to Java’s Maven or Ant. This is a definition I found from the Internet. There is an online document you can read up for ‘Getting Started with sbt’, http://www.scala-sbt.org/0.13/docs/Getting-Started.html. I refer to this online document to install sbt on Linux. For other operating systems, you can refer to the relevant document.

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
sudo apt-get update
sudo apt-get install sbt

Installing IntelliJ

For the Coursera’s course, the instructor teaches us to install the IntelliJ IDEA. You can choose to install other IDEs such as Eclipse, Sublime and etc. It is your own preferences. For my virtual machine, I will follow the Coursera’s course to use the IntelliJ. The installer can be found from its website, https://www.jetbrains.com/idea/download/#section=linux.

Proceed to download the Community version .tar.gz file. Upon completion, change directory to the file location. You can run the command below to check the file too.

Next, we need to extract the file and begin to install it on our machine by navigating to the bin folder and run the idea.sh. Pardon me for the wrong change directory in the screenshot below.

Viola! The IntelliJ’s first screen prompts up. Go along with the step by step setup until you click the ‘Finish’ button. The customization of IntelliJ IDEA allows us to set the UI Theme, create desktop entry for integration with system application menu, create launcher script which allows us to open files or projects from the command lines, install plugin in which Scala must be installed before we start using it.

So, what is next? Of course we shall create a Scala project and have our very first program runs. Let us give a try and not just finish here… You will get to see UI of IntelliJ with options to a create project, import project and etc on the screen as below,

And yes, we are just two more steps nearer to the first Scala program. Click on the ‘Create New Project’. In the screen below, select the Scala > SBT > Next button.

It brings us to the next page where we fill in the project name and check on the JDK, SBT and Scala properties. Remember that we have done the JDK installation in the first step, then followed by the SBT installation before we began our IntelliJ installation whereby we did the Scala installation too?

Click on the ‘Finish’ button and it creates the project for us. The interface looks as below when it launches on my virtual machine which is running on Ubuntu 16.04.

Last step is start learning how to code! Keep it up!

MongoDB – GUI

After I finished both installation and new user creation, the next thing which comes into my mind is, does MongoDB has GUI? Coming from the MSSQL background, the SQL management tool is very useful for me and for now, I think I cannot live without it when I start learning MongoDB. I am not sure if this is a correct way of thinking and using the MongoDB. Should the MongoDB required a GUI tool to use, please advise me.

I do not have any idea which GUI is good and a search from the Internet returns Robomongo as the first link in the list. So, I think I will give a try to install it in my virtual machine and test to login using the userID and password I created and start learning and using the database.

Installation of Robomongo
The installar can be downloaded from its website and the installation is done pretty fast in Linux as usual. Then, launch the application and it first glance of look as below:

Create MongoDB Connection
The next step is create new MongoDB connection. It requires to fill up the Name of the connection and we can test the connection to port 27017 is working fine or not but clicking the ‘Test’ button.

Upon receiving the success message, we can proceed to set the authentication.

Test again the authentication and verified it is successful before we save the setting. I am not sure why whenever I connect to the database it does not prompt me for the userID and password. Is it meant to be this way? I will update on this part after my research. Stay tuned!

First Linux Experience

The new environment requires me to work using the Linux OS – Ubuntu. It is my first time using the Linux in my working life and it is my second time using Linux OS. The first time was during my college time when we were working on the group assignment to introduce a Linux OS. Back then, I used Suse Linux. I barely have any memories of using the command lines and it is going to be a challenge for me.

Without much knowledge, I dived into the Ubuntu installation from the flash drive on a new machine which just delivered to me this morning. However, I have mistakenly gone into the Windows environment before I started the installation from the USB

I got a help from my colleague. He tried to restart the laptop with an attempt to boot to Advanced Setup from Windows. Make sure the USB is connected to the laptop. I saw he pressed ‘Shift’ and restart.

For Windows 10, we have to change the UEFI Firmware settings to boot device from the USB. It goes into this screen and select ‘Use a device’. Select the USB to be used and the computer will now restart and boot from the selected USB drive.

Some guides can refer here too, https://www.tenforums.com/tutorials/21756-boot-usb-drive-windows-10-pc.html.

However, for my case, after applied the new UEFI firmware setting, it restarted and directly booted up from the USB whereby the Ubuntu installation took place. I

Since my laptop is using the Windows OS, I installed the VMware Workstation in order to allow myself to install the same Ubuntu version on the virtual machine. I feel it is more easy for my learning or do my work if I have the similar environment on my laptop.

Before I begin my setup to create new virtual machine in the VMware Workstation, I downloaded the Ubuntu 16.04 disk image from the Ubuntu website, https://www.ubuntu.com/download/desktop.

To create a new virtual machine, it is simple by following the step by step in the VMware. There is an online guide to follow too, https://betanews.com/2012/08/29/how-to-install-ubuntu-on-vmware-workstation/. I find the step by step setup is easy and fast.

If you wish to customize the setting, you can do it by clicking the ‘Customize Hardware’ button. It prompts up to the screen above. I increased the RAM to 2 GB instead of the default 1 GB and keep the default 20 GB for hard disk space.

Complete the installation with naming the virtual machine and personalized the user setting with username and password. You can choose to ‘Power On’ the virtual machine and start using it before hitting the ‘Finish’ button. This is how the Ubuntu’s interface looks like.

Everything is well setup and working fine. I pretty like the user interface with the task bar on the left, maroon in colour and simple user interface. Initially, I fear that I have to use command prompt all the way to do my work.