From 5d10e97f1dc31dd7b24d17d8cb218c0b548b86c1 Mon Sep 17 00:00:00 2001 From: yangj1211 Date: Mon, 28 Oct 2024 18:10:22 +0800 Subject: [PATCH 1/7] add doc of snapshot and pitr --- .../backup-restore/backup-restore-overview.md | 12 +- .../mobr-pitr-backup-restore.md | 231 +++++++++ .../mobr-snapshot-backup-restore.md | 98 +++- .../mobr-backup-restore/mobr.md | 471 +++++++++++++++--- .../Data-Definition-Language/alter-pitr.md | 52 ++ .../Data-Definition-Language/create-pitr.md | 96 ++++ .../create-snapshot.md | 42 +- .../Data-Definition-Language/drop-pitr.md | 31 ++ .../Data-Definition-Language/restore-pitr.md | 262 ++++++++++ ...restore-account.md => restore-snapshot.md} | 75 ++- .../Other/SHOW-Statements/show-pitr.md | 37 ++ mkdocs.yml | 10 +- 12 files changed, 1303 insertions(+), 114 deletions(-) create mode 100644 docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-pitr-backup-restore.md create mode 100644 docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-pitr.md create mode 100644 docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-pitr.md create mode 100644 docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-pitr.md create mode 100644 docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md rename docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/{restore-account.md => restore-snapshot.md} (75%) create mode 100644 docs/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-pitr.md diff --git a/docs/MatrixOne/Maintain/backup-restore/backup-restore-overview.md b/docs/MatrixOne/Maintain/backup-restore/backup-restore-overview.md index 4d1e149b2f..bbe6ca3ed8 100644 --- a/docs/MatrixOne/Maintain/backup-restore/backup-restore-overview.md +++ b/docs/MatrixOne/Maintain/backup-restore/backup-restore-overview.md @@ -81,17 +81,21 @@ MatrixOne 支持使用 `LOAD DATA` 命令将大量行插入数据库表,也支 #### 使用 `mo_br` 备份与恢复 -MatrixOne 支持使用 `mo_br` 工具进行常规物理备份和快照备份。 +MatrixOne 支持使用 `mo_br` 工具进行常规物理备份、快照备份和 PITR 备份。 操作步骤及示例,参见 [`mo-br 使用指南`](../backup-restore/mobr-backup-restore/mobr.md) #### 使用 SQL 备份与恢复 -MatrixOne 支持使用 SQL 进行快照备份与恢复。 +MatrixOne 支持使用 SQL 进行快照、PITR 备份与恢复。 -有关使用 SQL 进行快照备份与恢复的方法,请参考文档: +有关使用 SQL 进行快照、PITR 备份与恢复的方法,请参考文档: - [CREATE SNAPSHOT](../../Reference/SQL-Reference/Data-Definition-Language/create-snapshot.md) - [DROP SNAPSHOT](../../Reference/SQL-Reference/Data-Definition-Language/drop-snapshot.md) - [SHOW SNAPSHOTS](../../Reference/SQL-Reference/Data-Definition-Language/create-snapshot.md) -- [RESTORE ACCOUNT](../../Reference/SQL-Reference/Data-Definition-Language/restore-account.md) +- [RESTORE ... FROM SNAPSHOT](../../Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md) +- [CREATE PITR](../../Reference/SQL-Reference/Data-Definition-Language/create-pitr.md) +- [DROP PITR](../../Reference/SQL-Reference/Data-Definition-Language/drop-pitr.md) +- [SHOW PITR](../../Reference/SQL-Reference/Data-Definition-Language/create-pitr.md) +- [RESTORE ... FROM PITR](../../Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md) diff --git a/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-pitr-backup-restore.md b/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-pitr-backup-restore.md new file mode 100644 index 0000000000..3191d4769d --- /dev/null +++ b/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-pitr-backup-restore.md @@ -0,0 +1,231 @@ +# mo_br 工具进行 PITR 备份恢复 + +## PITR 备份恢复实现原理 + +PITR(时间点恢复)备份恢复的实现基于完整备份和增量日志,通过记录数据库的事务操作并应用这些增量日志,系统可以将数据库恢复到指定的时间点。恢复过程首先从完整备份开始,将数据库还原到基础状态,然后依次应用增量日志中的事务,直至达到目标时间点,从而实现精确的数据恢复。这种机制有效应对因误操作或故障导致的数据丢失,保障数据库的完整性和一致性。 + +## 应用场景 + +PITR 是数据库管理中常见的一个功能,主要用于恢复数据库到某个特定的时间点,通常用于以下场景: + +- **误操作恢复:**当数据库中的某些数据被误删除、误修改或误操作时,可以使用 PITR 将数据库恢复到误操作之前的状态,避免数据丢失。 + +- **灾难恢复:**在遭遇数据库灾难性故障(如硬件故障、软件错误、自然灾害等)后,PITR 可以帮助将数据库恢复到故障发生前的某个时间点,保证业务连续性和数据完整性。 + +- **数据审核和合规性:**对于需要进行数据审计或需要遵守数据保留政策的企业和组织,PITR 可以提供历史数据的恢复和查看功能,以满足合规性要求。 + +- **测试和开发环境管理:**在开发和测试过程中,PITR 可以帮助恢复数据库到之前的测试数据集,以支持测试用例的重复运行和开发环境的管理。 + +- **数据库备份管理:**与常规备份结合使用,PITR 可以提供更细粒度的恢复选项,使得恢复过程更加灵活和精确。 + +## MatrixOne 对 PITR 的支持 + +MatrixOne 支持以下两种方式进行 PITR: + +- sql 语句 +- mo_br 工具 + +本篇文档主要介绍如何使用 `mo_br` 进行 PITR。 + +!!! note + mo_br 企业级服务的备份与恢复工具,你需要联系你的 MatrixOne 客户经理,获取工具下载路径。 + +## 开始前准备 + +- 已完成[单机部署 MatrixOne](../../../Get-Started/install-standalone-matrixone.md) + +- 已完成 mo_br 工具部署 + +## 示例 + +一家大型 SaaS 供应商管理一个多租户环境,提供各种服务给不同的业务客户。这些租户通过集群托管其数据库,存储业务关键数据。一天,系统管理员在进行升级操作时,意外触发了一些错误的脚本操作,影响到了不同租户的多个数据库和表。为了确保系统能尽快恢复并减少数据丢失,团队决定 PITR 进行恢复。 + +### 创建业务数据 + +该系统下有 acc1 和 acc2 两个租户,表示不同的客户,每个租户下面有商品信息和订单信息。 + +```sql +create account acc1 admin_name 'root' identified by '111'; +create account acc2 admin_name 'root' identified by '111'; + +#连接acc1 +create database db1; +use db1; +--创建商品表,用于存储商品信息 +CREATE TABLE products ( + id INT PRIMARY KEY AUTO_INCREMENT, + product_name VARCHAR(100) NOT NULL, + category VARCHAR(50), + price DECIMAL(10, 2) NOT NULL, + stock_quantity INT NOT NULL +); + +INSERT INTO products (product_name, category, price, stock_quantity) VALUES +('Gaming Laptop', 'Electronics', 1200.99, 30), +('Wireless Mouse', 'Accessories', 25.50, 100), +('Mechanical Keyboard', 'Accessories', 75.00, 50), +('Smartphone', 'Electronics', 699.99, 50), +('Headphones', 'Accessories', 199.99, 80), +('Tablet', 'Electronics', 299.99, 40), +('Smartwatch', 'Accessories', 149.99, 60), +('Charger', 'Accessories', 19.99, 200), +('Webcam', 'Electronics', 59.99, 75); + +create database db2; +use db2; +--创建一张用于存储客户订单的表 +CREATE TABLE orders ( + id int PRIMARY KEY auto_increment, + product_name VARCHAR(100) NOT NULL, + quantity INT NOT NULL, + order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +INSERT INTO orders (product_name, quantity) VALUES +('Laptop', 2), +('Mouse', 5), +('Keyboard', 3); + +#连接acc2 +create database db1; +use db1; +--创建商品表,用于存储商品信息 +CREATE TABLE products ( + id INT PRIMARY KEY AUTO_INCREMENT, + product_name VARCHAR(100) NOT NULL, + category VARCHAR(50), + price DECIMAL(10, 2) NOT NULL, + stock_quantity INT NOT NULL +); + +INSERT INTO products (product_name, category, price, stock_quantity) VALUES +('Gaming Laptop', 'Electronics', 1200.99, 30), +('Wireless Mouse', 'Accessories', 25.50, 100), +('Mechanical Keyboard', 'Accessories', 75.00, 50), +('Smartphone', 'Electronics', 699.99, 50), +('Headphones', 'Accessories', 199.99, 80), +('Tablet', 'Electronics', 299.99, 40), +('Smartwatch', 'Accessories', 149.99, 60), +('Charger', 'Accessories', 19.99, 200), +('Webcam', 'Electronics', 59.99, 75); + +create database db2; +use db2; +--创建一张用于存储客户订单的表 +CREATE TABLE orders ( + id int PRIMARY KEY auto_increment, + product_name VARCHAR(100) NOT NULL, + quantity INT NOT NULL, + order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +INSERT INTO orders (product_name, quantity) VALUES +('Smartphone', 10), +('Headphones', 15), +('Tablet', 7); +``` + +### 创建 pitr + +```bash +#创建集群级别的pitr +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "root" --password "111" --pname "pitr1" --level "cluster" --rangevalue 1 --rangeunit "d" + +>./mo_br pitr show --host "127.0.0.1" --port 6001 --user "dump" --password "111" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr1 2024-10-28 17:22:26 2024-10-28 17:22:26 cluster * * * 1 d + +#创建acc1租户级别的pitr +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "acc1#root" --password "111" --pname "pitr2" --level "account" --account "acc1" --rangevalue 10 --rangeunit "h" + +>./mo_br pitr show --host "127.0.0.1" --port 6001 --user "acc1#root" --password "111" --account "acc1" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr2 2024-10-28 17:24:18 2024-10-28 17:24:18 account acc1 * * 10 h + +#创建acc2租户级别的pitr +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "acc2#root" --password "111" --pname "pitr3" --level "account" --account "acc2" --rangevalue 10 --rangeunit "h" + + +>./mo_br pitr show --host "127.0.0.1" --port 6001 --user "acc2#root" --password "111" --account "acc2" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr3 2024-10-28 17:25:32 2024-10-28 17:25:32 account acc2 * * 10 h +``` + +### 模拟升级错误 + +由于升级脚本错误导致 acc1 下的 db1 和 db2 都被删除,acc2 下的 db1 被删除,db2 下的 orders 表数据被清空。 + +```sql +--在 acc1 下执行 +drop database db1; +drop database db2; + +--在 acc2 下执行 +drop database db1; +use db2; +truncate table orders; +``` + +### 恢复 pitr + +- 为 acc1 进行整个租户的恢复 + + ```bash + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc1#root" --password "111" --pname "pitr2" --timestamp "2024-10-28 17:30:00" --account "acc1" + ``` + + 连接 acc1 查询,可以看到数据成功恢复 + + ```sql + mysql> show databases; + +--------------------+ + | Database | + +--------------------+ + | db1 | + | db2 | + | information_schema | + | mo_catalog | + | mysql | + | system | + | system_metrics | + +--------------------+ + 7 rows in set (0.01 sec) + ``` + +- 为 acc2 进行库表级别的恢复 + + ```bash + #恢复 db1 + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc2#root" --password "111" --pname "pitr3" --timestamp "2024-10-28 17:30:00" --account "acc2" --database "db1" + + #恢复 orders 表 + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc2#root" --password "111" --pname "pitr3" --timestamp "2024-10-28 17:30:00" --account "acc2" --database "db2" --table "orders" + ``` + + 连接 acc2 查询,可以看到数据成功恢复 + + ```sql + mysql> show databases; + +--------------------+ + | Database | + +--------------------+ + | db1 | + | db2 | + | information_schema | + | mo_catalog | + | mysql | + | system | + | system_metrics | + +--------------------+ + 7 rows in set (0.01 sec) + + mysql> select * from db2.orders; + +------+--------------+----------+---------------------+ + | id | product_name | quantity | order_date | + +------+--------------+----------+---------------------+ + | 1 | Smartphone | 10 | 2024-10-28 17:11:27 | + | 2 | Headphones | 15 | 2024-10-28 17:11:27 | + | 3 | Tablet | 7 | 2024-10-28 17:11:27 | + +------+--------------+----------+---------------------+ + 3 rows in set (0.00 sec) + ``` diff --git a/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore.md b/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore.md index a4f8a2ede8..9c7768d274 100644 --- a/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore.md +++ b/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore.md @@ -20,12 +20,12 @@ ## MatrixOne 对快照的支持 -MatrixOne 支持以下两种方式进行租户级别的快照备份恢复: +MatrixOne 支持以下两种方式进行快照备份恢复: - sql 语句 - mo_br 工具 -本篇文档主要介绍如何使用 `mo_br` 进行租户级别快照备份恢复。 +本篇文档主要介绍如何使用 `mo_br` 进行集群/租户级别的快照备份恢复。 !!! note mo_br 企业级服务的备份与恢复工具,你需要联系你的 MatrixOne 客户经理,获取工具下载路径。 @@ -58,7 +58,7 @@ mysql> select count(*) from snapshot_read.test_snapshot_read; - 创建快照 -``` +```bash ./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --level "account" --sname "sp_01" --account "sys" ./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" @@ -81,7 +81,7 @@ mysql> select count(*) from snapshot_read.test_snapshot_read; - 表级别恢复到本租户 -``` +```bash ./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --db "snapshot_read" --table "test_snapshot_read" --sname "sp_01" ``` @@ -127,7 +127,7 @@ mysql> select count(*) from snapshot_read.test_snapshot_read_1; - 创建快照 -``` +```bash ./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --level "account" --sname "sp_02" --account "sys" ./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" @@ -160,7 +160,7 @@ mysql> select count(*) from snapshot_read.test_snapshot_read_1; - 数据库级别恢复到本租户 -``` +```bash ./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --db "snapshot_read" --sname "sp_02" ``` @@ -209,16 +209,6 @@ mysql> show databases; 8 rows in set (0.00 sec) ``` -- 创建快照 - -``` -./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --level "account" --sname "sp_03" --account "sys" - -./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "dump" --password "111" -SNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME -sp_03 2024-05-11 03:20:16.065685 account sys -``` - - 连接 Matrixone 系统租户删除数据库 ```sql @@ -241,13 +231,13 @@ mysql> show databases; - 租户级别恢复到本租户 -``` +```bash ./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --sname "sp_03" ``` - 租户级别恢复到新租户 -``` +```bash ./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --sname "sp_03" --new_account "acc2" --new_admin_name "admin" --new_admin_password "111"; ``` @@ -285,4 +275,76 @@ mysql> show databases; | system_metrics | +--------------------+ 6 rows in set (0.00 sec) +``` + +## 示例 4 集群级别恢复 + +```sql +--在租户 acc1,acc2 下执行 +create database db1; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) +``` + +- 创建快照 + +```bash +./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "root" --password "111" --level "cluster" --sname "cluster_sp1" + +(base) admin@192 mo-backup % ./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --cluster "sys" +SNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME +cluster_sp1 2024-10-14 03:52:55.657359 cluster +``` + +- 连接 Matrixone 系统租户删除数据库 + +```sql +--在租户 acc1,acc2 下执行 +drop database db1; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +5 rows in set (0.01 sec) +``` + +- 恢复 + +```bash +./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "root" --password "111" --sname "cluster_sp1" +``` + +- 连接租户 acc1,acc2 查询恢复情况 + +```sql +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) ``` \ No newline at end of file diff --git a/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr.md b/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr.md index c6a643211d..e6c3920b3e 100644 --- a/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr.md +++ b/docs/MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr.md @@ -45,30 +45,17 @@ Use "mo_br [command] --help" for more information about a command. #### 语法结构 ``` -mo_br backup - --host - --port - --user - --password - --backup_dir s3|filesystem - //s3 oss minio - --endpoint - --access_key_id - --secret_access_key - --bucket - --filepath - --region - --compression - --role_arn - --is_minio - --parallelism - //filesystem - --path - --parallelism - --meta_path - //增量备份需要 - --backup_type - --base_id +mo_cdc task create + --task-name 同步任务名称. + --source-uri 源端(mo)连接串 + --sink-type 下游类型 + --sink-uri 下游标识资源 + --tables 需要同步的表名 + --level cluster|account 选定同步的表的范围,集群/租户, + 1.3只支持account. 指定cluster报错。 + 1.3可以不需要此参数,因为1.3只做租户级别 + --account 同步的租户,当level为 account 时需指定 + --no-full 可选,默认开启全量,添加此参数表示全量关闭 ``` **参数说明** @@ -99,20 +86,20 @@ mo_br backup - 全量备份到本地文件系统 -``` -./mo_br backup --host "127.0.0.1" --port 6001 --user "dump" --password "111" --backup_dir "filesystem" --path "yourpath" +```bash +./mo_br backup --host "127.0.0.1" --port 6001 --user "root" --password "111" --backup_dir "filesystem" --path "yourpath" ``` - 全量备份到 minio -``` -./mo_br backup --host "127.0.0.1" --port 6001 --user "dump" --password "111" --backup_dir "s3" --endpoint "http://127.0.0.1:9000" --access_key_id "S0kwLuB4JofVEIAxWTqf" --secret_access_key "X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A" --bucket "bucket1" --filepath "/backup1" --is_minio +```bash +./mo_br backup --host "127.0.0.1" --port 6001 --user "root" --password "111" --backup_dir "s3" --endpoint "http://127.0.0.1:9000" --access_key_id "S0kwLuB4JofVEIAxWTqf" --secret_access_key "X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A" --bucket "bucket1" --filepath "/backup1" --is_minio ``` - 增量备份到本地文件系统 -``` -./mo_br backup --host "127.0.0.1" --port 6001 --user "dump" --password "111" --backup_dir "filesystem" --path "yourpath" --backup_type "incremental" --base_id "xxx" +```bash +./mo_br backup --host "127.0.0.1" --port 6001 --user "root" --password "111" --backup_dir "filesystem" --path "yourpath" --backup_type "incremental" --base_id "xxx" ``` ### 查看备份 @@ -143,7 +130,7 @@ mo_br list - 查看所有备份列表 -``` +```bash ./mo_br list +--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+ | ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | @@ -157,7 +144,7 @@ mo_br list - 查看指定 ID 备份列表,list 确定的 ID 时,会检测备份的文件。 -``` +```bash ./mo_br list 4d21b228-10dd-11ef-9497-26dd28356ef2 +--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+ | ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | @@ -205,13 +192,13 @@ mo_br delete ID - 删除本地文件系统备份 -``` +```bash ./mo_br delete e4cade26-3139-11ee-8631-acde48001122 ``` - 删除 minio 上的一个备份。 -``` +```bash ./mo_br delete e4cade26-3139-11ee-8631-acde48001122 --access_key_id "S0kwLuB4JofVEIAxWTqf" --secret_access_key "X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A" ``` @@ -363,7 +350,7 @@ mo_br restore - 校验某个 ID 的备份 -``` +```bash mo_br check ID //校验指定ID的备份数据。如果备份在s3(oss minio)上时,需要指定 --backup_access_key_id string @@ -420,7 +407,7 @@ mo_br check - 校验某个 ID 的备份 -``` +```bash ./mo_br check 1614f462-126c-11ef-9af3-26dd28356ef3 +--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+ | ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | @@ -442,7 +429,7 @@ check: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e - 校验某个备份目录中的备份 -``` +```bash (base) admin@admindeMacBook-Pro mo-backup % ./mo_br check --backup_dir filesystem --backup_path /Users/admin/soft/incbackup/back2 2024/05/15 11:40:30.011160 +0800 INFO malloc/malloc.go:42 malloc {"max buffer size": 1073741824, "num shards": 16, "classes": 23, "min class size": 128, "max class size": 1048576, "buffer objects per class": 23} check: /backup_meta @@ -480,25 +467,31 @@ mo_br snapshot create |port|端口号| |user | 用户| |password | 用户的密码| -|level | 快照备份的范围,暂只支持 account| -|account| 快照备份的租户对象名| +|level | 快照备份的范围,account|cluster| +|account| 快照备份的租户对象名,cluster 级别无需填写此参数| |sname | 快照名称| #### 示例 -- 为系统租户 sys 创建快照: +- 集群管理员创建集群级别快照: -``` -./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --level "account" --sname "snapshot_01" --account "sys" +```bash +./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "root" --password "111" --level "cluster" --sname "cluster_sp1" ``` -- 系统租户为普通租户 acc1 创建快照: +- 系统租户管理员为系统租户 sys 创建租户级别快照: +```bash +./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "root" --password "111" --level "account" --sname "snapshot_01" --account "sys" ``` - ./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --level "account" --sname "snapshot_02" --account "acc1" + +- 系统租户管理员为普通租户 acc1 创建租户级别快照: + +```bash + ./mo_br snapshot create --host "127.0.0.1" --port 6001 --user "root" --password "111" --level "account" --sname "snapshot_02" --account "acc1" ``` -- 普通租户创建快照: +- 普通租户管理员创建租户级别快照: - 创建普通租户 acc1 @@ -522,6 +515,7 @@ mo_br snapshot show --port --user --password + --cluster --account --db --table @@ -538,6 +532,7 @@ mo_br snapshot show |port|端口号| |user | 用户| |password | 用户的密码| +|cluster|固定填写 sys,其他值不生效,仅 sys 管理员使用| |account| 要筛选的租户名,仅限 sys 管理员使用| |db | 要筛选的数据库名| |table | 要筛选的表名| @@ -547,27 +542,27 @@ mo_br snapshot show #### 示例 -- 查看系统租户下创建的快照: +- 查看系统租户管理员下创建的快照: -``` -./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "dump" --password "111" +```bash +./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "root" --password "111" SNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME snapshot_02 2024-05-11 02:29:23.07401 account acc1 snapshot_01 2024-05-11 02:26:03.462462 account sys ``` -- 查看 acc1 下创建的快照: +- 查看普通租户管理员在 acc1 下创建的快照: -``` +```bash ./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "acc1#admin" --password "111" SNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME snapshot_03 2024-05-11 02:29:31.572512 account acc1 ``` -- 查看系统租户下为租户 acc1 创建的快照,并对开始时间进行筛选: +- 查看系统租户管理员下为租户 acc1 创建的快照,并对开始时间进行筛选: -``` -./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "acc1" --beginTs "2024-05-11 00:00:00" +```bash +./mo_br snapshot show --host "127.0.0.1" --port 6001 --user "root" --password "111" --account "acc1" --beginTs "2024-05-11 00:00:00" SNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME snapshot_02 2024-05-11 02:29:23.07401 account acc1 ``` @@ -597,15 +592,15 @@ mo_br snapshot drop #### 示例 -- 删除系统租户创建的快照: +- 删除系统管理员创建的快照: -``` -./mo_br snapshot drop --host "127.0.0.1" --port 6001 --user "dump" --password "111" --sname "snapshot_01" +```bash +./mo_br snapshot drop --host "127.0.0.1" --port 6001 --user "root" --password "111" --sname "snapshot_01" ``` -- 删除普通租户创建的快照: +- 删除普通租户管理员创建的快照: -``` +```bash ./mo_br snapshot drop --host "127.0.0.1" --port 6001 --user "acc1#admin" --password "111" --sname "snapshot_03" ``` @@ -648,26 +643,370 @@ __NOTE__: 只有系统租户才可以执行恢复数据到新租户,且只允 #### 示例 -- 表级别恢复到本租户 +- 表级别恢复 +```bash +./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "root" --password "111" --account "sys" --db "snapshot_read" --table "test_snapshot_read" --sname "sp_01" ``` -./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --db "snapshot_read" --table "test_snapshot_read" --sname "sp_01" + +- 数据库级别恢复 + +```bash +./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "root" --password "111" --account "sys" --db "snapshot_read" --sname "sp_02" ``` -- 数据库级别恢复到本租户 +- 租户级别恢复到本租户 +```bash +./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "root" --password "111" --account "sys" --sname "sp_03" ``` -./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --db "snapshot_read" --sname "sp_02" + +- 租户级别恢复到新租户 + +```bash +./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "root" --password "111" --account "sys" --sname "sp_03" --new_account "acc2" --new_admin_name "admin" --new_admin_password "111"; ``` -- 租户级别恢复到本租户 +- 集群级别恢复 +```bash +./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "root" --password "111" --sname "cluster_sp1" ``` -./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --sname "sp_03" + +## PITR 备份 + +### 创建 PITR + +#### 语法结构 + +``` +mo_br pitr create + --host + --port + --user + --password + --pname + --level + --account + --database + --table + --rangevalue + --rangeunit ``` -- 租户级别恢复到新租户 +**参数说明** + +| 参数 | 说明 | +| ---- | ---- | +|host | 目标 MatrixOne 的 IP| +|port|端口号| +|user | 用户| +|password | 用户的密码| +|pname | pitr 名字| +|level | 备份的范围,cluster | account | database | table,level 等于高层级时,低层级的对象名不需要也不能填写,例如 level = account,则 database 和 table 不能填写| +|account| 备份的租户名| +|database| 备份的租数据库名| +|table| 备份的表名| +|rangevalue|时间范围值,1-100| +|rangeunit| 时间范围单位,可选范围 h(小时)、d(天,默认)、mo(月)、y(年)| + +#### 示例 + +- 集群级别 + +只有系统租户才能创建集群级别的 pitr。 + +``` +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "root" --password "111" --pname "pitr01" --level "cluster" --rangevalue 10 --rangeunit "h" +``` + +- 租户级别 + +系统租户可以为自己和其它租户创建租户级别的 pitr。 + +```bash +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr02" --level "account" --account "sys" --rangevalue 1 --rangeunit "d" + +mo create account acc01 admin_name = 'test_account' identified by '111'; +mo create account acc02 admin_name = 'test_account' identified by '111'; + +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr015" --level "account" --account "acc01" --rangevalue 1 --rangeunit "y" + +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr016" --level "account" --account "acc02" --rangevalue 1 --rangeunit "y" +``` + +普通租户只能为自己创建租户级别的 pitr。 + +```bash +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr07" --level "account" --account "acc01" --rangevalue 1 --rangeunit "h" +``` + +- 数据库级别 + +```bash +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr011" --level "database" --account "sys" --database "abc" --rangevalue 1 --rangeunit "y" +``` + +- 表级别 + +```bash +./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr011" --level "database" --account "sys" --database "abc" --rangevalue 1 --rangeunit "y" +``` + +### 查看 PITR + +#### 语法结构 + +``` +mo_br pitr show + --hostname + --port + --user + --password + --cluster + --account + --database + --table +``` + +**参数说明** + +| 参数 | 说明 | +| ---- | ---- | +|host | 目标 MatrixOne 的 IP| +|port|端口号| +|user | 用户| +|password | 用户的密码| +|pname | pitr 名字| +|cluster | 固定填写 sys,其他值不生效,仅 sys 管理员使用| +|account| 备份的租户名| +|database| 备份的租数据库名| +|table| 备份的表名| + +#### 示例 + +- 查看所有 pitr + +```bash +./mo_br pitr show --host "127.0.0.1" --port 6001 --user "dump" --password "111" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr016 2024-08-08 06:55:40 2024-08-08 06:55:40 account acc02 * * 1 y +pitr015 2024-08-08 06:55:04 2024-08-08 06:55:04 account acc01 * * 1 y +pitr012 2024-08-08 06:52:30 2024-08-08 06:52:30 table sys abc test 1 y +pitr011 2024-08-08 06:50:43 2024-08-08 06:50:43 database sys abc * 1 y +pitr05 2024-08-08 06:45:56 2024-08-08 06:45:56 account sys * * 1 y +pitr04 2024-08-08 06:45:52 2024-08-08 06:45:52 account sys * * 1 mo +pitr03 2024-08-08 06:45:42 2024-08-08 06:45:42 account sys * * 1 d +pitr02 2024-08-08 06:45:25 2024-08-08 06:45:25 account sys * * 1 h +pitr01 2024-08-08 06:32:31 2024-08-08 06:32:31 cluster * * * 10 h +``` + +- 查看集群级别 pitr + +```bash +./mo_br pitr show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --cluster "sys" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr01 2024-08-08 06:32:31 2024-08-08 06:32:31 cluster * * * 10 h +``` + +- 查看租户级别 pitr + +```bash +./mo_br pitr show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr012 2024-08-08 06:52:30 2024-08-08 06:52:30 table sys abc test 1 y +pitr011 2024-08-08 06:50:43 2024-08-08 06:50:43 database sys abc * 1 y +pitr05 2024-08-08 06:45:56 2024-08-08 06:45:56 account sys * * 1 y +pitr04 2024-08-08 06:45:52 2024-08-08 06:45:52 account sys * * 1 mo +pitr03 2024-08-08 06:45:42 2024-08-08 06:45:42 account sys * * 1 d +pitr02 2024-08-08 06:45:25 2024-08-08 06:45:25 account sys * * 1 h +``` + +- 查看数据库级别 pitr + +```bash +./mo_br pitr show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --database "abc" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr012 2024-08-08 06:52:30 2024-08-08 06:52:30 table sys abc test 1 y +pitr011 2024-08-08 06:50:43 2024-08-08 06:50:43 database sys abc * 1 y +``` + +- 查看表级别 pitr + +```bash + ./mo_br pitr show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --database "abc" --table "test" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr012 2024-08-08 06:52:30 2024-08-08 06:52:30 table sys abc test 1 y +``` + +### 更改 PITR + +#### 语法结构 + +``` +mo_br pitr alter + --host + --port + --user + --password + --pname + --rangevalue + --rangeunit +``` + +**参数说明** + +| 参数 | 说明 | +| ---- | ---- | +|host | 目标 MatrixOne 的 IP| +|port|端口号| +|user | 用户| +|password | 用户的密码| +|pname | pitr 名字| +|rangevalue|时间范围值,1-100| +|rangeunit| 时间范围单位,可选范围 h(小时)、d(天,默认)、mo(月)、y(年)| + +#### 示例 + +```bash +./mo_br pitr alter --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr01" --rangevalue 10 --rangeunit "d" + ./mo_br pitr show --host "127.0.0.1" --port 6001 --user "dump" --password "111" --cluster "sys" +PITR NAME CREATED TIME MODIFIED TIME PITR LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME PITR LENGTH PITR UNIT +pitr01 2024-08-08 06:32:31 2024-08-08 07:31:06 cluster * * * 10 d +``` + +### 恢复 PITR + +#### 语法结构 ``` -./mo_br snapshot restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --account "sys" --sname "sp_03" --new_account "acc2" --new_admin_name "admin" --new_admin_password "111"; +mo_br pitr restore + --host string 集群 IP + --port int 集群端口号 + --user string 用户名 + --password 用户密码 + //要恢复的对象名 + --cluster 恢复整个集群,仅限集群管理员使用,固定填写 sys,该字段填写后,只需填写 --timestamp + --account 要筛选的租户名,仅限集群管理员使用 + --database 要筛选的数据库名 + --table 要筛选的表名 + //要恢复的时间 + --timestamp + //创建并恢复到新租户 + --new_account string 新创建的租户名 + --new_admin_name string 租户管理员 + --new_admin_password string 租户管理员密码 +``` + +**参数说明** + +| 参数 | 说明 | +| ---- | ---- | +|host | 目标 MatrixOne 的 IP| +|port|端口号| +|user | 用户| +|password | 用户的密码| +|cluster | 恢复整个集群,仅限集群管理员使用,固定填写 sys,该字段填写后,只需填写 --timestamp| +|account | 要筛选的租户名,仅限集群管理员使用| +|database | 要筛选的数据库名| +|table | 要筛选的表名| +|timestamp | 要恢复的时间| +|new_account | 要恢复的时间| +|new_admin_name | 创建并恢复到新租户,新创建的租户名| +|new_admin_password | 租户管理员| +|timestamp | 租户管理员密码| + +#### 示例 + +- 系统租户 + + ```bash + #集群级别 + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr01" --level "cluster" --rangevalue 10 --rangeunit "h" + + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr01" --cluster "sys" --timestamp "2024-08-08 15:42:20.249966" + + #租户级别 + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr100" --level "account" --account "sys" --rangevalue 10 --rangeunit "h" + ##用 account pitr 恢复 account + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr100" --timestamp "2024-08-08 15:47:15.216472" --account "sys" + ##用 account pitr 恢复 db + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr100" --timestamp "2024-08-08 15:47:15.216472" --account "sys" --database "abc" + ##用 account pitr 恢复 table + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr100" --timestamp "2024-08-08 15:47:15.216472" --account "sys" --database "abc" --table "test" + + #数据库级别 + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr101" --level "database" --account "sys" --database "abc" --rangevalue 10 --rangeunit "h" + ##用 db pitr 恢复 db + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr101" --timestamp "2024-08-08 15:56:18.610295" --account "sys" --database "abc" + ##用 db pitr 恢复 table + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr101" --timestamp "2024-08-08 15:56:18.610295" --account "sys" --database "abc" --table "test" + + #表级别 + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr102" --level "table" --account "sys" --database "abc" --table "test" --rangevalue 10 --rangeunit "h" + ##用 table pitr 恢复 table + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr102" --timestamp "2024-08-08 16:00:41.433477" --account "sys" --database "abc" --table "test" + ``` + +- 普通租户 + + ```bash + #租户级别 + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr200" --level "account" --account "acc01" --rangevalue 10 --rangeunit "h" + ##用 account pitr 恢复 account + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr200" --timestamp "2024-08-08 16:04:17.276521" --account "acc01" + ##用 account pitr 恢复 db + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr200" --timestamp "2024-08-08 16:04:17.276521" --account "acc01" --database "abc" + ##用 account pitr 恢复 table + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr200" --timestamp "2024-08-08 16:04:17.276521" --account "acc01" --database "abc" --table "test" + + #数据库级别 + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr201" --level "database" --account "acc01" --database "abc" --rangevalue 10 --rangeunit "h" + ##用 db pitr 恢复 db + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr201" --timestamp "2024-08-08 16:06:50.374948" --account "acc01" --database "abc" + ##用 db pitr 恢复 table + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr201" --timestamp "2024-08-08 16:06:50.374948" --account "acc01" --database "abc" --table "test" + + #表级别 + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr202" --level "table" --account "acc01" --database "abc" --table "test" --rangevalue 10 --rangeunit "h" + ##用 table pitr 恢复 table + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "acc01#test_account" --password "111" --pname "pitr202" --timestamp "2024-08-08 16:06:50.374948" --account "acc01" --database "abc" --table "test" + + #系统租户给普通租户创建 pitr 并恢复普通租户 + + ./mo_br pitr create --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr300" --level "account" --account "acc01" --rangevalue 1 --rangeunit "y" + + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr300" --timestamp "2024-08-08 16:09:17.035136" --account "acc01" + + #系统租户将普通租户恢复到新租户 + ./mo_br pitr restore --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr300" --timestamp "2024-08-08 16:09:17.035136" --account "acc03" --new_account "acc03" --new_admin_name "test_account" --new_admin_password "111" + ``` + +### 删除 PITR + +#### 语法结构 + +``` +mo_br pitr drop + --host + --port + --user + --password + --pname +``` + +**参数说明** + +| 参数 | 说明 | +| ---- | ---- | +|host | 目标 MatrixOne 的 IP| +|port|端口号| +|user | 用户| +|password | 用户的密码| +|pname | pitr 名字| + +#### 示例 + +```bash +./mo_br pitr drop --host "127.0.0.1" --port 6001 --user "dump" --password "111" --pname "pitr01" ``` \ No newline at end of file diff --git a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-pitr.md b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-pitr.md new file mode 100644 index 0000000000..748f66b06d --- /dev/null +++ b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-pitr.md @@ -0,0 +1,52 @@ +# **ALTER PITR** + +## **语法说明** + +`ALTER PITR` 用于更改 PITR。 + +## **语法结构** + +``` +> ALTER PITR RANGE +``` + +## **示例** + +```sql +drop table if exists t1; +create table t1 (a int); +insert into t1 values(1),(2),(3),(4); +create view v5 as select * from t1; + +mysql> select * from v5; ++------+ +| a | ++------+ +| 1 | +| 2 | +| 3 | +| 4 | ++------+ +4 rows in set (0.01 sec) + +alter view v5 as select * from t1 where a=1; + +mysql> select * from v5; ++------+ +| a | ++------+ +| 1 | ++------+ +1 row in set (0.01 sec) + +alter view v5 as select * from t1 where a > 2; + +mysql> select * from v5; ++------+ +| a | ++------+ +| 3 | +| 4 | ++------+ +2 rows in set (0.00 sec) +``` diff --git a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-pitr.md b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-pitr.md new file mode 100644 index 0000000000..4cee193011 --- /dev/null +++ b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-pitr.md @@ -0,0 +1,96 @@ +# CREATE PITR + +## 语法说明 + +`CREATE PITR` 命令用于创建时间点恢复(Point-in-Time Recovery, PITR)的恢复点。集群管理员可以创建集群级别或租户级别的 pitr,而租户管理员则可以为当前租户创建租户/数据库/表级别的 pitr。每个 pitr 的信息仅对创建该 pitr 的租户可见,确保了数据的隔离性和安全性。 + +## 语法结构 + +```sql +create pitr for + [cluster]|[account ]|[database ]|[table ] + range +``` + +### 语法释义 + +**range**: int,时间范围值,1-100。 +**unit**: string 时间范围单位,可选范围 h(小时)、d(天,默认)、mo(月)、y(年) + +## 示例 + +**示例 1:集群管理员为集群创建 pitr** + +```sql +create pitr cluster_pitr1 for cluster range 1 "d"; +mysql> show pitr; ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| PITR_NAME | CREATED_TIME | MODIFIED_TIME | PITR_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME | PITR_LENGTH | PITR_UNIT | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| cluster_pitr1 | 2024-10-18 14:07:10 | 2024-10-18 14:07:10 | cluster | * | * | * | 1 | d | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.01 sec) +``` + +**示例 2:集群管理员为租户创建 pitr** + +```sql +create account acc1 admin_name 'root' identified by '111'; +create account acc2 admin_name 'root' identified by '111'; +mysql> create pitr account_pitr1 for account acc1 range 1 "d"; +mysql> show pitr where pitr_name='account_pitr1'; ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| account_pitr1 | 2024-10-18 14:11:57 | 2024-10-18 14:11:57 | account | acc1 | * | * | 1 | d | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.00 sec) +``` + +**示例 3:租户管理员为租户创建 pitr** + +```sql +create pitr account_pitr1 range 2 "h"; + +mysql> show pitr where pitr_name='account_pitr1'; ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| account_pitr1 | 2024-10-18 14:23:12 | 2024-10-18 14:23:12 | account | acc1 | * | * | 2 | h | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.00 sec) +``` + +**示例 4:租户管理员为数据库创建 pitr** + +```sql +mysql> create pitr db_pitr1 for database db1 range 1 'y'; +Query OK, 0 rows affected (0.01 sec) + +mysql> show pitr where pitr_name='db_pitr1'; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| db_pitr1 | 2024-10-18 14:26:02 | 2024-10-18 14:26:02 | database | acc1 | db1 | * | 1 | y | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.01 sec) +``` + +**示例 5:租户管理员为表创建 pitr** + +```sql +mysql> create pitr tab_pitr1 for database db1 table t1 range 1 'y'; +Query OK, 0 rows affected (0.02 sec) + +mysql> show pitr where pitr_name='tab_pitr1'; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| tab_pitr1 | 2024-10-18 14:28:53 | 2024-10-18 14:28:53 | table | acc1 | db1 | t1 | 1 | y | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.01 sec) +``` + +## 限制 + +- 集群管理员为其它租户创建 pitr 时只能创建租户级别的 pitr。 diff --git a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot.md b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot.md index 7fcd4fc3a3..6a33ccf664 100644 --- a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot.md +++ b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot.md @@ -2,45 +2,59 @@ ## 语法说明 -`CREATE SNAPSHOT` 命令用于创建快照。系统租户可以给自己也可以给普通租户创建快照,但是普通租户只能给自己创建快照。租户创建的快照仅本租户可见。 +`CREATE SNAPSHOT` 命令用于创建数据库的快照。集群管理员可以创建集群级别或租户级别的快照,而普通租户管理员则可以为当前租户创建租户级别的快照。每个快照仅对创建该快照的租户可见,确保了数据的隔离性和安全性。 ## 语法结构 ```sql -> CREATE SNAPSHOT snapshot_name FOR ACCOUNT account_name +create snapshot for [cluster]|[account ] ``` ## 示例 +**示例 1:集群管理员为集群创建集群快照** + ```sql ---在系统租户 sys 下执行 -create snapshot sp1 for account sys; -create snapshot sp2 for account acc1; +create snapshot cluster_sp for cluster; +mysql> show snapshots; ++---------------+----------------------------+----------------+--------------+---------------+------------+ +| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME | ++---------------+----------------------------+----------------+--------------+---------------+------------+ +| cluster_sp | 2024-10-10 10:40:14.487655 | cluster | | | | ++---------------+----------------------------+----------------+--------------+---------------+------------+ +1 row in set (0.00 sec) +``` + +**示例 2:集群管理员为租户创建租户快照** +```sql +mysql> create snapshot account_sp1 for account acc1; mysql> show snapshots; +---------------+----------------------------+----------------+--------------+---------------+------------+ | SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME | +---------------+----------------------------+----------------+--------------+---------------+------------+ -| sp2 | 2024-05-10 09:49:08.925908 | account | acc1 | | | -| sp1 | 2024-05-10 09:48:50.271707 | account | sys | | | +| account_sp1 | 2024-10-10 10:58:53.946829 | account | acc1 | | | +---------------+----------------------------+----------------+--------------+---------------+------------+ -2 rows in set (0.00 sec) +1 row in set (0.00 sec) +``` + +**示例 3:普通租户管理员为租户创建租户快照** ---在租户 acc1 下执行 -mysql> create snapshot sp3 for account acc2;--普通租户只能为自己建立快照 -ERROR 20101 (HY000): internal error: only sys tenant can create tenant level snapshot for other tenant +```sql +create snapshot account_sp2 for account acc1; -create snapshot sp3 for account acc1; +mysql> create snapshot account_sp2 for account acc2; +ERROR 20101 (HY000): internal error: only sys tenant can create tenant level snapshot for other tenant--租户管理员只能为本租户创建快照 mysql> show snapshots; +---------------+----------------------------+----------------+--------------+---------------+------------+ | SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME | +---------------+----------------------------+----------------+--------------+---------------+------------+ -| sp3 | 2024-05-10 09:53:09.948762 | account | acc1 | | | +| account_sp2 | 2024-10-10 11:19:12.699093 | account | acc1 | | | +---------------+----------------------------+----------------+--------------+---------------+------------+ 1 row in set (0.00 sec) ``` ## 限制 -- 目前只支持创建租户级别的快照,不支持创建集群级别、数据库级别和表级别的快照。 \ No newline at end of file +- 目前只支持创建集群和租户级别的快照,不支持创建数据库级别和表级别的快照。 diff --git a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-pitr.md b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-pitr.md new file mode 100644 index 0000000000..51610b0bc0 --- /dev/null +++ b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-pitr.md @@ -0,0 +1,31 @@ +# DROP PITR + +## 语法说明 + +`DROP PITR` 用于删除当前租户下创建的 pitr。 + +## 语法结构 + +``` +> DROP PITR pitr_name; +``` + +## 示例 + +```sql +create pitr db_pitr1 for database db1 range 1 'y'; + +mysql> show pitr where pitr_name='db_pitr1'; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| db_pitr1 | 2024-10-18 14:26:02 | 2024-10-18 14:26:02 | database | acc1 | db1 | * | 1 | y | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.01 sec) + +mysql> drop pitr db_pitr1; +Query OK, 0 rows affected (0.01 sec) + +mysql> show pitr where pitr_name='db_pitr1'; +Empty set (0.01 sec) +``` diff --git a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md new file mode 100644 index 0000000000..5ac8557653 --- /dev/null +++ b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md @@ -0,0 +1,262 @@ +# RESTORE ... FROM PITR + +## 语法说明 + +`RESTORE ... FROM PITR` 用于从之前创建的 PITR 中进行数据恢复。 + +## 语法结构 + +``` +> RESTORE [CLUSTER]|[[ACCOUNT ] [DATABASE database_name [TABLE table_name]]]FROM PITR [TO ACCOUNT ]; +``` + +## 示例 + +### 示例 1:恢复集群 + +```sql + +--sys 租户下执行 +create account acc1 admin_name 'root' identified by '111'; +create account acc2 admin_name 'root' identified by '111'; + +--在租户 acc1,acc2 下执行 +create database db1; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) + +--创建 pitr +mysql> create pitr clu_pitr1 for cluster range 1 'h'; +Query OK, 0 rows affected (0.01 sec) + +mysql> show pitr where pitr_name='clu_pitr1'; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| clu_pitr1 | 2024-10-18 17:06:49 | 2024-10-18 17:06:49 | cluster | * | * | * | 1 | h | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.00 sec) + +--在租户 acc1,acc2 下执行 +drop database db1;--删除数据库 db1 + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) + +--恢复 +mysql> restore cluster from pitr clu_pitr1 "2024-10-18 17:06:50"; +Query OK, 0 rows affected (1.84 sec) + +--在租户 acc1,acc2 下执行,可以看到,恢复成功 +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) +``` + +### 示例 2:恢复租户 + +```sql +CREATE database db1; +CREATE database db2; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| db2 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +7 rows in set (0.00 sec) + +--创建 pitr +mysql> create pitr acc_pitr1 range 1 "h"; +Query OK, 0 rows affected (0.02 sec) + +mysql> show pitr; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| PITR_NAME | CREATED_TIME | MODIFIED_TIME | PITR_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME | PITR_LENGTH | PITR_UNIT | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| acc_pitr1 | 2024-10-18 16:09:34 | 2024-10-18 16:09:34 | account | acc1 | * | * | 1 | h | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.01 sec) + +--过一会删除数据库 db1,db2 +drop database db1; +drop database db2; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +5 rows in set (0.01 sec) + +--恢复 +mysql> restore from pitr acc_pitr1 "2024-10-18 16:09:35"; +Query OK, 0 rows affected (0.78 sec) + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| db2 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +7 rows in set (0.00 sec) +``` + +### 示例 3:恢复数据库 + +```sql +CREATE database db1; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +7 rows in set (0.00 sec) + + +--创建 pitr +mysql> create pitr db_pitr1 for database db1 range 2 "d"; +Query OK, 0 rows affected (0.01 sec) + +mysql> show pitr where pitr_name='db_pitr1'; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| db_pitr1 | 2024-10-18 16:16:03 | 2024-10-18 16:16:03 | database | acc1 | db1 | * | 2 | d | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.01 sec) + +--删除数据库 db1 +drop database db1; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) + +--恢复 db1 +mysql> restore database db1 from pitr db_pitr1 "2024-10-18 16:16:05"; +Query OK, 0 rows affected (0.02 sec) + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +7 rows in set (0.00 sec) +``` + +### 示例 4:恢复表 + +```sql +--在租户 acc1 下执行 +CREATE TABLE t1(n1 int); +INSERT INTO t1 values(1); + +mysql> SELECT * FROM t1; ++------+ +| n1 | ++------+ +| 1 | ++------+ +1 row in set (0.00 sec) + +create pitr tab_pitr for database db1 table t1 range 1 'd';--创建 pitr + +mysql> show pitr where pitr_name='tab_pitr'; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| tab_pitr | 2024-10-23 14:32:17 | 2024-10-23 14:32:17 | table | sys | db1 | t1 | 1 | d | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.01 sec) + +truncate TABLE t1;--清空 t1 + +mysql> SELECT * FROM t1; +Empty set (0.01 sec) + +restore database db1 table t1 from pitr tab_pitr "2024-10-23 14:32:18";--恢复 pitr + +mysql> SELECT * FROM t1;--恢复成功 ++------+ +| n1 | ++------+ +| 1 | ++------+ +1 row in set (0.00 sec) +``` + +## 限制 + +- 已删除租户暂不支持恢复。 +- 集群级别的 pitr 能对集群基本和租户级别进行恢复。 +- 系统租户恢复普通租户到新租户只允许租户级别的恢复。 +- 只有系统租户才可以执行恢复数据到新租户,且只允许租户级别的恢复。新租户需提前创建,为了避免对象冲突,新租户最好为新建租户。 diff --git a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md similarity index 75% rename from docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md rename to docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md index fa01a9ed6d..d3499a53cf 100644 --- a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md +++ b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md @@ -1,18 +1,73 @@ -# RESTORE ACCOUNT +# RESTORE ... FROM SNAPSHOT ## 语法说明 -`RESTORE ACCOUNT` 根据当前租户下创建的快照将租户/数据库/表恢复到某个时间戳对应的状态。 +`RESTORE ... FROM SNAPSHOT` 用于从之前创建的集群/租户级别的快照中进行集群/租户/数据库/表级别的恢复数据。 ## 语法结构 ``` -> RESTORE ACCOUNT account_name [DATABASE database_name [TABLE table_name]] FROM SNAPSHOT snapshot_name [TO ACCOUNT account_name]; +> RESTORE [CLUSTER]|[[ACCOUNT ] [DATABASE database_name [TABLE table_name]]]FROM SNAPSHOT [TO ACCOUNT ]; ``` ## 示例 -- 示例 1:恢复租户到本租户 +### 示例 1:恢复集群 + +```sql +--在租户 acc1,acc2 下执行 +create database db1; + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) + +--在系统租户 sys 下执行 +create snapshot cluster_sp1 for cluster;--为集群创建快照 + +--在租户 acc1,acc2 下执行 +drop database db1;--删除数据库 db1 + +mysql> show databases; ++--------------------+ +| Database | ++--------------------+ +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) + +--在系统租户 sys 下执行 +restore cluster FROM snapshot cluster_sp1;--在系统租户下对集群进行快照恢复 + +--在租户 acc1,acc2 下执行 +mysql> show databases;--恢复成功 ++--------------------+ +| Database | ++--------------------+ +| db1 | +| information_schema | +| mo_catalog | +| mysql | +| system | +| system_metrics | ++--------------------+ +6 rows in set (0.01 sec) +``` + +### 示例 2:恢复租户 ```sql --在租户 acc1 下执行 @@ -66,7 +121,7 @@ mysql> show databases;--恢复成功 7 rows in set (0.01 sec) ``` -- 示例 2:恢复数据库到本租户 +### 示例 3:恢复数据库 ```sql --在租户 acc1 下执行 @@ -116,7 +171,7 @@ mysql> show databases;--恢复成功 7 rows in set (0.00 sec) ``` -- 示例 3:恢复表到本租户 +### 示例 4:恢复表 ```sql --在租户 acc1 下执行 @@ -148,7 +203,7 @@ mysql> SELECT * FROM t1;--恢复成功 1 row in set (0.00 sec) ``` -- 示例 4:系统租户恢复普通租户到普通租户本租户 +### 示例 5:系统租户恢复普通租户到普通租户本租户 ```sql --在租户 acc1 下执行 @@ -203,7 +258,7 @@ mysql> show databases;--恢复成功 6 rows in set (0.01 sec) ``` -- 示例 5:系统租户恢复普通租户到新租户 +### 示例 6:系统租户恢复普通租户到新租户 ```sql --在租户 acc1 下执行 @@ -274,8 +329,8 @@ mysql> show databases;--恢复至 acc2 ## 限制 -- 目前只支持租户/数据库/表级别的恢复,暂不支持集群的。 +- 只有租户级别的快照才能进行数据库/表级别的恢复。 - 系统租户恢复普通租户到新租户只允许租户级别的恢复。 -- 只有系统租户才可以执行恢复数据到新租户,且只允许租户级别的恢复。新租户需提前创建,为了避免对象冲突,新租户最好为新建租户。 \ No newline at end of file +- 只有系统租户才可以执行恢复数据到新租户,且只允许租户级别的恢复。新租户需提前创建,为了避免对象冲突,新租户最好为新建租户。 diff --git a/docs/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-pitr.md b/docs/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-pitr.md new file mode 100644 index 0000000000..f8c1bf9c7d --- /dev/null +++ b/docs/MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-pitr.md @@ -0,0 +1,37 @@ +# SHOW PITR + +## 语法说明 + +`SHOW PITR` 返回当前租户下创建的 PITR 的信息。 + +## 语法结构 + +``` +> SHOW PITR[WHERE expr] +``` + +## 示例 + +```sql +create pitr account_pitr1 range 2 "h"; +create pitr db_pitr1 for database db1 range 1 'y'; +create pitr tab_pitr1 for database db1 table t1 range 1 'y'; + +mysql> show pitr; ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| PITR_NAME | CREATED_TIME | MODIFIED_TIME | PITR_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME | PITR_LENGTH | PITR_UNIT | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| tab_pitr1 | 2024-10-18 14:28:53 | 2024-10-18 14:28:53 | table | acc1 | db1 | t1 | 1 | y | +| db_pitr1 | 2024-10-18 14:26:02 | 2024-10-18 14:26:02 | database | acc1 | db1 | * | 1 | y | +| account_pitr1 | 2024-10-18 14:23:12 | 2024-10-18 14:23:12 | account | acc1 | * | * | 2 | h | ++---------------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +3 rows in set (0.01 sec) + +mysql> show pitr where pitr_name='tab_pitr1'; ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| pitr_name | created_time | modified_time | pitr_level | account_name | database_name | table_name | pitr_length | pitr_unit | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +| tab_pitr1 | 2024-10-18 14:28:53 | 2024-10-18 14:28:53 | table | acc1 | db1 | t1 | 1 | y | ++-----------+---------------------+---------------------+------------+--------------+---------------+------------+-------------+-----------+ +1 row in set (0.00 sec) +``` diff --git a/mkdocs.yml b/mkdocs.yml index 13cbd5a588..72053e116c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -244,7 +244,8 @@ nav: - mo_br 备份与恢复: - mo_br 使用指南: MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr.md - mo_br 常规物理备份恢复: MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore.md - - mo_br 快照备份恢复: MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore.md + - mo_br snapshot: MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore.md + - mo_br pitr: MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-pitr-backup-restore.md - 数据挂载: - 挂载目录到 Docker 容器: MatrixOne/Maintain/mount-data-by-docker.md - 数据迁移: @@ -328,6 +329,7 @@ nav: - CREATE TABLE ... LIKE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-like.md - CREATE EXTERNAL TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table.md - CREATE CLUSTER TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table.md + - CREATE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-pitr.md - CREATE PUBLICATION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication.md - CREATE SEQUENCE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence.md - CREATE STAGE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage.md @@ -341,6 +343,7 @@ nav: - CREATE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot.md - ALTER TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table.md - ALTER TABLE ... ALTER REINDEX: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-reindex.md + - ALTER PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-pitr.md - ALTER PUBLICATION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication.md - ALTER SEQUENCE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-sequence.md - ALTER STAGE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage.md @@ -348,6 +351,7 @@ nav: - DROP DATABASE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database.md - DROP INDEX: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index.md - DROP TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table.md + - DROP PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-pitr.md - DROP PUBLICATION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication.md - DROP SEQUENCE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence.md - DROP STAGE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage.md @@ -355,7 +359,8 @@ nav: - DROP VIEW: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view.md - DROP FUNCTION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function.md - TRUNCATE TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table.md - - RESTORE ACCOUNT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md + - RESTORE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md + - RESTORE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md - 数据修改语言(DML): - INSERT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert.md - INSERT INTO SELECT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select.md @@ -422,6 +427,7 @@ nav: - SHOW GRANT: MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants.md - SHOW PROCESSLIST: MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist.md - SHOW PUBLICATIONS: MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications.md + - SHOW PITRS: MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-pitrs.md - SHOW ROLES: MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles.md - SHOW SEQUENCES: MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences.md - SHOW SNAPSHOTS: MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-snapshots.md From 561d8b752e2808b0a72e48c399bf2b5b5947d3af Mon Sep 17 00:00:00 2001 From: yangj1211 Date: Mon, 28 Oct 2024 18:14:39 +0800 Subject: [PATCH 2/7] fix --- mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/mkdocs.yml b/mkdocs.yml index 72053e116c..a2e4777215 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -359,6 +359,7 @@ nav: - DROP VIEW: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view.md - DROP FUNCTION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function.md - TRUNCATE TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table.md + - RENAME TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/rename-table.md - RESTORE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md - RESTORE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md - 数据修改语言(DML): From cb992af26c926ca21d71bb8e70914e486f81618f Mon Sep 17 00:00:00 2001 From: yangj1211 Date: Mon, 28 Oct 2024 18:18:46 +0800 Subject: [PATCH 3/7] fix --- mkdocs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index a2e4777215..b7376e1459 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -360,8 +360,7 @@ nav: - DROP FUNCTION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function.md - TRUNCATE TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table.md - RENAME TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/rename-table.md - - RESTORE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md - - RESTORE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md + - RESTORE ACCOUNT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md - 数据修改语言(DML): - INSERT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert.md - INSERT INTO SELECT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select.md From 2b915db435f1c8de4d303a2924a7e86de982f2ee Mon Sep 17 00:00:00 2001 From: yangj1211 Date: Mon, 28 Oct 2024 18:19:26 +0800 Subject: [PATCH 4/7] fix --- mkdocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index b7376e1459..a2e4777215 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -360,7 +360,8 @@ nav: - DROP FUNCTION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function.md - TRUNCATE TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table.md - RENAME TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/rename-table.md - - RESTORE ACCOUNT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md + - RESTORE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md + - RESTORE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md - 数据修改语言(DML): - INSERT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert.md - INSERT INTO SELECT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select.md From 42cc5ab7cdbb4bb93d1f064df748b69ff301cae4 Mon Sep 17 00:00:00 2001 From: yangj1211 Date: Mon, 28 Oct 2024 18:22:23 +0800 Subject: [PATCH 5/7] fix --- mkdocs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index a2e4777215..b7376e1459 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -360,8 +360,7 @@ nav: - DROP FUNCTION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function.md - TRUNCATE TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table.md - RENAME TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/rename-table.md - - RESTORE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md - - RESTORE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md + - RESTORE ACCOUNT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md - 数据修改语言(DML): - INSERT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert.md - INSERT INTO SELECT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select.md From bd7a286505dae3a65971548a09f67c1a1ef0b961 Mon Sep 17 00:00:00 2001 From: yangj1211 <153493538+yangj1211@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:41:50 +0800 Subject: [PATCH 6/7] Update mkdocs.yml --- mkdocs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkdocs.yml b/mkdocs.yml index b7376e1459..64a5956792 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -360,6 +360,8 @@ nav: - DROP FUNCTION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function.md - TRUNCATE TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table.md - RENAME TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/rename-table.md + - RESTORE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md + - RESTORE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md - RESTORE ACCOUNT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md - 数据修改语言(DML): - INSERT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert.md From 5a5a2d611a0c4db673a617dc1562cdf5ed444a42 Mon Sep 17 00:00:00 2001 From: yangj1211 <153493538+yangj1211@users.noreply.github.com> Date: Mon, 28 Oct 2024 18:43:23 +0800 Subject: [PATCH 7/7] Update mkdocs.yml --- mkdocs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 64a5956792..b7376e1459 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -360,8 +360,6 @@ nav: - DROP FUNCTION: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function.md - TRUNCATE TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table.md - RENAME TABLE: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/rename-table.md - - RESTORE PITR: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-pitr.md - - RESTORE SNAPSHOT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-snapshot.md - RESTORE ACCOUNT: MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account.md - 数据修改语言(DML): - INSERT: MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert.md