Skip to main content
Version: latest

Tiered Storage


Only Enterprise Edition supports

In the actual service scenario, there are multiple data disks on one machine at the same time. Therefore, it is necessary to give full play to the capabilities of these disks to improve the throughput of the system. Another scenario is that multiple data disks on the same or multiple machines use different storage media, and customers want to store cold data that is not frequently accessed move to cheap storage media to reduce the cost of enterprise storage. In CnosDB, we solve these two scenarios by the following solutions:

The basic unit of data migration in a CnosDB cluster is the Vnode.The enterprise version of CnosDB cluster provides the following commands to support hierarchical storage:

SHOW DATANODES;                          // 查看节点信息
| 1001 | | HOT | HEALTHY | 5.18 GB | 7.37 GB | 2023-06-05 02:30:22 |
| 1002 | | HOT | HEALTHY | 93.71 GB | 240.11 GB | 2023-06-05 02:30:19 |

ALTER NODE [node_id] ATTRIBUTE [HOT/COLD]; // 更改节点的属性
CREATE DATABASE [IF NOT EXISTS] db_name [WITH db_options];

db_option ...

db_option: {
TTL value
| SHARD value
| REPLICA value
| PRECISION {'ms' | 'us' | 'ns'}

Add a COOLING_DURATION value to the CREATE DATABASE statement to add a cooling time field. Add COOLING_DURATION value to the CREATE DATABASE statement to add a cooldown time field. option indicates the interval for data cooling, COOLING_DURATION defaults to 0, which means stopping data migration.

COOLING_DURATION must be an integer multiple of VNODE_DURATION. COOLING_DURATION must be a multiple of VNODE_DURATION. The COOLING_DURATION field can be modified by alter database.

After data is cooled, the migrate thread in meta will migrate data from hot nodes to cold nodes. The migrate thread periodically checks whether there is data to be migrated. The timing can be modified using the auto_migrate_vnodes_duration configuration item in the meta configuration file. The unit of this configuration item is seconds, and the default value is 0, which means that tiered storage is not enabled. The timing for periodic checks can be set according to practical needs. It is recommended to set the minimum check time to 1800 seconds, which is auto_migrate_vnodes_duration = 1800.


  • After data is cooled, data is migrated from the hot node to the cold node. However, the cooling degree of data is defined by users. Users can modify the cooling period of db to change the cooling degree of data.

  • Users change the db cool downtime. The change may migrate data from a cold node to a hot node, for example: When starting the cluster through ./ with default configuration, there are two data nodes in the cluster: 1001 and 2001, and both are hot nodes by default.

ALTER NODE 2001 ATTRIBUTE COLD;  // 修改data节点2001为冷节点

Then create a table and write data in the "db1" database, wait for a period of time until the data is cooled and migrated from hot node 1001 to cold node 2001. At this point, execute the SQL statement:

ALTER DATABASE db1 SET COOLING_DURATION '1d'; // 将数据库db1的冷却时间由上面的1分钟,改为1天

At this point, as the cool downtime becomes larger, the cooled data above becomes hot data again, so the data is moved from cold node 2001 to hot node 1001.