namenode hdfs
We have a running HDFS cluster. Currently, the NameNode metadata data directory has only one directory configured in hdfs-site.xml:
我们有一个正在运行的HDFS集群。 当前,NameNode元数据数据目录只有在hdfs-site.xml中配置的一个目录:
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///home/hadoop/hdfs/</value>
<description>NameNode directory for namespace and transaction logs storage.</description>
</property>
We would like to add a new directory for dfs.namenode.name.dir
to make replicas of the metadata on a separated disk for higher data reliability.
我们想为dfs.namenode.name.dir
添加一个新目录,以在分离的磁盘上复制元数据,以提高数据可靠性。
How to safely add the new directory?
如何安全地添加新目录?
Backup first as the NameNode metadata directory contains critical data for the HDFS cluster.
首先备份为NameNode元数据目录,其中包含HDFS群集的关键数据。
Then following these steps.
然后按照以下步骤。
First, shutdown the NameNode.
首先, 关闭NameNode。
Second, copy the files from the old NameNode metadata directory to the new metadata directory. Such as to /home/hadoop/hdfs2,
其次,将文件从旧的NameNode元数据目录复制到新的元数据目录。 例如到/ home / hadoop / hdfs2,
cp -r /home/hadoop/hdfs/* /home/hadoop/hdfs2/
Third, add the new metadata directory to hdfs-site.xml:
第三,将新的元数据目录添加到hdfs-site.xml中:
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///home/hadoop/hdfs/, file:///home/hadoop/hdfs2/</value>
<description>NameNode directory for namespace and transaction logs storage.</description>
</property>
Last, restart the NameNode.
最后,重新启动NameNode。
namenode hdfs