2

I have installed hadoop on my ubuntu 12.04 single node .I am trying to execute an init script to make the hadoop run on start up but it asks password every time i execute.

    #!/bin/sh
### BEGIN INIT INFO
# Provides:          hadoop services
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       Hadoop services
# Short-Description: Enable Hadoop services including hdfs
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HADOOP_BIN=/home/naveen/softwares/hadoop-1.0.3/bin
NAME=hadoop
DESC=hadoop
USER=naveen
ROTATE_SUFFIX=
test -x $HADOOP_BIN || exit 0
RETVAL=0
set -e
cd /

start_hadoop () {
    set +e
    su $USER -s /bin/sh -c $HADOOP_BIN/start-all.sh > /var/log/hadoop/startup_log
    case "$?" in
      0)
        echo SUCCESS
        RETVAL=0
        ;;
      1)
        echo TIMEOUT - check /var/log/hadoop/startup_log
        RETVAL=1
        ;;
      *)
        echo FAILED - check /var/log/hadoop/startup_log
        RETVAL=1
        ;;
    esac
    set -e
}

stop_hadoop () {
    set +e
    if [ $RETVAL = 0 ] ; then
        su $USER -s /bin/sh -c $HADOOP_BIN/stop-all.sh > /var/log/hadoop/shutdown_log
        RETVAL=$?
        if [ $RETVAL != 0 ] ; then
            echo FAILED - check /var/log/hadoop/shutdown_log
        fi
    else
        echo No nodes running
        RETVAL=0
    fi
    set -e
}

restart_hadoop() {
    stop_hadoop
    start_hadoop
}

case "$1" in
    start)
        echo -n "Starting $DESC: "
        start_hadoop
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        stop_hadoop
        echo "$NAME."
        ;;
    force-reload|restart)
        echo -n "Restarting $DESC: "
        restart_hadoop
        echo "$NAME."
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload}" >&2
        RETVAL=1
        ;;
esac
exit $RETVAL

Please tell me how to run hadoop without entering password.

2 Answers 2

0

Setup an ssh key for the user running hadoop

ssh-keygen

Copy the public key into ~/.ssh/authorized_keys

cat ~/.ssh/public_key_name >> ~/.ssh/authorized_keys

Test the key by running ssh localhost as that user.

If that worked then Hadoop should use it without any further configuration.

0

You might want to :

  • check your sshd configuration (in /etc/ssh/sshd_config) and make sure PubkeyAuthentication is set to yes
  • generate a key pair with ssh-keygen from the hadoop system user and copy it into the authorized_keys file cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys

  • make sure the ownership is correct on the file chown 600 $HOME/.ssh/authorized_keys

finally follow the documentation online and don't forget your hadoop-env.sh configuration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .