Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values when 1

SOLVED Go to solution
Highlighted

Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values when 1

Contributor

Hi,

I have written my own topology script and made required configuration in cloudera manager>hdfs>configurations>net.topology.script.file.name property. But the rack topology is not updated and could see ERROR in namenode log as "script /etc/hadoop/conf/topology.sh returned 0 values when 1 were expected.". Please help to resolve the issue. 

 

topology.sh

#!/bin/bash

nodearg=$1  #get the first argument

while [ $# -gt 0 ]; do

        for line in `cat topology.data`;  do  #read line from topology.data file

        node=$(echo $line|awk -F ',' '{print $1}')   #parse the data and get the hostname to compare

        result=""

         if [ $nodearg = $node ]; then          #compare the hostname in the file with the argument

                 result=$(echo $line|awk -F ','  '{print $2}')  #parse the file again to recive the rack details for the host

                break;

         else

                result="/default/rack-0"

         fi

        done

 

shift

echo $result

done

 

topology.data

hdp-1.hdp.com,/default/rack-1

hdp-2.hdp.com,/default/rack-2

hdp-3.hdp.com,/default/rack-3

19.1.0.13,/default/rack-1

19.1.0.14,/default/rack-2

19.1.0.15,/default/rack-3

 

Output:

$ ./topology.sh hdp-1. hdp.com

/default/rack-1

$ ./topology.sh 19.1.0.14

/default/rack-2

 

 

Thanks and regards

Sidharth

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values wh

Contributor

Hi,

 

Thanks for your response and help.

 

Everytime i make changes in configs it re-deploy the configurations which was deleting my topology script. So i pushed my script to /mnt/topology/ directory and also tweak the script a bit

It look like below now 

 

topology.sh

#!/bin/bash

while [ $# -gt 0 ]; do

  nodearg=$1  #get the first argument

        for line in `cat /mnt/topology/topology.data`;  do  #read line from topology.data file

        node=$(echo $line|awk -F ',' '{print $1}')   #parse the data and get the hostname to compare

        result=""

         if [ $nodearg = $node ]; then          #compare the hostname in the file with the argument

                 result=$(echo $line|awk -F ','  '{print $2}')  #parse the file again to recive the rack details for the host

                break;

         else

                result="/default/rack-0"

         fi

        done

 

shift

echo $result

done

6 REPLIES 6

Re: Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values wh

Master Collaborator
The first explanation could be that the script is called without argument maybe?

Re: Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values wh

Contributor
So, in that case it will satisfy the first if condition. Do you know how
hadoop invoke topology script? I mean the parameters it passes along with
script file.

Re: Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values wh

Super Guru

Re: Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values wh

Contributor

Hi,

 

Thanks for your response and help.

 

Everytime i make changes in configs it re-deploy the configurations which was deleting my topology script. So i pushed my script to /mnt/topology/ directory and also tweak the script a bit

It look like below now 

 

topology.sh

#!/bin/bash

while [ $# -gt 0 ]; do

  nodearg=$1  #get the first argument

        for line in `cat /mnt/topology/topology.data`;  do  #read line from topology.data file

        node=$(echo $line|awk -F ',' '{print $1}')   #parse the data and get the hostname to compare

        result=""

         if [ $nodearg = $node ]; then          #compare the hostname in the file with the argument

                 result=$(echo $line|awk -F ','  '{print $2}')  #parse the file again to recive the rack details for the host

                break;

         else

                result="/default/rack-0"

         fi

        done

 

shift

echo $result

done

Re: Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values wh

Super Guru

@sid2707,

 

Very cool and thanks for sharing your solution!

Re: Rack topology script not working ERROR: script /etc/hadoop/conf/topology.sh returned 0 values wh

Super Guru

@sid2707,

 

Sounds like you may need to add some debugging to your shell script to identify what values are being evaluated and why no results are being returned.