Mapreduce统计

准备工作

1.创建hadoop用户

1.代码如下

$ sudo useradd -m hadoop -s /bin/bash

2.设置密码,添加管理员权限。

$ sudo passwd hadoop
$ sudo adduser hadoop sudo

3.更新apt

$ sudo apt-get update

4.安装配置文件VIM。

$ sudo apt-get install vim

5.安装SSH、配置SSH无密码登陆。

$ sudo apt-get install openssh-server

6.安装JAVA环境
下载文件jdk-8u162-linux-x64.tar.gz 使用Filezilla传输到“/home/linziyu/Downloads/”目录下。

$ cd /usr/lib
$ sudo mkdir jvm 
$ cd ~ #进入hadoop用户的主目录
$ cd Downloads 
$ sudo tar -zxvf ./jdk-8u162-linux-x64.tar.gz -C /usr/lib/jvm 

7.设置环境变量

$ cd ~
$ vim ~/.bashrc

8.继续执行如下命令让.bashrc文件的配置立即生效

$ source ~/.bashrc

2.安装eclipse

在ubuntu软件中心中下载安装

在 Eclipse 中创建 MapReduce 项目

1.在Eclipse中创建项目
在这里插入图片描述
在这里插入图片描述
在弹出来的 General 选项面板中,General 的设置要与 Hadoop 的配置一致。
在这里插入图片描述
在 Eclipse 中操作 HDFS 中的文件
配置好后,点击左侧 Project Explorer 中的 MapReduce Location 就能直接查看 HDFS 中的文件列表
在这里插入图片描述

源代码

public static void main(String[] args) throws Exception {
   
    Configuration conf = new Configuration();
    //*String[] otherArgs = (new GenericOptionsParser(conf, args)).getRemainingArgs();
    String[] otherArgs=new String[]{
   "input","outpu2"};
    if(otherArgs.length < 2) {
   
        System
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值