4_尚硅谷大数据之Hadoop运行模式.pdfVIP

  • 32
  • 0
  • 约2.18万字
  • 约 21页
  • 2018-04-15 发布于湖北
  • 举报
4_尚硅谷大数据之Hadoop运行模式.pdf

四 Hadoop 运行模式 Hadoop 运行模式包括:本地模式、伪分布式模式以及完全分布式模式。 Hadoop 官方网站:/ 4.1 本地运行模式 4.1.1 官方grep 案例 1)创建在hadoop-2.7.2 文件下面创建一个input 文件夹 [atguigu@hadoop101 hadoop-2.7.2]$ mkdir input 2 )将hadoop 的xml 配置文件复制到input [atguigu@hadoop101 hadoop-2.7.2]$ cp etc/hadoop/*.xml input 3 )执行share 目录下的mapreduce 程序 [atguigu@hadoop101 hadoop-2.7.2]$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar grep input output dfs[a-z.]+ 4 )查看输出结果 [atguigu@hadoop101 hadoop-2.7.2]$ cat output/* 4.1.2 官方wordcount 案例 1)创建在hadoop-2.7.2 文件下面创建一个wcinput 文件夹 [atguigu@hadoop101 hadoop-2.7.2]$ mkdir wcinput 2 )在wcinput 文件下创建一个wc.input 文件 [atguigu@hadoop101 hadoop-2.7.2]$ cd wcinput [atguigu@hadoop101 wcinput]$ touch wc.input 3 )编辑wc.input 文件 [atguigu@hadoop101 wcinput]$ vi wc.input 在文件中输入如下内容 hadoop yarn hadoop mapreduce atguigu atguigu 保存退出::wq 4 )回到hadoop 目录/opt/module/hadoop-2.7.2 5 )执行程序: [atguigu@hadoop101 hadoop-2.7.2]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount wcinput wcoutput 6 )查看结果: [atguigu@hadoop101 hadoop-2.7.2]$ cat wcoutput/part-r-00000 atguigu 2 hadoop 2 mapreduce 1 yarn 1 4.2 伪分布式运行模式 4.2.1 启动HDFS 并运行MapReduce 程序 1)分析: (1)配置集群 (2 )启动、测试集群增、删、查 (3 )执行wordcount 案例 2 )执行步骤 (1)配置集群 (a )配置:hadoop-env.sh Linux 系统中获取jdk 的安装路径: [atguigu@ hadoop101 ~]# echo $JAVA_HOME /opt/module/jdk1.8.0_144 修改JAVA_HOME 路径: export JAVA_HOME=/opt/module/jdk1.8.0_144 (b )配置:core-site.xml !-- 指定HDFS 中NameNode 的地址 -- property namefs.defaultFS/name valuehdfs://hadoop101:9000/value /property !-- 指定hadoop 运行时产生文件的存储目录 -- property

文档评论(0)

1亿VIP精品文档

相关文档