centos升级默认node版本
最新版的elasticsearch 在装head插件的时候会报一个错误,这里需要升级下node版本就好了 npm install -g n n stable node -v v9.0.0 本文转自 shouhou2581314 51CTO博客,原文链接:http://blog.51cto.com/thedream/2047883,如需转载请自行联系原作者
1.使用示例程序实现单词统计
(1)wordcount程序
wordcount程序在hadoop的share目录下,如下:
|
1
2
3
4
5
6
7
8
9
|
[root@leaf mapreduce]
# pwd
/usr/local/hadoop/share/hadoop/mapreduce
[root@leaf mapreduce]
# ls
hadoop-mapreduce-client-app-2.6.5.jar hadoop-mapreduce-client-jobclient-2.6.5-tests.jar
hadoop-mapreduce-client-common-2.6.5.jar hadoop-mapreduce-client-shuffle-2.6.5.jar
hadoop-mapreduce-client-core-2.6.5.jar hadoop-mapreduce-examples-2.6.5.jar
hadoop-mapreduce-client-hs-2.6.5.jar lib
hadoop-mapreduce-client-hs-plugins-2.6.5.jar lib-examples
hadoop-mapreduce-client-jobclient-2.6.5.jar sources
|
就是这个hadoop-mapreduce-examples-2.6.5.jar程序。
(2)创建HDFS数据目录
创建一个目录,用于保存MapReduce任务的输入文件:
|
1
|
[root@leaf ~]
# hadoop fs -mkdir -p /data/wordcount
|
创建一个目录,用于保存MapReduce任务的输出文件:
|
1
|
[root@leaf ~]
# hadoop fs -mkdir /output
|
查看刚刚创建的两个目录:
|
1
2
3
|
[root@leaf ~]
# hadoop fs -ls /
drwxr-xr-x - root supergroup 0 2017-09-01 20:34
/data
drwxr-xr-x - root supergroup 0 2017-09-01 20:35
/output
|
(3)创建一个单词文件,并上传到HDFS
创建的单词文件如下:
|
1
2
3
4
5
6
|
[root@leaf ~]
# cat myword.txt
leaf yyh
yyh xpleaf
katy ling
yeyonghao leaf
xpleaf katy
|
上传该文件到HDFS中:
|
1
|
[root@leaf ~]
# hadoop fs -put myword.txt /data/wordcount
|
在HDFS中查看刚刚上传的文件及内容:
|
1
2
3
4
5
6
7
8
|
[root@leaf ~]
# hadoop fs -ls /data/wordcount
-rw-r--r-- 1 root supergroup 57 2017-09-01 20:40
/data/wordcount/myword
.txt
[root@leaf ~]
# hadoop fs -cat /data/wordcount/myword.txt
leaf yyh
yyh xpleaf
katy ling
yeyonghao leaf
xpleaf katy
|
(4)运行wordcount程序
执行如下命令:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
[root@leaf ~]
# hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.5.jar wordcount /data/wordcount /output/wordcount
...
17
/09/01
20:48:14 INFO mapreduce.Job: Job job_local1719603087_0001 completed successfully
17
/09/01
20:48:14 INFO mapreduce.Job: Counters: 38
File System Counters
FILE: Number of bytes
read
=585940
FILE: Number of bytes written=1099502
FILE: Number of
read
operations=0
FILE: Number of large
read
operations=0
FILE: Number of write operations=0
HDFS: Number of bytes
read
=114
HDFS: Number of bytes written=48
HDFS: Number of
read
operations=15
HDFS: Number of large
read
operations=0
HDFS: Number of write operations=4
Map-Reduce Framework
Map input records=5
Map output records=10
Map output bytes=97
Map output materialized bytes=78
Input
split
bytes=112
Combine input records=10
Combine output records=6
Reduce input
groups
=6
Reduce shuffle bytes=78
Reduce input records=6
Reduce output records=6
Spilled Records=12
Shuffled Maps =1
Failed Shuffles=0
Merged Map outputs=1
GC
time
elapsed (ms)=92
CPU
time
spent (ms)=0
Physical memory (bytes) snapshot=0
Virtual memory (bytes) snapshot=0
Total committed heap usage (bytes)=241049600
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=57
File Output Format Counters
Bytes Written=48
|
(5)查看统计结果
如下:
|
1
2
3
4
5
6
7
|
[root@leaf ~]
# hadoop fs -cat /output/wordcount/part-r-00000
katy 2
leaf 2
ling 1
xpleaf 2
yeyonghao 1
yyh 2
|
本文转自 xpleaf 51CTO博客,原文链接:http://blog.51cto.com/xpleaf/1962271,如需转载请自行联系原作者
微信关注我们
转载内容版权归作者及来源网站所有!
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。
Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。
Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。
Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。