Monday, November 28, 2011

Hadoop NameSpaceID Error

Below given is usual error occurred in Hadoop environment.

Error in logger will be:

ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Incompatible namespaceIDs

Solution:

Stop all hadoop daemons and then

1. vi $PATH_TO_HADOOP_DATASTORE/dfs/name/current/VERSION
2. Copy the namespaceID value.
3. Now open a terminal on every machine having a datanode and do the following:
     vi $PATH_TO_HADOOP_DATASTORE/dfs/data/current/VERSION
4. Delete the entry corresponding to namespaceID and paste the value copied in Step 1.
Then save and exit.
Start hadoop daemons.

Thursday, August 19, 2010

Unix: Edit/Add string into a file

Here I have given useful scripts for editing and append some text into a file.

This command used to get the line number of a word in the file.

#grep -n "word" asd1.sh | cut -f1 -d:

To get the output in a variable use the below command:

#VAR='grep -n "word" asd1.sh | cut -f1 -d:'

Below command will add 1 to result line. bc is the command line calculator.

#echo `grep -n "word" asd1.sh | cut -f1 -d:` + 1 | bc


Command to add text in a file at given location

#awk 'NR==3{print "newline"}1' asd1.sh


test.sh

findline=`grep -n "log4j:configuration" jboss-log4j.xml | cut -f1 -d:`
addline=`echo $findline+1| bc`
sed ""${addline}"i\ $appender" jboss-log4j.xml > test.txt


The above command will be useful for adding the appender to Jboss log4j xml file during deployment.