Hadoop单机环境搭建
程序员文章站
2022-07-15 18:40:24
...
说明:单机环境—仅仅适用于单击运行分布式计算作业,直接执行mapreduce-examples.jar案例。
1.首先到官网下载好hadoop压缩包,上传到Linux上,解压
2.修改主机名
[[email protected] ~]# hostnamectl set-hostname server
[[email protected] ~]# reboot #重启生效
3.设置主机与ip间的映射
[[email protected] ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.100 server
4.新建一个输出目录
[[email protected] ~]# cd hadoop/hadoop-2.7.3/
[[email protected] hadoop-2.7.3]# mkdir input
5.拷贝etc/hadoop/下的.xml文件到输出目录
[[email protected] hadoop-2.7.3]# cp etc/hadoop/*.xml input/
[[email protected] hadoop-2.7.3]# ls input/
capacity-scheduler.xml hadoop-policy.xml httpfs-site.xml kms-site.xml
core-site.xml hdfs-site.xml kms-acls.xml yarn-site.xml
[[email protected] hadoop-2.7.3]#
6.运行hadoop简单案例
格式:/bin/hadoop jar 案例的相对路径 主方法 输入目录 输出目录 正则表达式(输出目录不需要创建,执行会自动创建)
[[email protected] hadoop-2.7.3]# bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar grep input/ output 'dfs[a-z.]+'
Total committed heap usage (bytes)=1399808000
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=26007
File Output Format Counters
Bytes Written=123
7.查看输出目录,_SUCCESS说明案例运行成功
[[email protected] hadoop-2.7.3]# ls output/
part-r-00000 _SUCCESS
[[email protected] hadoop-2.7.3]#
上一篇: java练习 继承02
下一篇: 面试题:编写一个截取字符串的函数