Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

IX. Usage of HDFS security mode, snapshot, recycle bin, quota management

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

I. Security mode

When hdfs initially starts the cluster, it is in safe mode, internally checking whether the replica rate in the cluster meets the replica rate configured in the configuration file.

1. If it is not satisfied, it is necessary to meet the replication rate through replication between nodes before exiting the security mode.

If it is greater than the configured copy rate, it will reduce the copy rate by deleting more copies.

Check the condition of safe mode:

hdfs dfsadmin -safemode get|enter|leave|wait

Note:

In safe mode, you cannot write or modify files in hdfs, only read them.

1. Setting the minimum copy condition dfs.replication.min, The default is 1.

This is a backup of a directory in hdfs. By default, snapshots are turned off for each directory, so if you want to create snapshots for that directory, you have to turn snapshots on for that directory.

Open snapshot:

hdfs dfsadmin -allowSnapshot

Close Snapshot:

hdfs dfsadmin -disallowSnapshot

Displays all directories where snapshots can be created:

hdfs lsSnapshottableDir

Compare two snapshots where they differ:

//Compare the difference between two snapshots of a directory hdfs snapshotDiff Snapshot directory Snapshot 1 Snapshot 2//Compare the difference between directory and snapshot, the middle one ". "indicates the current directory, hdfs snapshotDiff snapshot directory cannot be omitted. snapshot 1

Create a snapshot:

//Directory of snapshots Name of snapshot (optional) hdfs dfs -createSnapshot [] The state of the snapshot created is stored in the directory where the snapshot was created under.snapshot//

Delete snapshot:

//Directory of snapshots Name of snapshot (required, as a directory may have multiple snapshots)hdfs dfs -deleteSnapshot

Rename snapshot:

//Directory of snapshots The name of the snapshot (must be present, as a directory may have multiple snapshots)hdfs dfs -renameSnapshot

Recover content from snapshots:

You can view all files and directories directly from/.snapshot//and copy any file you need. snapshotDir is the directory where the snapshot was created.

Recycle Bin is closed by default, you need to set it to open in the configuration file

1. Open the recycling bin

Modify core-site.xml and restart hdfs

fs.trash.interval 2 fs.trash.checkpoint.interval 12. View Recycle Bin

After opening the Recycle Bin, when we delete hdfs files, the deleted files will be moved to/user/USERNAME/.trash/Current/in hdfs, where USERNAME is the user name of the current operation hdfs. So it's actually a shearing operation.

Note:

Files deleted by the program are not moved to the Recycle Bin and need to be explicitly moved to the Recycle Bin. If it is through the command line, it will be moved to the recycle bin.

3. Move files to Recycle Bin through program//Create Recycle Bin object Trash tsh = new Trash(conf);Path path = new Path(pathString);//Move specified files to Recycle Bin tsh.moveToTrash(path);4. Empty Recycle Bin hdfs-expunge5. Recover files from Recycle Bin

Cut directly from the recycle bin path to the specified path

4. Quota//name Quota, simply put, is the limit on the total number of files and directories under the directory hdfs dfsadmin -setQuota N HDFS directory 1 HDFS directory 2... Set Name Quota hdfs dfsadmin -clrQuota HDFS Directory 1 HDFS Directory 2... Cancel name quota//space quota, simply put, the storage space limit of the directory hdfs dfsadmin -setSpaceQuota N units (e.g.:1GB) [-storageType ] HDFS directory 1 HDFS directory 2... Set Space Quota hdfs dfsadmin -clrSpaceQuota [-storageType ] HDFS Directory 1 HDFS Directory 2... Unquota where storageType has the following types: RAW-DISK: Original physical disk DISK: Partition Space SSD: SSD ARCHIVE:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report