Point-In-Time Recovery


SDS Point-In-Time Recovery 提供比快照更细粒度的数据备份与恢复机制。开启此功能后,您可以将表的状态恢复到任意指定的时间点。Point-In-Time Recovery基于Stream机制,开启Point-In-Time Recovery的表,后台会定期创建队列的checkpoint,记录了某个时间点在队列中的offset,您可以指定小于最小checkpoint的某个时间戳,将表恢复到此时间戳的状态。

配置项

  • topicName : 队列名,需要在此topic上开启stream
  • snapshotPeriod : 快照周期
  • ttl : 快照过期时间
  • createdTimestamp : 创建时间戳
  • enablePointInTimeRecovery : 开关
  • timeToArchive: 快照归档到fds的时间

使用流程

  • 在Talos中创建topic
  • 建表或更新表schema时,以topic名作为输入,添加并开启Stream,同时添加并开启Point-In-Time Recovery
  • 向表中生产数据
  • 指定时间戳ts, 把表恢复到ts时间点的状态
  • 通过listSnapshots()的返回结果中的pitrSnapshots查看PointInTimeRecovery已存在的快照,找到小于ts的最近的快照, 如该快照已归档到fds,需联系我们进行恢复,否则可以通过restoreSnapshot 自行恢复
  • 通过getFloorStreamCheckpoint(), 找到比快照时间小的最大的checkPoint
  • 根据checkPoint重放队列中的修改日志到快照恢复的表,且根据消息中的时间戳,只重放不大于ts的修改日志

接口

  • listSnapshots(tableName),可以通过返回值的pitrSnapshots查看PointInTimeRecovery已存在的快照
  • getFloorStreamCheckpoint(ts), 查询小于等于某个时间戳的最大stream checkpoint
  • restoreSnapshot(tableName, snapshotName, destTableName, snapshotType), 恢复表, destTableName为恢复出的表名,snapshotType选PITR

需要注意的问题

  • 快照最小周期是1天,最大个数是5,(暂定为5,可调整)
  • 快照归档到fds的时间, 最小为1个月

示例

示例表为例,下面给出修改表的示例代码

$tableName = "php-note";
$tableSpec = $adminClient->describeTable($tableName);

$tableSpec->metadata->pitr = new PointInTimeRecovery(array(
    'enablePointInTimeRecovery' => true,
    'topicName' => 'test-pirt-topic',
    'ttl' => 7776000,
    'snapshotPeriod' => 2592000,
    'timeToArchive' => 7776000
));

$adminClient->alterTable($tableName, $tableSpec);

results matching ""

    No results matching ""