Month: July 2017

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 and the clear guide on how to install MongoDB can be found in this two links:
1. From the MongoDB website: https://docs.mongodb.com/manual/tutorial/

4. Install MongoDB.Edited on 2019/01/31.
It is much cleaner and straight forward installation right now using command,
sudo apt-get install -y mongodb-org

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 using command,
sudo service mongod start
sudo systemctl enable mongod

It could be important to run the service at boot time especially when install on a server, while some of us would prefer to on the service when we run our database on local machine.

Upon run the second command I see,
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /lib/systemd/system/mongod.service.

If you are into system files details, you can navigate to the path above to see more information.

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.

mongod.conf is a great file to check mongo database’s configuration.

The installation is completed. Few commands to be remember:1. Start service – sudo service mongod start2. Stop service – sudo service mongod stop (or control-C)3. Restart service – sudo service mongod restart4. Go to Mongo shell – mongo

It has been a while since the last time I visited Kim Gary in Mid Valley’s branch. I cannot even remember there is a branch in Berjaya Times Square until my friend said she wanted to have dinner here. I am glad to see the restaurant still offers various set meals which can easily take you a while to choose what you want to eat and how much you want to eat.

It did take me a while to look through the menu to decide what I wanted to order for the night and lastly, I chose to have a bowl of noodle, an half of the toast with chicken wing set which included a glass of drink. It seemed a lot, right? I was thinking the noodle would not make me feeling full and the additional of toast and chicken wing made the dinner more completed.

It was really sinful to have the toast at night but it has been quite long I did not have toast in Kuala Lumpur. It was nothing special about this toast and chicken wing, it tasted normal and slightly oily as usual for the toast. Besides that, I think they do not use butter, they gave me margarine instead. It did not taste good. No comment about the chicken wing, just a normal chicken wing.

Instant noodle with a piece of luncheon meat and a fried egg on top of noodle is the basic for a Hong Kong style instant noodle meal. Sometimes, you can find some vegetable and sometimes, you do not. It is normal instant noodle with MSG soup based and it is nothing interesting about it. I am not sure which instant noodle’s brand they are using. The noodle texture is spring, did not overly cook the egg and luncheon meat.

What interested me the most of that dinner was a glass of cold ying yong. It is a combination of the coffee and tea, one of the favourite drink in Hong Kong too. The ratio of the coffee and tea is important to get the right taste of the ying yong.

It was a night full with unhealthy food selection, the toast and instant noodle. Moreover, having the cold drink after the meal is not going to help the digestion at night but it satisfied my stomach!

This is a continuation from the previous entry which I wrote about the Scala Programming’s setup and IDE installation. In the previous entry, we were successfully setup the JDK, sbt, Scala and installed the IntelliJ. The last step is start coding.

Besides using the IntelliJ, you can install and use other IDEs to write codes, for example, Eclipse. It is just a personal preferences. I asked my friends which tools that they are using for Scala programming and I received a standard reply from them, Eclipse.

As for my Coursera’s course, the instructor is using IntelliJ and I am going to use it in my virtual machine. I will try to use Eclipse as well on my Windows environment. Come, let try to write a Hello World program using the IntelliJ.

When the new project loads, the Project explorer on the left side shows the structure of the Scala project. Go to the src folder and expand it. Under the main folder > New Scala Worksheet > Enter file name. The text editor at the center of the application loads the new file. Type as below,

"Hello World"

And, press the ‘Run’ button on the top. It renders the result on the right side of the application. We need to include the double quotation in our codes.

This is our first helloworld. If you want to create an object class file, under the main folder > New > Scala Class > Enter the filename, eg: example.Example > Select Object in the Kind dropdown. It will show the package example and object Example in the screen below.

If we want to run this as the main application, we need to tell the compiler to extend the application. Just extra code needs after object Example, see below:

object Example extends App {
println(“Hello World”)
}

As it is run as main application, you will see a little icon on the left side as below which you can choose Run ‘Example’ or Debug ‘Example’.

Then, what is Run ‘Example’ with Coverage?

Different IDEs will show the result in different mode or presentation but the end result is the same. You can try to use the command line to run and print helloworld too. When I tried it using my virtual machine’s command line by typing scala, it prompted me an error. It is my very first time using command line in Ubuntu to run a scala program.

scala

It advised me to install the Scala using the command below. I just did as per advised.

sudo apt install scala

It took a while to install when I run it in my Terminal. Can someone highlight to me what causes the error? Does it mean that Scala installation on the IDEs is not the same as the Terminal?

When the installation is completed in the Terminal, I try again as below and it is correctly displaying the string input I entered.

This is Scala Programming! I am going to stop writing for a while and concentrating on learning this programming language. See ya 🙂

Like this:

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.

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.

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. To extract the tar.gz file, use this command,

tar -xvzf ideaIC-2017.1.2.tar.gz

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.

As a newbie to Linux, I do need to search in the Internet for the command lines to be executed whenever I wanted to do something in the Ubuntu’s environment. Recently, the most commonly used command line that I used is

sudo apt-get install

I used it when I was installing the Java Development Kit JDK 8.0 for example. Then, I am curious what does the sudo means? And is the apt-get means get the application? So, I did a search in the Internet to get more understanding on these commands which I have been using it lately.

Someone wrote in his/her reply,sudo is a shell command — it’s a program whose name you can type in the shell. Its arguments are a command to run as root, the system user with maximum privileges. (super user do)

apt-get is a shell command, part of the APT tool suite. APT is the package manager on Debian, Ubuntu, Mint and other Linux distributions. apt-get installs and maintains programs and other collections of files (data, documentation, etc.) in the form of packages. Packages are usually downloaded from repositories on the Internet, but can also be read from a CD or other media.

install, here, is a one of apt-get’s commands. It is followed by the name of one or more package to install. Other apt-get commands include remove (to remove the packages whose name follow), upgrade (to upgrade all packages for which upgrades can be downloaded), etc. The apt-get command build-dep installs all the packages that are required to install the specified package from source.

Indeed, it is a new journey for myself as a newbie and a lot of learning, trials and errors, hiccups to get things done or worked. The initial fear of touching Linux has gone because I have to use it as part of my work life. Positively looking into this new transformation brought by my new working environment. At the moment, I do not have intention to completely move from Windows to Linux.

With the virtual machine tool installed, I will have more chances to deal with different operating systems. I am looking forward 🙂

Like this:

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!

Upon the Ubuntu 16.04 installation completion on my machine, I realized it was showing Jakarta’s timezone. I repeated the same installation in my virtual machine and it showed Los Angelas’ timezone. Oddly, it is an automatically detected from the Internet.

I tried to enter ‘Singapore’ under the Location, however, it failed to show the correct Asia/Singapore as shown below.

I became clueless why Singapore was not listed in the timezone selection. The closest timezone will be Kuala Lumpur or Johor state in Malaysia. I tried to pick the location from the map which was quite hard because Singapore is a very tiny country in the world map. I am so sorry, I could not input Singapore and I have to use Kuala Lumpur, Malaysia.

If you have the solution on this issue, kindly share with me. Thank you in advanced.