无法使用scoop导入数据:exitCode = 255

时间:2016-07-27 17:10:26

标签: sqoop

我是hadoop spark的菜鸟。我已经设置了一个hadoop / spark集群(1个namenode,2个datanode)。现在我尝试使用HDFS中的scoop从DB(mysql)导入数据,但它总是失败

16/07/27 16:50:04 INFO mapreduce.Job: Running job: job_1469629483256_0004
16/07/27 16:50:11 INFO mapreduce.Job: Job job_1469629483256_0004 running in uber mode : false
16/07/27 16:50:11 INFO mapreduce.Job:  map 0% reduce 0%
16/07/27 16:50:13 INFO ipc.Client: Retrying connect to server: datanode1_hostname/172.31.58.123:59676. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
16/07/27 16:50:14 INFO ipc.Client: Retrying connect to server: datanode1_hostname/172.31.58.123:59676. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
16/07/27 16:50:15 INFO ipc.Client: Retrying connect to server: datanode1_hostname/172.31.58.123:59676. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
16/07/27 16:50:18 INFO mapreduce.Job: Job job_1469629483256_0004 failed with state FAILED due to: Application application_1469629483256_0004 failed 2 times due to AM Container for appattempt_1469629483256_0004_000002 exited with  exitCode: 255
For more detailed output, check application tracking page:http://ip-172-31-55-182.ec2.internal:8088/cluster/app/application_1469629483256_0004Then, click on links to logs of each attempt.
Diagnostics: Exception from container-launch.
Container id: container_1469629483256_0004_02_000001
Exit code: 255
Stack trace: ExitCodeException exitCode=255: 
        at org.apache.hadoop.util.Shell.runCommand(Shell.java:545)
        at org.apache.hadoop.util.Shell.run(Shell.java:456)
        at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:722)
        at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:212)
        at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:302)
        at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:82)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)


Container exited with a non-zero exit code 255
Failing this attempt. Failing the application.
16/07/27 16:50:18 INFO mapreduce.Job: Counters: 0
16/07/27 16:50:18 WARN mapreduce.Counters: Group FileSystemCounters is deprecated. Use org.apache.hadoop.mapreduce.FileSystemCounter instead
16/07/27 16:50:18 INFO mapreduce.ImportJobBase: Transferred 0 bytes in 16.2369 seconds (0 bytes/sec)
16/07/27 16:50:18 WARN mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
16/07/27 16:50:18 INFO mapreduce.ImportJobBase: Retrieved 0 records.
16/07/27 16:50:18 ERROR tool.ImportTool: Error during import: Import job failed!

我可以手动写入HDFS:

hdfs dfs -put <local file path> <hdfs path>

但是当我运行scoop import命令时

sqoop import --connect jdbc:mysql://<host>/<db_name> --username <USERNAME> --password <PASSWORD> --table <TABLE_NAME> --enclosed-by '\"' --fields-terminated-by , --escaped-by \\ -m 1 --target-dir <hdfs location>

任何人都可以告诉我我做错了什么

以下是我已经尝试的事项清单

  1. 关闭群集,格式化HDFS,然后重新启动群集(没有帮助)
  2. 确保HDFS未处于安全模式
  3. 所有节点都在/etc/hosts

    127.0.0.1 localhost
    172.31.55.182 namenode_hostname
    172.31.58.123 datanode1_hostname
    172.31.58.122 datanode2_hostname
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    

    配置文件:

    所有节点:$ HADOOP_CONF_DIR / core-site.xml:

    <configuration>
      <property>
        <name>fs.defaultFS</name>
        <value>hdfs://ip-172-31-55-182.ec2.internal:9000</value>
      </property>
    </configuration>
    

    所有节点:$ HADOOP_CONF_DIR / yarn-site.xml:

    <configuration>
    
      <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
      </property>
    
      <property>
        <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
        <value>org.apache.hadoop.mapred.ShuffleHandler</value>
      </property>
    
      <property>
        <name>yarn.resourcemanager.hostname</name>
        <value>ip-172-31-55-182.ec2.internal</value>
      </property>
    
    </configuration>
    

    所有节点:$ HADOOP_CONF_DIR / mapred-site.xml:

    <configuration>
      <property>
        <name>mapreduce.jobtracker.address</name>
        <value>ip-172-31-55-182.ec2.internal:54311</value>
      </property>
      <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
      </property>
    </configuration>
    

    NameNode特定配置

    $ HADOOP_CONF_DIR / HDFS-site.xml中:

    <configuration>
      <property>
        <name>dfs.replication</name>
        <value>2</value>
      </property>
      <property>
        <name>dfs.datanode.data.dir</name>
        <value>file:///mnt/hadoop_data/hdfs/namenode</value>
      </property>
      <property>
        <name>dfs.datanode.address</name>
        <value>0.0.0.0:50010</value>
      </property>
      <property>
        <name>dfs.datanode.http.address</name>
        <value>0.0.0.0:50075</value>
      </property>
      <property>
        <name>dfs.datanode.https.address</name>
        <value>0.0.0.0:50475</value>
      </property>
      <property>
        <name>dfs.datanode.ipc.address</name>
        <value>0.0.0.0:50020</value>
      </property>
    </configuration>
    

    $ HADOOP_CONF_DIR /主人: ip-172-31-55-182.ec2.internal

    $ HADOOP_CONF_DIR /从站:

    ip-172-31-58-123.ec2.internal
    ip-172-31-58-122.ec2.internal
    

    DataNode特定配置

    $ HADOOP_CONF_DIR / HDFS-site.xml中:

    <configuration>
      <property>
        <name>dfs.replication</name>
        <value>2</value>
      </property>
      <property>
        <name>dfs.datanode.data.dir</name>
        <value>file:///mnt/hadoop_data/hdfs/datanode</value>
      </property>
      <property>
        <name>dfs.datanode.address</name>
        <value>0.0.0.0:50010</value>
      </property>
      <property>
        <name>dfs.datanode.http.address</name>
        <value>0.0.0.0:50075</value>
      </property>
      <property>
        <name>dfs.datanode.https.address</name>
        <value>0.0.0.0:50475</value>
      </property>
      <property>
        <name>dfs.datanode.ipc.address</name>
        <value>0.0.0.0:50020</value>
      </property>
    </configuration>
    

3 个答案:

答案 0 :(得分:0)

您尝试导入数据的位置。我的意思是你要连接的是哪台机器。检查namenode和datanode中的master和slaves文件。

尝试ping不同服务器的IP地址,并检查它是否显示为up。

答案 1 :(得分:0)

进行这些更改并重新启动群集,然后重试:

在下面的评论(#)中编辑部分,并删除评论

客户端节点上的

/etc/hosts文件:

127.0.0.1 localhost yourcomputername  #get computername by "hostname -f" command and replace here
172.31.55.182 namenode_hostname ip-172-31-55-182.ec2.internal
172.31.58.123 datanode1_hostname ip-172-31-58-123.ec2.internal
172.31.58.122 datanode2_hostname ip-172-31-58-122.ec2.internal
群集节点上的

/etc/hosts文件:

198.22.23.212 youcomputername #change to public ip of client node, change computername same as client node 
172.31.55.182 namenode_hostname ip-172-31-55-182.ec2.internal
172.31.58.123 datanode1_hostname ip-172-31-58-123.ec2.internal
172.31.58.122 datanode2_hostname ip-172-31-58-122.ec2.internal

答案 2 :(得分:0)

我正在终止此群集并从头开始。