Saturday, October 25, 2014

How to correct "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)" on Mac OS X


I tried to install mysql using home-brew. Everything was successful But could not connect to the server. Obviously server have not started.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Sigh..

Following command rescued me..

mysqld stop
mysql.server start
I found it in this stack overflow answer.

Saturday, October 11, 2014

How to install Hadoop Standalone / Pseudo Distributed mode 2.X.X on Mac with OS X Mavericks


                                                          Image source: http://www.javacodegeeks.com/2011/05/hadoop-soft-introduction.html

I was searching for a complete tutorial on installing Hadoop on Mac and play around with it. There are resources on installing Hadoop with "HomeBrew" which is the missing package manager in Mac ;). But i do not want to offload all the configuration burden to it as i need to learn this from top to bottom. I played with some and here are the configuration steps i followed.

1) You need to download and extract Hadoop Binary. I used Hadoop 2.5.1 which is the latest at the moment.

http://www.apache.org/dyn/closer.cgi/hadoop/common/

2) Extract the binary and lets called the location as HADOOP_HOME

eg: /Users/user1/software/hadoop-2.5.1

3) Add HADOOP_HOME and JAVA_HOME  as path variables to your system. You can add them to
bashrc or bash_profile.

You can add them by issuing following commands.


$vim ~/.bash_profile

Add following entries and change paths according to your machine's configurations. 


export JAVA_HOME=$(/usr/libexec/java_home)
export HADOOP_HOME=/Users/user1/software/hadoop-2.5.1
export PATH=$PATH:$HADOOP_HOME

and then reload the configurations.


$source ~/.bash_profile
(Follow these steps if you need to run in Pseudo Distributed mode. If you do continue you will have to add input files to the HDFS and then download output files from the HDFS too.)

4) Navigate to HADOOP_HOME and change following files as below.

etc/hadoop/core-site.xml:
<configuration>
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://localhost:9000</value>
    </property>
</configuration>
etc/hadoop/hdfs-site.xml:
<configuration>
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>
</configuration>

5) Setup passphraseless ssh

Now check that you can ssh to the localhost without a passphrase:
$ ssh localhost

If you cannot ssh to localhost without a passphrase, execute the following commands:

$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
 $ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

(You may need to enable remote-login in system preferences --> sharing if you have not enabled it later to login through ssh.)
6) Starting the Hadoop in Standalone mode.
 
Navigate to $HADOOP_HOME

Format the filesystem:

 $ bin/hdfs namenode -format


Start NameNode daemon and DataNode daemon:

$ sbin/start-dfs.sh



The hadoop daemon log output is written to the $HADOOP_LOG_DIR directory (defaults to $HADOOP_HOME/logs).
Browse the web interface for the NameNode; by default it is available at:

So good luck with all your map reduce jobs. :)

Friday, October 3, 2014

Castle of the Moors(Castelo dos Mouros) - Hill top Medieval Castle

This is another weekend trip as last one. It seems there are plenty of places to be covered in Portugal which is an amazing country with lots of beautiful people and places.

 http://blog.shelan.org/2014/09/cabo-da-roca-western-most-cape-of.html

So all the EMDC students got together for a weekend out. We decided to pay a visit to Sintra without knowing what exactly we would we be going to explore or it would offer. We knew that it had lots of attractions and that was all what we needed to know.

 You can reach there using viva gem card which is valid for Metro and train (My previous blog post explains about it) . We travelled from Alameda to Rossio Metro station and then changed into the train to Sintra. It took around 1 hour to reach there and it was a different city with mountains all around and more green sights. You can see lots of tourists visiting there too.

We thought of going to the Castle of the Moors and then visit other places after that. But we had marginal time even to return. That place was amazing and a worth place to kill your time in the weekend. It took around 2 hours or more to go to the top. We hiked on our own and if you are bit lazy
you can get a Hop on Hop off bus. To be frank we thought that option better too had we known that earlier :). But you will burn some calories (a lot i would say while enjoying the nature) so it is okay if you are settled for it.

There are two castles on the top and one of them was closed (It closes around 4.30 pm after summer) so we had to choose Castle of the Moors which closes at 8.00pm. You need to pay Euro 7.50 per person for the entry ticket. This place was amazing and well maintained. Below pics will proof that to you for sure. You can enjoy a breath taking view from top of the Castle. And this castle was a Medieval Castle which built couple of centuries ago during 8th/9th Century. So it was pretty old one which poses a great historical value too.

On our way back six of us got into two groups due to bad timing and three of us almost lost on the way. Luckily we had Google maps and found a way to Sintra Train station. Luckily
That path was much shorter but steeper than the path we climbed. Ask Google the path he will tell you obviously :).

Enjoy my pics.