Mount an Apsara File Storage for HDFS file system
This topic describes how to mount and uninstall an Apsara File Storage for HDFS file system.
Prerequisites
The Java Development Kit (JDK) 1.8 or later is installed on your ECS instance.
You have created an Apsara File Storage for HDFS file system and added a mount target. For more information, see Create a file system and Add a mount target.
A Hadoop client is installed. Hadoop 2.7.2 or later is recommended. To download Hadoop, see Hadoop Releases.
Mounting instructions
If the mount target uses the virtual private cloud (VPC) network type, you can mount the file system only on an ECS instance that resides in the same VPC. Additionally, the authorized address in the permission group attached to the mount target must include the IP address of the ECS instance.
Mount the file system
Connect to the ECS instance. For more information, see Connect to an ECS instance.
Configure the core-site.xml file.
Run the following command to open the core-site.xml file.
vim ${HADOOP_HOME}/etc/hadoop/core-site.xmlIf you have not configured the
${HADOOP_HOME}environment variable, run the following command to set it to your Hadoop installation directory.export HADOOP_HOME=/your/hadoop/installation/directoryIn the core-site.xml file, add the following configuration.
<property> <name>fs.defaultFS</name> <value>dfs://f-xxxxxxxx.cn-xxxxx.dfs.aliyuncs.com:10290</value> </property> <property> <name>fs.dfs.impl</name> <value>com.alibaba.dfs.DistributedFileSystem</value> </property> <property> <name>fs.AbstractFileSystem.dfs.impl</name> <value>com.alibaba.dfs.DFS</value> </property>In the preceding configuration, replace
f-xxxxxxxx.cn-xxxxx.dfs.aliyuncs.comwith the mount target address of your Apsara File Storage for HDFS file system.Optional: Adjust the core-site.xml configuration to optimize cluster performance. For more information, see Best practices for performance optimization.
Synchronize the core-site.xml file across all nodes.
Deploy the Apsara File Storage for HDFS Java software development kit (SDK).
Download the latest Apsara File Storage for HDFS Java SDK.
Add the downloaded Apsara File Storage for HDFS Java SDK to the CLASSPATH of the Hadoop Distributed File System (HDFS) component.
cp aliyun-sdk-dfs-x.y.z.jar ${HADOOP_HOME}/share/hadoop/hdfsSynchronize the Apsara File Storage for HDFS Java SDK across all nodes.
Run the following command to verify that the file system is mounted.
Run the command.
${HADOOP_HOME}/bin/hadoop fs -dfSample output
If the output is similar to the following, the Apsara File Storage for HDFS file system is mounted.
Filesystem Size Used Available Use% dfs://f-e389e5c7e****.cn-hangzhou.dfs.aliyuncs.com:10290 10995116277760 0 10995116277760 0% 22/09/20 14:19:04 INFO dfs.DistributedFileSystem: FileSystem close com.alibaba.dfs.DistributedFileSystem@51ee79a3 22/09/20 14:19:04 INFO dfs.DfsClient: DfsClient close Client-6676663918471637276 22/09/20 14:19:04 INFO common.LeaseRenewer: close all files being written 22/09/20 14:19:04 INFO common.LeaseRenewer: LeaseRenwerForClient-6676663918471637276 closed
Uninstalling a file system
If you no longer need to use the Apsara File Storage for HDFS file system, you must uninstall it. To do so, refer to Mount file systems, delete all deployed Apsara File Storage for HDFS Java SDKs, and delete all Apsara File Storage for HDFS-related configurations from all core-site.xml files.
If you want to release the Apsara File Storage for HDFS file system instance, see Delete a file system.
After you release a file system instance, the data stored in the file system is deleted and cannot be recovered. Before you release the instance, make sure that you no longer need the data.