大数据平台运维之HDFS

HDFS

1.在HDFS文件系统的根目录下创建递归目录“1daoyun/file”,将附件中的BigDataSkills.txt文件,上传到1daoyun/file目录中,使用相关命令查看文件系统中1daoyun/file目录的文件列表信息,输出结果为。

[root@master ~]# hadoop fs -mkdir -p /1daoyun/file

[root@master ~]# hadoop fs -put BigDataSkills.txt/1daoyun/file

[root@master ~]# hadoop fs -ls /1daoyun/file 

Found 1 items

-rw-r--r--   3root hdfs         49 2017-05-06 09:57/1daoyun/file/BigDataSkills.txt

2.在HDFS文件系统的根目录下创建递归目录“1daoyun/file”,将附件中的BigDataSkills.txt文件,上传到1daoyun/file目录中,并使用HDFS文件系统检查工具检查文件是否受损,输出结果为。

[root@master ~]# hadoop fs -mkdir -p /1daoyun/file

[root@master ~]# hadoop fs -put BigDataSkills.txt/1daoyun/file

[root@master ~]# hadoop fsck/1daoyun/file/BigDataSkills.txt

DEPRECATED: Use of this script to execute hdfs commandis deprecated.

Instead use the hdfs command for it.

 

Connecting to namenode viahttp://master:50070/fsck?ugi=root&path=%2F1daoyun%2Ffile%2FBigDataSkills.txt

FSCK started by root (auth:SIMPLE) from /10.0.0.14 forpath /1daoyun/file/BigDataSkills.txt at Sun May 07 03:14:38 UTC 2017

.

/1daoyun/file/BigDataSkills.txt:  Under replicatedBP-90981007-192.168.101.10-1492713691966:blk_1073741906_1085. Target Replicasis 3 but found 2 live replica(s), 0 decommissioned replica(s) and 0decommissioning replica(s).

Status: HEALTHY

 Totalsize:    49 B

 Totaldirs:    0

 Totalfiles:   1

 Totalsymlinks:                0

 Total blocks(validated):      1 (avg. block size 49B)

 Minimallyreplicated blocks:   1 (100.0 %)

 Over-replicatedblocks:        0 (0.0 %)

 Under-replicated blocks:       1 (100.0 %)

 Mis-replicatedblocks:         0 (0.0 %)

 Defaultreplication factor:    3

 Average blockreplication:     2.0

 Corruptblocks:                0

 Missingreplicas:              1 (33.333332 %)

 Number ofdata-nodes:          2

 Number ofracks:               1

FSCK ended at Sun May 07 03:14:38 UTC 2017 in 6milliseconds

 

 

The filesystem under path'/1daoyun/file/BigDataSkills.txt' is HEALTHY

3.在HDFS文件系统的根目录下创建递归目录“1daoyun/file”,将附件中的BigDataSkills.txt文件,上传到1daoyun/file目录中,上传过程指定BigDataSkills.txt 文件在HDFS 文件系统中的复制因子为2,并使用fsck工具检查存储块的副本数,输出结果为。

 

[root@master ~]# hadoop fs -mkdir -p /1daoyun/file

[root@master ~]# hadoop fs -D dfs.replication=2 -putBigDataSkills.txt /1daoyun/file

[root@master ~]# hadoop fsck /1daoyun/file/BigDataSkills.txt

DEPRECATED: Use of this script to execute hdfs commandis deprecated.

Instead use the hdfs command for it.

 

Connecting to namenode viahttp://master:50070/fsck?ugi=root&path=%2F1daoyun%2Ffile%2FBigDataSkills.txt

FSCK started by root (auth:SIMPLE) from /10.0.0.14 forpath /1daoyun/file/BigDataSkills.txt at Sun May 07 09:39:44 UTC 2017

.Status: HEALTHY

 Totalsize:    32 B

 Totaldirs:    0

 Totalfiles:   1

 Totalsymlinks:                0

 Total blocks(validated):      1 (avg. block size 32B)

 Minimallyreplicated blocks:   1 (100.0 %)

 Over-replicatedblocks:        0 (0.0 %)

 Under-replicated blocks:       0 (0.0 %)

 Mis-replicatedblocks:         0 (0.0 %)

 Defaultreplication factor:    3

 Average blockreplication:     2.0

 Corruptblocks:                0

 Missingreplicas:              0 (0.0 %)

 Number ofdata-nodes:          2

 Number ofracks:               1

FSCK ended at Sun May 07 09:39:44 UTC 2017 in 0milliseconds

 

 

The filesystem under path '/1daoyun/file/BigDataSkills.txt'is HEALTHY

4.HDFS文件系统的根目录下存在一个/apps的文件目录,要求开启该目录的可创建快照功能,

并为该目录文件创建快照,快照名称为apps_1daoyun,使用相关命令查看该快照文件的列表信息,输出结果为。

 

一:

[root@master ~]# hadoop dfsadmin -allowSnapshot /apps

DEPRECATED: Use of this script to execute hdfs commandis deprecated.

Instead use the hdfs command for it.

 

Allowing snaphot on /apps succeeded

 

 

二:

[root@master ~]# hadoop dfsadmin -allowSnapshot /apps

Allowing snaphot on /apps succeeded

 

 

[root@master ~]# hadoop fs -createSnapshot /apps apps_1daoyun

Created snapshot /apps/.snapshot/apps_1daoyun

[root@master ~]# hadoop fs -ls /apps/.snapshot

Found 1 items

drwxrwxrwx   -hdfs hdfs          0 2017-05-07 09:48/apps/.snapshot/apps_1daoyun

5.HDFS文件系统的/user/root/small-file目录中存在一些小文件,要求使用Hadoop  Arachive工具将这些小文件归档成为一个文件,文件名为xiandian-data.har。归档完成后,查看xiandian-data.har的列表信息,输出结果为。

[root@master ~]# hadoop archive -archiveName xiandian-data.har-p /user/root/small-file /user/root/

 

[root@master ~]# hadoop fs -ls /user/root/xiandian-data.har

Found 4 items

-rw-r--r--   3root hdfs          0 2017-05-08 01:53/user/root/xiandian-data.har/_SUCCESS

-rw-r--r--   5root hdfs        735 2017-05-08 01:53/user/root/xiandian-data.har/_index

-rw-r--r--   5root hdfs         23 2017-05-08 01:53/user/root/xiandian-data.har/_masterindex

-rw-r--r--   3root hdfs        617 2017-05-08 01:53/user/root/xiandian-data.har/part-0

6.当Hadoop集群启动的时候,会首先进入到安全模式的状态,该模式默认30秒后退出。当

系统处于安全模式时,只能对HDFS 文件系统进行读取,无法进行写入修改删除等的操作。

现假设需要对Hadoop集群进行维护,需要使集群进入安全模式的状态,并检查其状态。将集群进入安全模式和检查安全模式状态的操作命令输出结果为中。

一:

[root@master ~]# hadoop dfsadmin -safemode enter

DEPRECATED: Use of this script to execute hdfs commandis deprecated.

Instead use the hdfs command for it.

 

Safe mode is ON

[root@master ~]# hadoop dfsadmin -safemode get

DEPRECATED: Use of this script to execute hdfs commandis deprecated.

Instead use the hdfs command for it.

 

Safe mode is ON

 

二:

[root@master ~]# hdfs dfsadmin -safemode enter

Safe mode is ON

[root@master ~]# hdfs dfsadmin -safemode get    

Safe mode is ON

7.为了防止操作人员误删文件,HDFS文件系统提供了回收站的功能,但过多的垃圾文件会占用大量的存储空间。要求在先电大数据平台的WEB界面将HDFS文件系统回收站中的文件彻底删除的时间间隔为7天,输出结果为。

高级 core-site

fs.trash.interval

10080

8.为了防止操作人员误删文件,HDFS文件系统提供了回收站的功能,但过多的垃圾文件会占用大量的存储空间。要求在Linux Shell中使用“vi”命令修改相应的配置文件以及参数信息,完成后,重启相应的服务。输出结果为

[root@master ]# vi/etc/hadoop/2.4.3.0-227/0/core-site.xml

   <property>

     <name>fs.trash.interval</name>

     <value>0</value>

   </property>

 

[root@master ~]# su - hdfs

Last login: Mon May 8 09:31:52 UTC 2017

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop namenode

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart namenode

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop datanode

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart datanode

9.为了防止操作人员误删文件,HDFS文件系统提供了回收站的功能,假设一名工程师发现自己前一天以root用户的身份不小心删除了HDFS文件系统中一个名为cetc55.txt的文件,现需要你使用find命令找到这个文件路径,并还原文件至原来的位置。完成后输出结果为。

[root@master ~]# hadoop fs -find / -name 'cetc55.txt'

/user/hdfs/.Trash/Current/data/cetc55.txt

/user/root/.Trash/Current/cetc55.txt

[root@master ~]# hadoop fs -mv/user/root/.Trash/Current/cetc55.txt /

10.Hadoop集群中的主机在某些情况下会出现宕机或者系统损坏的问题,一旦遇到这些问题, HDFS文件系统中的数据文件难免会产生损坏或者丢失,为了保证HDFS文件系统的可靠性,现需要在先电大数据平台的WEB界面将集群的冗余复制因子修改为5,以文本形式提交修改的参数信息和参数值输出结果为。

General

Block replication

5

11.Hadoop集群中的主机在某些情况下会出现宕机或者系统损坏的问题,一旦遇到这些问题, HDFS文件系统中的数据文件难免会产生损坏或者丢失,为了保证HDFS文件系统的可靠性,需要将集群的冗余复制因子修改为5,在Linux Shell中使用“vi”命令修改相应的配置文件以及参数信息,完成后,重启相应的服务。以文本形式提交以上操作命令和修改的参数信息输出结果为。

[root@master ~]# vi/etc/hadoop/2.4.3.0-227/0/hdfs-site.xml

 

   <property>

     <name>dfs.replication</name>

     <value>5</value>

   </property>

 

[root@master ~]# su - hdfs

Last login: Mon May 8 09:31:52 UTC 2017

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop namenode

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart namenode

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstop datanode

[hdfs@master ~]$/usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh --config /usr/hdp/current/hadoop-client/confstart datanode

猜你喜欢

转载自blog.csdn.net/kamroselee/article/details/80256002