Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How Namenode forbids formatting

Shulou Source: shulou.com Published: 2022-06-02 06:30:29 11月13日 Update

How to prohibit formatting in Namenode? in view of this question, this article introduces in detail the corresponding analysis and answers, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

1 the purpose of document writing

As we all know, Namenode stores the metadata of Hadoop clusters, and Datanode stores data. If the Namenode is formatted, it means that all data from the entire cluster will be lost. Unless the metadata is backed up and can be recovered by technical means, the lost data will not be recovered, which is undoubtedly fatal to the cluster in the production environment. This article focuses on how to disable Namenode formatting and add a bit of security to your cluster.

Test environment:

Operating system version is CentOS 6.8,

Version 5.11.2 for CM and CDH

Article directory structure:

1. Purpose of document writing

two。 Disable Namenode formatting

2.1 from formatting to running away

2.2 configure advanced parameters

3. Parameter function verification

4. Summary

2 prohibit Namenode formatting 2.1 from formatting to running away

Even ordinary users can format your Namenode! Some people may think that as long as the root user rights of the operating system are well controlled, ordinary users cannot switch to hdfs users to execute commands, and Namenode seems to be safe. In fact, it is not, with a command, the average user can format your Namenode and run away.

The average user can switch to the hdfs user through the environment variable, and then execute the format command. Like this:

Export HADOOP_USER_NAME=hdfs

Hdfs namenode-format

I hope that after reading, do not go to other people's cluster format Namenode, if you do, advise you to run quickly, do not say that I taught you to format, remember.

2.2 configure advanced parameters

In the HDFS configuration interface, search for "hdfs-site.xml", find the Namenode advanced configuration code snippet (safety valve), add the contents in the red box, and set the value of the parameter "dfs.namenode.support.allow.format" (default is true) to false, indicating that namenode formatting is prohibited. Then save the configuration and restart HDFS and related services. If you are an operation and maintenance staff, the pillars of the company, it is strongly recommended to configure this parameter, or buy a good pair of shoes, it is easier to run.

3 functional verification of parameters

1. Choose a random Namenode to test and stop the Namenode

2. Format the Namenode

3. You can see that Namenode formatting failed.

4. The above figure may not directly show that the Namenode formatting failed due to configuration parameters. I wanted to capture some logs, but because that Namenode was stopped, the logs were not printed. But I finally found a diagram that intuitively illustrates the effect of disabling Namenode formatting parameters.

This is the answer to the question about how Namenode forbids formatting. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.

Tags: Format parameter user configuration data cluster normal advanced security command environment problem intuitive operating system content function available through document log more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Docker MariaDB Apple Shulou Tech Info