Configure cold storage
Lindorm uses Capacity cloud storage as the storage medium for cold data. After you enable the cold storage feature, you need to configure the tables or column families in the database. This topic describes how to configure cold storage.
Background information
The cold storage feature is supported only by Lindorm engines of version 2.1.8 or later. Lindorm allows you to configure storage attributes at the table level. You can set the storage type of an entire table or a specific column family to cold storage. When a table or column family is configured as cold storage, the data is stored in Capacity cloud storage and does not consume the default storage space of the instance.
For information about the performance of Capacity cloud storage, see Introduction to Capacity-Oriented Cloud Storage.
Configure cold storage
You can configure a table or column family in the database as cold storage in either of the following ways:
Configure cold storage by using HBase Shell. Before you begin, download and configure the shell. For more information, see Connect to LindormTable with Lindorm Shell.
When you create a table, run the following statement to configure cold storage.
create 'coldTable', {NAME => 'f', STORAGE_POLICY => 'COLD'}If the table has already been created, you can configure cold storage on a column family by modifying the properties of the column family.
ImportantIf the column family already contains data, the data is moved to cold storage only after a major compaction is completed.
alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'COLD'}To reset the table back to hot storage, run the following statement.
alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'DEFAULT'}
Configure cold storage by using HBase Java API. Before you begin, install and configure the SDK. For more information, see Use ApsaraDB for HBase API for Java to develop applications.
When you create a table, run the following statement to configure cold storage.
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 the table has already been created, you can configure cold storage on a column family by modifying the properties of the column family.
ImportantIf the column family already contains data, the data is moved to cold storage only after a major compaction is completed.
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 table to cold storage. cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_COLD); admin.modifyTable(tableName, descriptor);To reset the table back to hot storage, run the following statement.
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 table to the default storage. The default storage is hot storage. cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_DEFAULT); admin.modifyTable(tableName, descriptor);