To reduce storage costs for infrequently accessed data — such as archived IoT sensor readings, historical order records, or application audit logs — assign cold storage to a table or column family in LindormTable. Data assigned to cold storage moves to Capacity storage and stops counting against your instance's default storage quota. This topic explains how to configure cold storage using Lindorm Shell or the ApsaraDB for HBase API for Java.
Limits
Cold storage requires LindormTable V2.1.8 or later.
Cold storage must be enabled on the Lindorm instance before you can configure it on a table or column family.
For read IOPS limits that apply to Capacity storage, see Limits on the read IOPS of Capacity storage.
Prerequisites
Before you begin, ensure that you have:
A Lindorm instance with cold storage enabled and LindormTable V2.1.8 or later
Lindorm Shell configured (for the Lindorm Shell method) — see Use Lindorm Shell to connect to LindormTable
ApsaraDB for HBase SDK for Java configured (for the Java method) — see Use ApsaraDB for HBase API for Java to develop applications
Configure cold storage using Lindorm Shell
Create a table with cold storage
When creating a table, set STORAGE_POLICY to COLD on the column family:
create 'coldTable', {NAME => 'f', STORAGE_POLICY => 'COLD'}Switch an existing column family to cold storage
Run alter to update the storage policy on an existing column family:
alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'COLD'}If the column family already contains data, the data is archived to cold storage only after a major compaction completes.
Switch back to hot storage
To revert a column family to the default hot storage tier:
alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'DEFAULT'}Configure cold storage using ApsaraDB for HBase API for Java
Create a table with cold storage
Set STORAGE_POLICY to AliHBaseConstants.STORAGETYPE_COLD on the column family descriptor before calling createTable:
Admin admin = connection.getAdmin();
HTableDescriptor descriptor = new HTableDescriptor(TableName.valueOf("coldTable"));
HColumnDescriptor cf = new HColumnDescriptor("f");
// Set the storage type of the column family to cold storage.
cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_COLD);
descriptor.addFamily(cf);
admin.createTable(descriptor);Switch an existing column family to cold storage
Retrieve the table descriptor, update the column family's storage policy, and call modifyTable:
Admin admin = connection.getAdmin();
TableName tableName = TableName.valueOf("coldTable");
HTableDescriptor descriptor = admin.getTableDescriptor(tableName);
HColumnDescriptor cf = descriptor.getFamily("f".getBytes());
// Set the storage type of the column family to cold storage.
cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_COLD);
admin.modifyTable(tableName, descriptor);If the column family already contains data, the data is archived to cold storage only after a major compaction completes.
Switch back to hot storage
Set STORAGE_POLICY to AliHBaseConstants.STORAGETYPE_DEFAULT to revert the column family to hot storage:
Admin admin = connection.getAdmin();
TableName tableName = TableName.valueOf("coldTable");
HTableDescriptor descriptor = admin.getTableDescriptor(tableName);
HColumnDescriptor cf = descriptor.getFamily("f".getBytes());
// Set the storage type of the column family to hot storage (default).
cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_DEFAULT);
admin.modifyTable(tableName, descriptor);