Hadoop - java.net.ConnectException: Connection refused

后端 未结 5 928
无人及你
无人及你 2021-02-15 23:54

I want connect to hdfs (in localhost) and i have a error:

Call From despubuntu-ThinkPad-E420/127.0.1.1 to localhost:54310 failed on connection exception: java.net.Connec

5条回答
  •  走了就别回头了
    2021-02-16 00:26

    I guess that you didn't set up your hadoop cluster correctly please follow these steps :

    Step1: begin with setting up .bashrc:

    vi $HOME/.bashrc
    

    put the following lines at the end of the file: (change the hadoop home as yours)

    # Set Hadoop-related environment variables
    export HADOOP_HOME=/usr/local/hadoop
    
    # Set JAVA_HOME (we will also configure JAVA_HOME directly for Hadoop later on)
    export JAVA_HOME=/usr/lib/jvm/java-6-sun
    
    # Some convenient aliases and functions for running Hadoop-related commands
    unalias fs &> /dev/null
    alias fs="hadoop fs"
    unalias hls &> /dev/null
    alias hls="fs -ls"
    
    # If you have LZO compression enabled in your Hadoop cluster and
    # compress job outputs with LZOP (not covered in this tutorial):
    # Conveniently inspect an LZOP compressed file from the command
    # line; run via:
    #
    # $ lzohead /hdfs/path/to/lzop/compressed/file.lzo
    #
    # Requires installed 'lzop' command.
    #
    lzohead () {
        hadoop fs -cat $1 | lzop -dc | head -1000 | less
    }
    
    # Add Hadoop bin/ directory to PATH
    export PATH=$PATH:$HADOOP_HOME/bin
    

    step 2 : edit hadoop-env.sh as following:

    # The java implementation to use.  Required.
    export JAVA_HOME=/usr/lib/jvm/java-6-sun
    

    step 3 : Now create a directory and set the required ownerships and permissions

    $ sudo mkdir -p /app/hadoop/tmp
    $ sudo chown hduser:hadoop /app/hadoop/tmp
    # ...and if you want to tighten up security, chmod from 755 to 750...
    $ sudo chmod 750 /app/hadoop/tmp
    

    step 4 : edit core-site.xml

    
      hadoop.tmp.dir
      /app/hadoop/tmp
    
    
    
      fs.default.name
      hdfs://localhost:54310
    
    

    step 5 : edit mapred-site.xml

    
      mapred.job.tracker
      localhost:54311
    
    

    step 6 : edit hdfs-site.xml

    
      dfs.replication
      1
    
    

    finally format your hdfs (You need to do this the first time you set up a Hadoop cluster)

     $ /usr/local/hadoop/bin/hadoop namenode -format
    

    hope this will help you

提交回复
热议问题