This topic describes how to enable the transparent compression feature in LindormDFS provided by ApsaraDB for Lindorm (Lindorm).

Prerequisites

When you purchase an instance, you must select Capacity for the Storage Type parameter.
Note Only the files created after the transparent compression feature is enabled are compressed. The files created before the feature is enabled are not compressed.

Enable the transparent compression feature

  1. Use open source HDFS clients to access LindormDFS.
  2. Run the following command to enable the transparent compression feature for a data directory:
    hdfs dfs -setfattr -n user.lhdfs_compress_enabled /<Data directory path> 
    If you want to disable the transparent compression feature of a data directory, you can run the following command:
    hdfs dfs -setfattr -x user.lhdfs_compress_enabled /<Data directory path>
  3. Run the following command to check whether the transparent compression feature is enabled for a data directory:
    hdfs dfs -getfattr -d /<Data directory path>
    If the following query result is returned, the transparent compression feature is enabled.
    $ hdfs dfs -getfattr -d hdfs://ld-xxxx/tmp
    # file: hdfs://ld-xxxx/tmp
    user.lhdfs_compress_enabled

View the result of transparent compression

  1. Log on to the Lindorm console.
  2. On the Instance List page, find the ID of the instance for which the transparent compression feature is enabled, and click the instance ID.
  3. In the left-side navigation pane, choose File Engine > Cluster Management.
  4. On the UI Access page, click ClusterManager.
    UI access
    Note If you are accessing the cluster management system for the first time, you must reset the password used to access the system UI.
  5. In the menu bar of the cluster management system, choose Utilities > Browse the file system.
  6. On the Browse Directory page, use the following methods to view the sizes of a data directory or a file before and after compression:
    • View the sizes of a data directory before and after compression.
      In the Directory Usage section, enter the path of the data directory in the search box and click GO!.Then, you can check the result. The following figure shows an example of the query result. In the example, the size of the /tmp path before the data in the directory is compressed is 960.89 GB. The size after the data in the directory is compressed is 857.37 GB. Directory Usage
    • View the size of a file before and after compression.
      In the Directory Usage section, enter the path of the file in the search box and click GO!.Then, you can check the result. The following figure shows an example of the query result. In the example, the size of the file in the /tmp/terasort/data/1000g_1/part-r-01216 path before the file is compressed is 476.84 MB. The size after the file is compressed is 175.77 MB. Directory Usage