如何使用gedit打开HDFS输出文件? [英] How to open HDFS output file using gedit?
问题描述
我已经在系统(Ubuntu 14.04)中成功安装并执行了mapreduce程序.
I have installed and executed an mapreduce program successfully in my system(Ubuntu 14.04).
我可以看到输出文件为
hadoopuser@arul-PC:/usr/local/hadoop$ bin/hadoop dfs -ls /user/hadoopuser/MapReduceSample-output
Found 3 items
-rw-r--r-- 1 hadoopuser supergroup 0 2014-07-09 16:10 /user/hadoopuser/MapReduceSample-output/_SUCCESS
drwxr-xr-x - hadoopuser supergroup 0 2014-07-09 16:10 /user/hadoopuser/MapReduceSample-output/_logs
-rw-r--r-- 1 hadoopuser supergroup 880838 2014-07-09 16:10 /user/hadoopuser/MapReduceSample-output/part-00000
然后我可以使用以下命令在终端上打开它,
And I can open it on terminal using following command,
hadoopuser@arul-PC:/usr/local/hadoop$ bin/hadoop dfs -cat /user/hadoopuser/MapReduceSample-output/part-00000
我可以在终端上看到输出文件,但是我看不到完整的结果,因为我的输出有很多行.
I can see the output file on terminal, but I can't see the full result because my output has large amount of lines.
所以我想在 gedit
或 nano
上打开它.
So I want to open it on gedit
or nano
.
需要解决方案.
推荐答案
您无法从本地计算机(系统用户)访问HDFS文件,因此无法使用 gedit
打开HDFS文件
You can't access HDFS file from local machine(system user), so that you can't open HDFS file using gedit
.
要在 gedit
中打开,您必须复制到本地计算机.
To open in gedit
you have to copy to local machine.
为此,请打开终端( Ctrl + Alt + T ),然后使用 copyToLocal
a Hadoop Shell命令,将输出文件复制到本地计算机.
To do that, open terminal(Ctrl+Alt+T) and use copyToLocal
a Hadoop Shell Command to copy the output file into local machine.
执行以下操作,
hadoopuser@arul-PC:/usr/local/hadoop$ sudo bin/hadoop dfs -copyToLocal /user/hadoopuser/MapReduceSample-output/part-00000 /home/arul/Downloads/
现在您可以使用 gedit
如下打开输出文件,
Now you can open the output file using gedit
as follows,
$ sudo gedit /home/arul/Downloads/part-00000
注意:
- 我的 HDFS 用户名是
hadoopuser
. - 您可以将文件从 HDFS 移至本地计算机. Hadoop Shell命令
fs -mv
允许移动不同的HDFS位置. - 更多信息 Hadoop Shell命令(单击此处) .
- My HDFS username is
hadoopuser
. - You can move a file from HDFS to local machine. The Hadoop Shell Command
fs -mv
allow to move different HDFS location. - For more Hadoop Shell Commands(click here).
更新(从 Y-Prithvi 的帖子)
Update (An another option to do the same from Y-Prithvi's post)
您还可以使用getmerge将HDFS文件复制到本地系统.
you can also use getmerge to copy HDFS file to local system.
hadoopuser@arul-PC:/usr/local/hadoop$ bin/hadoop dfs -getmerge /user/hadoopuser/MapReduceSample-output/part-00000 /home/arul/MROutput
hadoop dfs -getmerge /path/to/HDFS /path/to/save
这篇关于如何使用gedit打开HDFS输出文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!