hdfs的命令_hbase shell命令

hdfs的命令_hbase shell命令hdfs命令InthislessononApacheHadoopHDFScommands,wewillgothroughthemostcommoncommandswhichareusedforHadoopadministrationandtomanagefilespresentonaHadoopcluster.在本课程中,有关Apach…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

hdfs命令

In this lesson on Apache Hadoop HDFS commands, we will go through the most common commands which are used for Hadoop administration and to manage files present on a Hadoop cluster.

在本课程中,有关Apache Hadoop HDFS命令的内容,我们将介绍最常用的命令,这些命令用于Hadoop管理和管理Hadoop集群上的文件。

HDFS命令 (HDFS Commands)

Hive commands can be run on any Hadoop cluster or you’re free to use any of the VMs offered by Hortonworks, Cloudera etc.

Hive命令可以在任何Hadoop群集上运行,或者您可以自由使用HortonworksCloudera等提供的任何VM。

In this guide, we will make use of Ubuntu 17.10 (GNU/Linux 4.13.0-37-generic x86_64) machine:

在本指南中,我们将使用Ubuntu 17.10(GNU / Linux 4.13.0-37-generic x86_64)计算机:

hadoop cluster ubuntu version

Ubuntu Version

Ubuntu版本

Finally, we will make use of Hadoop v3.0.1 for this lesson:

最后,本课将使用Hadoop v3.0.1:

Hadoop version

Hadoop version

Hadoop版本

Let’s get started.

让我们开始吧。

Hadoop HDFS命令 (Hadoop HDFS Commands)

We will start with some very basic help commands and go into more detail as we go through this lesson.

我们将从一些非常基本的帮助命令开始,并在本课程中进行更详细的介绍。

获取所有HDFS命令 (Getting all HDFS Commands)

The simplest help command for Hadoop HDFS is the following with which we get all the available commands in Hadoop and how to use them:

以下是Hadoop HDFS最简单的帮助命令,通过它我们可以获取Hadoop中所有可用的命令以及如何使用它们:

hadoop fs -help

Let’s see the output for this command:

让我们看一下该命令的输出:

HDFS commands fs help

Hadoop fs help

Hadoop fs帮助

The output was quite long actually as this prints all the available commands a brief on how to use those commands as well.

实际上,输出相当长,因为这会打印所有可用的命令,并简要说明如何使用这些命令。

有关特定Hadoop命令的帮助 (Help on specific Hadoop command)

The information printed from the last command was quite big as it printed all the commands. Finding help for a specific command is tricky in that output. Here is a command to narrow your search:

从最后一个命令打印的信息很大,因为它打印了所有命令。 在该输出中查找特定命令的帮助非常棘手。 这是缩小搜索范围的命令:

hadoop fs -help ls

Let’s see the output of this command:

让我们看一下该命令的输出:

Hadoop specific command guide

Hadoop specific command guide

Hadoop特定命令指南

特定Hadoop命令的用法 (Usage of specific Hadoop command)

to know the syntax of each command, we don’t need t go anywhere apart from the terminal itself. We can know the syntax of a command on how to use it, use the usage option:

要知道每个命令的语法,除了终端本身,我们不需要走任何地方。 我们可以使用用法选项来了解有关如何使用命令的语法:

hadoop fs -usage ls

Let’s see the output of this command:

让我们看一下该命令的输出:

Usage of HDFS Commands

Usage of Hadoop Command

Hadoop命令的用法

Apart from usage, it also shows all possible options for the command specified.

除用法外,它还显示指定命令的所有可能选项。

列出fs文件和目录 (Listing fs files and directories)

To list all the available files and subdirectories under default directory, just use the following command:

要列出默认目录下的所有可用文件和子目录,只需使用以下命令:

hadoop fs -ls

Let’s see the output for this command:

让我们看一下该命令的输出:

Listing all files

Listing all files

列出所有文件

We ran this in the root directory and that’s why the output.

我们在根目录中运行它,这就是输出的原因。

制作HDFS目录 (Making HDFS Directory)

We can make a new directory for Hadoop File System using the following command:

我们可以使用以下命令为Hadoop File System创建新目录:

hadoop fs -mkdir /root/journaldev_bigdata

Note that if you create a new directory inside the /user/ directory, Hadoop will have read/write permissions on the directory but with other directories, it only has read permission by default.

请注意,如果在/user/目录中创建一个新目录,则Hadoop将对该目录具有读/写权限,但对于其他目录,默认情况下它仅具有读权限。

将文件从本地文件系统复制到Hadoop FS (Copying file from Local file System to Hadoop FS)

To copy a file from Local file System to Hadoop FS, we can use a simple command:

要将文件从本地文件系统复制到Hadoop FS,我们可以使用一个简单的命令:

hadoop fs -copyFromLocal derby.log /root/journaldev_bigdata

Let’s see the output for this command:

让我们看一下该命令的输出:

Copy File from local fs to HDFS

Copy File from local fs to HDFS

将文件从本地fs复制到HDFS

If instead of copying the file, you just want to move it, just make use of the

如果您只想移动文件而不是复制文件,则只需使用
-moveFromLocal option.
-moveFromLocal选项。

磁盘使用情况 (Disk Usage)

We can see the disk usage of files under HDFS in a given directory with a simple option as shown:

我们可以通过一个简单的选项查看给定目录中HDFS下文件的磁盘使用情况,如下所示:

hadoop fs -du /root/journaldev_bigdata/

Let’s see the output for this command:

让我们看一下该命令的输出:

Disk Usage of a directory in HDFS

Disk Usage of a directory in HDFS

HDFS中目录的磁盘使用情况

If you simply want to check disk usage of complete HDFS, run the following command:

如果您只想检查完整HDFS的磁盘使用情况,请运行以下命令:

Let’s see the output for this command:

让我们看一下该命令的输出:

Disk Usage of complete HDFS

Disk Usage of complete HDFS

完整HDFS的磁盘使用情况

清空垃圾数据 (Empty Trash Data)

When we are sure that no files in the trash are usable, we can empty the trash in HDFS by deleting all files with the following command:

当我们确定垃圾箱中没有可用的文件时,我们可以通过使用以下命令删除所有文件来清空HDFS中的垃圾箱:

hadoop fs -expunge

This will simply delete all Trashed data in the HDFS and creates no output.

这将仅删除HDFS中的所有Trashed数据,并且不创建任何输出。

修改文件的复制因子 (Modifying replication factor for a file)

As we already know, replication factor is the count by which a file is replicated across as Hadoop cluster and in its HDFS. We can modify the replication factor of a file using the following command:

众所周知,复制因子是文件在Hadoop集群及其HDFS中被复制的计数。 我们可以使用以下命令修改文件的复制因子:

hadoop fs -setrep -w 1 /root/journaldev_bigdata/derby.log

Let’s see the output of this command:

让我们看一下该命令的输出:

Modify replication factor in HDFS

Modify replication factor in HDFS

修改HDFS中的复制因子

更新Hadoop目录权限 (Updating Hadoop Directory permissions)

If you face permission related issues in Hadoop, run the following command:

如果您在Hadoop中遇到与权限相关的问题,请运行以下命令:

hadoop fs -chmod 700 /root/journaldev_bigdata/

With this command, you can provide and formulate the permissions given to a HDFS directory and restrict its access.

使用此命令,您可以提供和制定授予HDFS目录的权限并限制其访问。

删除HDFS目录 (Removing HDFS Directory)

We can remove an entire HDFS directory using the rm command:

我们可以使用rm命令删除整个HDFS目录:

hadoop fs -rm -r /root/journaldev_bigdata

Let’s see the output for this command:

让我们看一下该命令的输出:

Removing directory from HDFS

Removing directory from HDFS

从HDFS移除目录

That’s all for a quick roundup on Hadoop HDFS commands.

这就是对Hadoop HDFS命令的快速总结。

翻译自: https://www.journaldev.com/20624/hdfs-commands

hdfs命令

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/185844.html原文链接:https://javaforall.net

(0)
上一篇 2022年10月4日 下午11:36
下一篇 2022年10月4日 下午11:46


相关推荐

  • python 高中信息技术 会考_今年9月,8年级将新增Python课程,3-9年级以及新高一的信息技术课都有变化···…[通俗易懂]

    python 高中信息技术 会考_今年9月,8年级将新增Python课程,3-9年级以及新高一的信息技术课都有变化···…[通俗易懂]原标题:今年9月,8年级将新增Python课程,3-9年级以及新高一的信息技术课都有变化···浙江省中小学信息技术课9月换新教材,新增PPT、H5、Python、大数据……等内容。浙江消息,今年9月份开始的新学期,三到九年级信息技术课将同步替换新器材。其中,新初二将新增Python编程课程内容。新高一信息技术编程语言由VB替换为Python,大数据、人工智能、程序设计与算法按照教材规划五六…

    2022年5月17日
    114
  • 计算机病毒永恒之蓝_永恒之蓝攻击win10

    计算机病毒永恒之蓝_永恒之蓝攻击win10做技术的要一直保持激情,和对新鲜事物的敏感性,从中寻找到快乐—-JobBird  最近永恒之蓝病毒肆虐,简直让电脑用户闻风丧胆,一旦中招真的是毁灭性的,虽然自己写不出来这么牛逼的程序,也没有这样的耐心去分析它究竟是怎么做到的,或者怎么解除威胁。基于技术宅的好奇心免不了对其指手画脚一番。  什么是病毒?  网上跟教科书上都有非常明确的定义,什么什么一大堆,看一下就过了,反正也

    2022年10月16日
    4
  • java timsort_Timsort算法浅析

    java timsort_Timsort算法浅析上一篇谈到的双轴快排 是 Arrays 对八种基本类型进行排序的算法 针对其它的对象类型 JDK1 6 及以前的版本使用的是归并排序 从 JDK1 7 开始 默认情况下会采用 Timsort 排序算法 而 Collections sort 实际上也是调用 Arrays sort 方法 现实中的大多数据通常是有部分已经排好序的 该算法利用这一特点提升了排序效率 下面将跟随 JDK1 8 源码 对 Timsort 的实现进行分析

    2026年3月19日
    3
  • 用webBrowser打开网页出现脚本错误怎么办

    当IE浏览器遇到脚本错误时,在浏览器左下角会出现一个黄色图标,点击可以查看脚本错误的详细信息,并不会有弹出的错误信息框。我们在用webBrowser编写的程序打开网页,遇到脚本有问题是,会弹出一个错误

    2021年12月27日
    42
  • BHO注册问题

    BHO注册问题BHO 在 Doc 窗口注册时 提示 regasm 不是内部或外部命令 也不是可运行的程序或批处理文件解决办法 1 转到需要注册的 dll 路径如 C GZ BHOHelloWord BHOHelloWord bin Debug BHOTestDemo dll 则在 DOS 下输入 cd nbsp C GZ BHOHelloWord BHOHelloWord bin Debug2 在 1 转到的目录下输

    2026年3月17日
    3
  • vim编辑器显示行数过多_vim查看指定行

    vim编辑器显示行数过多_vim查看指定行设置ubuntu的vim编辑器显示行数,方法如下:1.打开终端输入:sudovi/etc/vim/vimrc,打开vim的配置文件(使用sudo可忽视vimrc文件的readonly属性);2.在配置文件中,找到最底行,点击键盘a键,打开输入模式;3.输入:setnu,设置显示行数;4.点击键盘esc键,退出输入模式,点击shift+:,输入:wq,保存退出;至此所有用vim打开的…

    2025年7月21日
    7

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号