hadoop 打jar包,在linux下运行

来源:互联网 发布:美萍数据库密码 编辑:程序博客网 时间:2024/05/19 05:38
1、在linux系统中,所在目录“/home/kcm”下创建一个文件input
  [ubuntu@701~]$ mkdir input

2.在文件夹input中创建两个文本文件file1.txt和file2.txt,file1.txt中内容是“hello word”,file2.txt中内容是“hello hadoop”、“hello mapreduce”(分两行)。
  [ubuntu@701~]$ cd input
  [ubuntu@701~]$ vi file1.txt(编辑文件并保存)
  [ubuntu@701~]$ vi file2.txt(编辑文件并保存)
  [ubuntu@701~]$ ls -l /home/kcm/input
  file1.txt file2.txt
  显示文件内容可用:
  [ubuntu@701~]$ cat/home/kcm/input/file1.txt
  hello word
  [ubuntu@701~]$ cat /home/kcm/input/file2.txt
  hello mapreduce
  hello hadoop

3.在HDFS上创建输入文件夹wc_input,并将本地文件夹input中的两个文本文件上传到集群的wc_input下
  [ubuntu@701~]$ hadoop fs -mkdir wc_input
  [ubuntu@701~]$ hadoop fs -put/home/kcm/input/file* wc_input
  查看wc_input中的文件:
  [ubuntu@701~]$ /hadoop fs -ls wc_input
  Found 2 items
  -rw-r--r-- 1 root supergroup 11 2014-03-13 01:19 /user/hadoop/wc_input/file1.txt
  -rw-r--r-- 1 root supergroup 29 2014-03-13 01:19 /user/hadoop/wc_input/file2.txt

4.首先,在window下将wordcount进行打包,我们这里把它打包成wordcount.jar;然后,将wordcount.jar拷贝到linux系统中,存放的目录自己决定即可。我们这里存放到/home/kcm目录下面。
5.运行wordcount.jar包(转到该jar包存放的目录下):
  [ubuntu@701~]$ hadoop jar wordcount.jar /user/hadoop/wc_input /user/hadoop/output
0 0
原创粉丝点击