Lindorm uses Capacity storage to store cold data that is infrequently accessed. After you enable cold storage for a Lindorm instance, you can configure whether to store a table or a column family in a table by using cold storage. This topic describes how to configure cold storage for a table or a column family.
Background information
The cold storage feature is supported only by LindormTable V2.1.8 or later versions. Lindorm allows you to configure the storage attributes of a single table. You can configure whether to store a table or a column family by using cold storage. If you store a table or a column family by using cold storage, data in the table or column family is stored in Capacity storage and does not occupy the default storage capacity of the Lindorm instance.
For more information about Capacity storage, see Limits on the read IOPS of Capacity storage.
Configuration methods
You can use the following methods to configure cold storage for a table or a column family:
Use Lindorm Shell to configure cold storage. Before you configure cold storage, download and configure Lindorm 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 attribute of a column family in the table to store the column family by using cold storage.
ImportantIf the column family contains data, the data is archived to cold storage only after a major compaction operation.
alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'COLD'}
If you want to store the data in the table by using hot storage, execute the following statement:
alter 'coldTable', {NAME=>'f', STORAGE_POLICY => 'DEFAULT'}
Use the ApsaraDB for HBase API for Java to configure cold storage. Before you configure cold storage, download and configure ApsaraDB for HBase SDK for Java. 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 attribute of a column family in the table to store the column family by using cold storage.
ImportantIf the column family contains data, the data is archived to cold storage only after a major compaction operation.
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);
If you want to store the data in the table by using 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()); // Set the storage type of the table to hot storage, which is the default value. cf.setValue("STORAGE_POLICY", AliHBaseConstants.STORAGETYPE_DEFAULT); admin.modifyTable(tableName, descriptor);