这个问题一般是在hadoop2.x版本里会出现,
Hadoop的datanode需要访问namenode的jobhistory server,如果没有修改,则默认为0.0.0.0:10020,则可以修改mapred-site.xml文件:
<property>
<name>mapreduce.jobhistory.address</name>
<!-- 配置实际的Master主机名和端口-->
<value>0.0.0.0:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<!-- 配置实际的Master主机名和端口-->
<value>0.0.0.0:19888</value>
</property>
最后不要忘记了启动jobhistory
$HADOOP_HOME/sbin/mr-jobhistory-daemon.sh start historyserver
********************************************************************
a:C:\words.txt 文件内容:
hello alamp s
hello qq
hello xx
hello aa
hello swk
hello zbj
hello blm
blm xixi
zbj hehe
swk haha
b. java
@Test
public void testUpload() throws IllegalArgumentException, IOException {
FSDataOutputStream out = fs.create(new Path(
"hdfs://itcast01:9000/upload2"));
FileInputStream in = new FileInputStream(new File("c:/words.txt"));
IOUtils.copyBytes(in, out, 2048, true);
package cn.itcast.hadoop.mr;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class WordCount {
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
conf.setInt("mapreduce.client.submit.file.replication", 20);
Job job = Job.getInstance(conf);
//notice
job.setJarByClass(WordCount.class);
//set mapper`s property
job.setMapperClass(WCMapper.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(LongWritable.class);
FileInputFormat.setInputPaths(job, new Path("/upload2/"));
//set reducer`s property
job.setReducerClass(WCReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(LongWritable.class);
FileOutputFormat.setOutputPath(job, new Path("/usr/mapperReduce"));
//submit
job.waitForCompletion(true);
}
}
c.打jar包
[root@itcast01 usr]# hadoop jar mr.jar
17/05/20 16:44:09 INFO client.RMProxy: Connecting to ResourceManager at itcast01/192.168.233.128:8032
17/05/20 16:44:10 WARN mapreduce.JobSubmitter: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
17/05/20 16:44:11 INFO input.FileInputFormat: Total input paths to process : 1
17/05/20 16:44:11 INFO mapreduce.JobSubmitter: number of splits:1
17/05/20 16:44:11 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1495288787912_0006
17/05/20 16:44:12 INFO impl.YarnClientImpl: Submitted application application_1495288787912_0006
17/05/20 16:44:12 INFO mapreduce.Job: The url to track the job: http://itcast01:8088/proxy/application_1495288787912_0006/
17/05/20 16:44:12 INFO mapreduce.Job: Running job: job_1495288787912_0006
17/05/20 16:44:55 INFO mapreduce.Job: Job job_1495288787912_0006 running in uber mode : false
17/05/20 16:44:55 INFO mapreduce.Job: map 0% reduce 0%
17/05/20 16:46:24 INFO mapreduce.Job: map 100% reduce 0%
17/05/20 16:47:02 INFO mapreduce.Job: map 100% reduce 100%
17/05/20 16:47:03 INFO mapreduce.Job: Job job_1495288787912_0006 completed successfully
17/05/20 16:47:06 INFO mapreduce.Job: Counters: 49
File System Counters
FILE: Number of bytes read=435
FILE: Number of bytes written=186471
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=210
HDFS: Number of bytes written=78
HDFS: Number of read operations=6
HDFS: Number of large read operations=0
HDFS: Number of write operations=2
Job Counters
Launched map tasks=1
Launched reduce tasks=1
Data-local map tasks=1
Total time spent by all maps in occupied slots (ms)=65092
Total time spent by all reduces in occupied slots (ms)=32649
Total time spent by all map tasks (ms)=65092
Total time spent by all reduce tasks (ms)=32649
Total vcore-seconds taken by all map tasks=65092
Total vcore-seconds taken by all reduce tasks=32649
Total megabyte-seconds taken by all map tasks=66654208
Total megabyte-seconds taken by all reduce tasks=33432576
Map-Reduce Framework
Map input records=17
Map output records=32
Map output bytes=365
Map output materialized bytes=435
Input split bytes=93
Combine input records=0
Combine output records=0
Reduce input groups=13
Reduce shuffle bytes=435
Reduce input records=32
Reduce output records=13
Spilled Records=64
Shuffled Maps =1
Failed Shuffles=0
Merged Map outputs=1
GC time elapsed (ms)=290
CPU time spent (ms)=5530
Physical memory (bytes) snapshot=284258304
Virtual memory (bytes) snapshot=1685770240
Total committed heap usage (bytes)=136515584
Shuffle Errors
BAD_ID=0
CONNECTION=0
IO_ERROR=0
WRONG_LENGTH=0
WRONG_MAP=0
WRONG_REDUCE=0
File Input Format Counters
Bytes Read=117
File Output Format Counters
Bytes Written=78
[root@itcast01 usr]# hadoop fs -ls /
Found 9 items
-rw-r--r-- 1 root supergroup 153512879 2017-05-17 05:34 /jdk
-rw-r--r-- 1 root supergroup 62 2017-05-20 13:54 /score_in
drwx------ - root supergroup 0 2017-05-17 06:15 /tmp
-rw-r--r-- 3 root supergroup 32 2017-05-17 14:47 /upload
-rw-r--r-- 3 root supergroup 117 2017-05-20 16:35 /upload2
drwxr-xr-x - root supergroup 0 2017-05-20 16:44 /usr
drwxr-xr-x - root supergroup 0 2017-05-17 06:18 /wcout
-rw-r--r-- 1 root supergroup 70 2017-05-17 06:12 /words
drwxr-xr-x - root supergroup 0 2017-05-20 15:23 /xx
[root@itcast01 usr]# hadoop fs -cat /usr/upload2/part-r-00000
cat: `/usr/upload2/part-r-00000': No such file or directory
[root@itcast01 usr]# hadoop fs -ls /usr/
Found 4 items
drwxr-xr-x - root supergroup 0 2017-05-17 14:54 /usr/local
drwxr-xr-x - root supergroup 0 2017-05-20 16:47 /usr/mapperReduce
drwxr-xr-x - root supergroup 0 2017-05-20 16:08 /usr/swk
drwxr-xr-x - root supergroup 0 2017-05-17 11:25 /usr/test
[root@itcast01 usr]# hadoop fs -ls /usr/mapperReduce
Found 2 items
-rw-r--r-- 1 root supergroup 0 2017-05-20 16:47 /usr/mapperReduce/_SUCCESS
-rw-r--r-- 1 root supergroup 78 2017-05-20 16:46 /usr/mapperReduce/part-r-00000
[root@itcast01 usr]# hadoop fs -cat /usr/mapperReduce/part-r-00000
11
aa 1
alamp 1
blm 2
haha 1
hehe 1
hello 7
qq 1
s 1
swk 2
xixi 1
xx 1
zbj 2
[root@itcast01 usr]#
- hadoop报错:java.io.IOException(java.net.ConnectException: Call From xxx/xxx to xxx:10020 failed on connection exception: java.net.ConnectException: 拒绝连接
任务一直报错 现象比较奇怪,部分任务可以正常跑,部分问题报错 报错信息如下: Ended Job = job_1527476268558_132947 with exception 'java.io. ...
- Hadoop格式化 From hu-hadoop1/192.168.11.11 to hu-hadoop2:8485 failed on connection exception: java.net.
192.168.11.12:8485: Call From hu-hadoop1/192.168.11.11 to hu-hadoop2:8485 failed on connection excep ...
- Hadoop: failed on connection exception: java.net.ConnectException: Connection refuse
ssh那些都已经搞了,跑一个书上的例子出现了Connection Refused异常,如下: 12/04/09 01:00:54 INFO ipc.Client: Retrying connect t ...
- Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案
Call to localhost/127.0.0.1:9000 failed on connection exception:java.net.ConnectException的解决方案 作者:凯鲁 ...
- android异常: java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused
android手机做下载文件时,报了如下异常: java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused 模拟器 ...
- [转]android访问网络:java.net.ConnectException: localhost/127.0.0.1:8888 - Connection refused
这对刚学会向tomcat模拟的本地服务器发送请求的同学非常重要! 转自:http://wing123.iteye.com/blog/1873763 描述:在做注册功能的时候,向本地服务器:127.0. ...
- 【android】java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused
调试中通过android simulator模拟器链接localhost或者127.0.0.1,因为我在电脑上面建立了apache,我的代码大概就是URL url = new URL(urlStrin ...
- Debian部署RMI异常:java.rmi.ConnectException: Connection refused to host: 127.0.1.1;
现象:在windows上部署RMI很顺利,但移到debian上部署后,客户端报异常: java.rmi.ConnectException: Connection refused to host: 12 ...
- 调用远程主机上的 RMI 服务时抛出 java.rmi.ConnectException: Connection refused to host: 127.0.0.1 异常原因及解决方案
最近使用 jmx 遇到一个问题,client/server 同在一台机器上,jmx client能够成功连接 server,如果把 server 移植到另一台机器上192.168.134.128,抛出 ...
随机推荐
- 通用网关接口 ruby perl web页面 文本处理 脚本语言
小结: 1.只要可以对标准输入输出进行操作,那么无论任何语言都可以编写CGI程序. <代码的未来> 在Ruby诞生的1993年,互联网还没有现在这样普及,因此Ruby也不是一开始就面向We ...
- lumen
HTTP路由 基本路由 路由参数 必填参数 可选参数 正则表达式约束 命名路由 路由组 中间件 命令空间 路由前缀 基本路由 你可以在 route/web.php 文件中定义应用程序的全部路由.最基本 ...
- easyUI表格多表头实现
项目中要实现表格多表头,结合网上的例子自己实现了一个,包含frozenColumns情况. 一,通过标签创建 效果: <table id="schoolGrid" class ...
- dp的斜率优化
对于刷题量我觉得肯定是刷的越多越好(当然这是对时间有很多的人来说. 但是在我看来我的确适合刷题较多的那一类人,应为我对知识的应用能力并不强.这两天学习的内容是dp的斜率优化.当然我是不太会的. 这个博 ...
- Python中给List添加元素的4种方法
https://blog.csdn.net/hanshanyeyu/article/details/78839266 List 是 Python 中常用的数据类型,它一个有序集合,即其中的元素始终保持 ...
- 图->存储结构->邻接表
文字描述 邻接表是图的一种链式存储结构.在邻接表中,对图中每个顶点建立一个单链表,第i个单链表的结点表示依附顶点vi的边(对有向图是指以顶点vi为尾的弧).单链表中的每个结点由3个域组成,其中邻接点域 ...
- quartz定时任务cron表达式详解
引用:https://www.cnblogs.com/lazyInsects/p/8075487.html cron表达式用于配置cronTrigger的实例.cron表达式实际上是由七个子表达式组成 ...
- g++编译多个文件
注意:头文件不用去指定,其是由#include命令进行管理的,只需要编译cpp文件就可以了: 举例: 有以下三个文件: a.h a.cpp main.cpp 那么编译可以有以下两种方式: 1.分开编译 ...
- 【JMeter】【接口测试】csv参数化,数据驱动,自动化测试
csv参数化,数据驱动 首先我们要有一个接口测试用例存放的地方,我们这里用EXCEL模板管理,里面包含用例编号.入参.优先级.请求方式.url等等. 1:新建一个txt文件,命名为sjqd,后缀名 ...
- react img 被自动转成base64,无法根据当前路径来动态改变值的解决办法
项目需求,需要根据当前的图片的路径值的来(加或者减)动态改变其值: state定义如下: this.state={ basket01:0+require("../../img/egg/egg ...