Skip to main content

Klustron Physical Backup and Restore

KlustronAbout 4 min

Klustron Physical Backup and Restore

Basic Concepts of Global Consistent Physical Backup & Restore

Physical backup: A backup of physical files of the database (data files, transaction log files, parameter files). Physical backups can be classified into offline backups (cold backups) and online backups (hot backups).

Klustron cluster supports online backup, where the database remains in a running state during the backup process, and application read and write operations are not blocked. Since the backup operation occurs on a slave node of the master-slave nodes, it has little impact on application performance.

1. Backup and Restore Architecture

Backup and restore target: storage cluster and metadata cluster

Backup and restore scheduling center: Cluster manager

Backup data storage: backup storage pool

Cluster backup execution unit: Node Manager

2. Basic Principles

Klustron Cluster Backup & Restore Working Principle

2.1 Backup Data Target

In the Klustron cluster, the metadata cluster stores the node information, table structure information, transaction information, backup and restore information of the entire cluster, which is the basis for the normal operation of the cluster. The metadata cluster adopts a high-availability architecture of one master and two slaves.

The storage cluster is responsible for storing business data, which is distributed among data shards. The storage cluster is composed of multiple shards, each of which has multiple replicas.

The data on the compute nodes is a subset of the metadata cluster data, and the compute nodes themselves are stateless and do not require separate backups.

Global consistent backups can back up all the data of the entire cluster (including all metadata and storage cluster data) or only part of the data, such as the data of a single storage shard.

2.2 Global Consistent Backup and Restore

Backup: At the beginning of the backup execution stage, the backup and restore manager obtains the global transaction information of the entire cluster from the metadata database, and then starts the backup. For each backup target, the data files and transaction logs of the backup target data need to be backed up at the same time. The database files and transaction logs during the backup are centrally stored in the backup resource pool (storage). After all files are copied, the backup is completed. The backup information is recorded in the metadata database. The cluster runs normally during the backup period and does not need to stop the business.

Restore: At the beginning of the restore execution stage, the backup and restore manager obtains the currently available backup information from the metadata database, and then copies the data from the backup resource pool to the restore target. After the data copying is completed, the transaction is rolled back or rolled forward according to the transaction log, so that the entire cluster is restored to a consistent state.

2.3 Backup Types

Full backup: backup all data of the backup target (data files and transaction logs), which is the basis of incremental backup.

Incremental backup: backup incremental data and transaction logs since the last backup.

Full backup: backup all data of the entire cluster (metadata and all storage cluster data).

Partial backup: only back up the data of a certain shard.

2.4 Restore Types

Full restore: restore the entire cluster

Partial restore: only restore a certain shard

Time-based restore: restore to a certain point in time

Transaction-based restore: restore based on a certain transaction number

3. Execution Steps

Backup

3.1 Set Backup Policy

Determine the backup object, backup type, and prepare the backup target storage.

3.2 Perform Backup

Schedule backup through command line or UI (Klustron provides Web interface)

[kunlun@kunlun-test6 util]$ backup --help
Usage of backup:
  -HdfsNameNodeService string
        specify the hdfs name node service, hdfs://ip:port
  -backuptype string
        back up storage node or 'compute' node,default is 'storage' (default "storage")
  -clustername string
        name of the cluster to be backuped
  -coldstoragetype string
        specify the coldback storage type: hdfs .. (default "hdfs")
  -etcfile string
        path to the etc file of the mysql instance to be backuped,
        if port is specified and the related instance is running,
        the tool will determine the etcfile path
  -port string
        the port of mysql or postgresql instance which to be backuped
  -shardname string
        name of the current shard
  -workdir string
        where store the backup data locally for temp use (default "./data")

3.3 Check the backup result to confirm that the backup is successful

Restore

3.4 Set Restore Policy

Determine the restore object, backup type, and prepare the backup target storage

3.5 Perform Restore

Restore operation command:

[kunlun@kunlun-test6 util]$ restore --help
Usage of restore:
  -HdfsNameNodeService string
        specify the hdfs name node service, hdfs://ip:port
  -enable-globalconsistent
        whether restore the new mysql under global consistent restrict
  -metaclusterconnstr string
        current meta cluster connection string e.g. user:pass@tcp(ip:port)/mysql
  -mysqletcfile string
        etc file of the mysql which to be restored, if port is provied and mysqld is alive ,no need
  -origclustername string
        source cluster name to be restored or backuped
  -origmetaclusterconnstr string
        orig meta cluster connection string e.g. user:pass@tcp(ip:port)/mysql
  -origshardname string
        source shard name to be restored
  -port string
        the port of mysql/postgresql instance which to be restored and needed to be running state
  -restoretime string
        time point the new mysql restore to
  -restoretype string
        restore storage node or 'compute' node,default is 'storage' (default "storage")
  -workdir string
        temporary work path to store the coldback or other type files if needed (default "./data")

3.6 Check the restore result to confirm that the restore is successful

4. Cluster Backup and Restore Demonstration

Demonstrate how to backup and restore a cluster in the Klustron UI interface

Environment Information:

The cluster to be backed up consists of a computing node, a shard (each shard consists of one master and two slaves) and a metadata cluster (one master and two slaves).

Data status before backup:

Step 1: Start Backup

Backup operation: Click the backup button in the cluster management interface to start the backup.

Step 2: Check Backup Status

Upon successful completion of the backup, user will see the message "backupcluster succeed" indicating that the backup has succeeded based on the execution time.

Step 3: Restore the Cluster

Select the time point to be restored, and then confirm the restore.

The cluster enters the restore state:

After the restore is completed, a new cluster will be created in the available resource area, and the backup data will be restored.

Restore status:

Restored cluster:

Enter the computing node of the restored cluster and check the restored data:

After the cluster is restored, the corresponding data is also correctly restored.

END