All Products
Search
Document Center

Lindorm:Configure cold storage

Last Updated:Apr 22, 2024

After you enable the cold storage feature of Lindorm, you must configure tables or column families in your Lindorm database. This topic describes how to configure cold storage.

Background information

The cold storage feature is available only for the Lindorm engine whose version is V2.1.8 or later. Lindorm allows you to configure the storage property for each table. You can configure storage settings to store the data of an entire table or a column family in cold storage. In this case, all the data of the table or this column family is stored in cold storage and does not occupy the default storage of the instance.

Configure cold storage

You can use the following methods to configure cold storage for a table or a column family:

  • Use HBase Shell to configure cold storage. Before you configure cold storage, download and configure HBase Shell. For more information, see Use Lindorm Shell to connect to LindormTable.

    • When you create a table, execute the following statement to configure cold storage for the table:

      create 'coldTable', {NAME => 'f', STORAGE_POLICY => 'COLD'}
    • If you have created a table, you can modify the property of a column family in the table to use cold storage.

      Important

      If the column family contains data, the data is archived to cold storage only after a major compaction.

      alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'COLD'}
    • If you want to store the data from the table in hot storage, execute the following statement:

      alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'DEFAULT'} 
  • Use the HBase Java API to configure cold storage. Before you configure cold storage, download and configure HBase Shell. For more information, see Use ApsaraDB for HBase API for Java to develop applications.

    • When you create a table, execute the following statement to configure cold storage for the table:

      Admin admin = connection.getAdmin();
       HTableDescriptor descriptor = new HTableDescriptor(TableName.valueOf("coldTable"));
       HColumnDescriptor cf = new HColumnDescriptor("f");
       cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_COLD);
       descriptor.addFamily(cf);
       admin.createTable(descriptor);
    • If you have created a table, you can modify the property of a column family in the table to use cold storage.

      Important

      If the column family contains data, the data is archived to cold storage only after a major compaction.

      Admin admin = connection.getAdmin();
      TableName tableName = TableName.valueOf("coldTable");
      HTableDescriptor descriptor = admin.getTableDescriptor(tableName);
      HColumnDescriptor cf = descriptor.getFamily("f".getBytes());
      // Configure the storage type of the table to cold storage.
      cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_COLD);
      admin.modifyTable(tableName, descriptor);
    • If you want to store the data from the table in hot storage, execute the following statement:

      Admin admin = connection.getAdmin();
      TableName tableName = TableName.valueOf("coldTable");
      HTableDescriptor descriptor = admin.getTableDescriptor(tableName);
      HColumnDescriptor cf = descriptor.getFamily("f".getBytes());
      // Configure the storage type of the table to the default storage. By default, hot storage is used.
      cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_DEFAULT);
      admin.modifyTable(tableName, descriptor);