评论

收藏

[NoSQL] 【TcaplusDB知识库】表格相关操作命令

数据库 数据库 发布于:2021-12-29 10:58 | 阅读数:284 | 评论:0

【TcaplusDB知识库】表格相关操作命令介绍

说明
TcaplusDB CLI工具提供了大量的关于表操作的命令,支持腾讯云环境和本地Docker开发环境。主要涉及:

  • 表创建: 支持Cloud, Docker
  • 表删除:支持Cloud, Docker
  • 表查询: 支持Cloud, Docker
  • 表清理: 支持Cloud, Docker
  • 表恢复: 支持Cloud
  • 表扩容:支持Cloud
  • 批量创建表: 支持Cloud
  • 批量清理表: 支持Cloud
  • 批量扩容表: 支持Cloud

帮助信息
执行​​tcapluscli table -h​​可查看对应帮助信息,如下所示:
Provide basic commands to operate TcaplusDB table. The basic commands includes: create, delete, recover and describe
Usage:
tcapluscli table [commands] [flags]
tcapluscli table [command]
Examples:
./tcapluscli table [create | delete | recover | describe] [flags]
Available Commands:
batchclear  Batch clear specified table data. [Cloud Env]
batchcreate Create multiple TcaplusDB tables. [Cloud Env]
batchexpand Expand multiple tables' quotas. [Cloud Env]
clear     Clear specified table data. [Cloud | Docker]
create    Create a TcaplusDB table [Cloud | Docker]
delete    Delete a TcaplusDB table. [Cloud | Docker]
describe  Get table description information. [Cloud | Docker]
expand    Expand table quotas. [Cloud Env]
recover   Recover a TcaplusDB table from Recycle. [ Cloud Env]
Flags:
-h, --help   help for table
Use "tcapluscli table [command] --help" for more information about a command.
创建表

创建单表
执行 ​​tcapluscli table create -h​​, 查看信息:
Create a TcaplusDB table. Support  creating table in local docker env with '--endpoint-url' flag
Note: The TcaplusDB cluster and table group should be created first.  See cluster and table group command
Usage:
tcapluscli table create [flags]
Examples:
Cloud Env: ./tcapluscli table create --region=ap-shanghai --cluster-id=1234 --group-id=1 --schema-type=PROTO --schema-file=game_players.proto
Docker Env: ./tcapluscli table create --endpoint-url=http://localhost --access-id=[2|3] --group-id=1 --schema-type=TDR --schema-file=table_test.xml
Flags:
-a, --access-id string    required in docker env: available value [2|3], 2: default cluster of TDR, 3: default cluster of PROTO.
-c, --cluster-id string   required in cloud env: table cluster id
-u, --endpoint-url string   required in local docker env: local env endpoint
-g, --group-id string     required: table group id
-h, --help          help for create
-R, --rcu int         optional: table reserved Read Capacity  Units (default 80)
-r, --region string     required in cloud env:region name of table (default "ap-shanghai")
-f, --schema-file string  required: table schema file with relative path, e.g:./cfg/test.proto
-t, --schema-type string  required: table schema protocol : PROTO | TDR (default "PROTO")
-v, --volume int      optional: table reserved volume (GB) (default 1)
-W, --wcu int         optional: table reserved Write Capacity Units (default 26)
命令功能:

  • 支持创建腾讯云&Docker环境的单表
  • 支持创建PROTO和TDR的单表
  • 支持一个schema文件放多个表定义

批量创建表
批量创建表仅支持腾讯云环境,执行​​tcapluscli table batchcreate -h​​,查看帮助信息:
Create multiple TcaplusDB tables.
Note: The TcaplusDB cluster and table group should be created first.  See cluster and table group command
Usage:
tcapluscli table batchcreate [flags]
Examples:
./tcapluscli table batchcreate --region=ap-shanghai --cluster-id=1234 --group-id=1 --schema-type=PROTO --schema-filepath=./cfg/schema
Flags:
-c, --cluster-id string    required: table cluster id
-g, --group-id string      required: table group id
-h, --help           help for batchcreate
-R, --rcu int          optional: table reserved Read Capacity  Units (default 80)
-r, --region string      required:region name of table (default "ap-shanghai")
-d, --schema-filepath string   required: file path of table schema file e.g:./cfg/schema
-t, --schema-type string     required: table schema protocol : PROTO | TDR (default "PROTO")
-v, --volume int         optional: table reserved volume (GB) (default 1)
-W, --wcu int          optional: table reserved Write Capacity Units (default 26)
注意:在创建多表时,需要指定表定义文件所放的目录,目录下可放多个表定义文件。每个文件支持放多个表定义。

清理表数据

清理单表数据
清理单个表数据,同时支持腾讯云环境和Docker本地环境表清理,执行​​tcapluscli table clear -h​​ 获取帮助信息:
Clear specfied table data.  Support clearing table data of local docker env with --endpoint-url flag.
Note: This operation is high dangerous, please be careful to execute this api to clear table data. Please double-check before operation
Usage:
tcapluscli table clear [flags]
Examples:
Cloud Env: ./tcapluscli table clear --region=ap-shanghai --cluster-id=1234 --group-id=1 --table-instance-id=tcpalus-123df12 --table-name=test
Docker Env: ./tcapluscli table clear --endpoint-url=http://localhost --access-id=[2|3] --group-id=1 --table-name=test
Flags:
-a, --access-id string       required in docker env: available value [2|3], 2: default cluster of TDR, 3: default cluster of PROTO.
-c, --cluster-id string      required in cloud env: table cluster id
-u, --endpoint-url string    required in docker env: access endpoint url of docker env
-g, --group-id string      required: table group id
-h, --help             help for clear
-r, --region string        required in cloud env: region name of table (default "ap-shanghai")
-i, --table-instance-id string   required in cloud env: tcaplusdb table instance id
-n, --table-name string      required: tcaplusdb table name
注意:清理数据是高危动作,尤其是清理线上数据时,请在执行清理操作前仔细确认,避免误删数据。

清理批量表数据
一次清理多个表数据,仅支持腾讯云环境批量清理,执行​​tcapluscli table batchclear -h​​获取帮助信息:
Batch clear specfied table data. If you want to clear multiple tables, the table infos should be saved in a text file, the file content should contain three fields: TableInstanceId, TableGroupId, and TableName and use comma to separate them.
Note: This operation is high dangerous, please be careful to execute this api to clear table data. Please double-check before operation
Usage:
tcapluscli table batchclear [flags]
Examples:
Cloud Env: ./tcapluscli table clear --region=ap-shanghai --cluster-id=1234 --clear-file=./data/target_table.clear
Flags:
-f, --clear-file string   required in cloud env: the clear file that contains target table infos need to be cleared.
-c, --cluster-id string   required in cloud env: table cluster id
-h, --help        help for batchclear
-r, --region string     required in cloud env: region name of table (default "ap-shanghai")
命令功能:

  • 支持将要清理的表元数据信息放一个文件中进行批量删除,文件内容格式: TableInstanceId, TableGroupId, and TableName, 用逗号隔开这三个属性。
注意:清理数据是高危动作,尤其是清理线上数据时,请在执行清理操作前仔细确认,避免误删数据。

获取表信息
获取指定表或全部表的信息,支持腾讯云环境和Docker本地环境,执行​​tcapluscli table describe -h​​获取帮助信息:
Get table description information. If table instance id and table name are empty, the 'list' flag must be indispensable  and list all table infos of table group. Support get table descriptions of local docker env with --endpoint-url flag.
Usage:
tcapluscli table describe [flags]
Examples:
Cloud Env: ./tcapluscli table describe --region=ap-shanghai --cluster-id=123 --group-id=1  --table-instance-id=tcaplus-12f397 --table-name=test
Cloud Env: ./tcapluscli  table describe --region=ap-shanghai --cluster-id=123 --group-id=1 --list
Docker Env: ./tcapluscli  table describe --endpoint-url=http://localhost --access-id=[2|3] --group-id=1 --list
Flags:
-a, --access-id string       required in docker env: available value [2|3], 2: default cluster of TDR, 3: default cluster of PROTO.
-c, --cluster-id string      required in cloud env: table cluster id
-u, --endpoint-url string    required in docker env: endpoint url of docker env
-g, --group-id string      required: table group id
-h, --help             help for describe
-l, --list             list all table infos
-r, --region string        required in cloud env : region name of table (default "ap-shanghai")
-i, --table-instance-id string   required in cloud env: tcaplusdb table instance id
-n, --table-name string      required in cloud env: tcaplusdb table name
命令功能:

  • 支持获取指定表的描述信息,通过在命令行参数指定表实例id,表名来获取
  • 支持获取指定group表格组下的所有表描述信息

删除表
从集群中删除指定的表,支持腾讯云环境和Docker环境,执行​​tcapluscli table delete -h​​ 获取帮助信息:
Delete a TcaplusDB table. The deleted table will be removed into Recycle of TcaplusDB Console. If you want to delete the table thoroughly, you can manually delete in the Recycle of TcaplusDB Console . Support deleting table of docker env with --endpoint-url flag
Usage:
tcapluscli table delete [flags]
Examples:
Cloud Env: ./tcapluscli table delete --cluster-id=123 --group-id=1 --region=ap-shanghai --table-instance-id=tcaplus-12f397 --table-name=test
Docker Env: ./tcapluscli table delete --endpoint-url=http://localhost --access-id=[2|3] --group-id=1 --table-name=test
Flags:
-a, --access-id string       required in docker env: available value [2|3], 2: default cluster of TDR, 3: default cluster of PROTO.
-c, --cluster-id string      required in cloud env: table cluster id
-u, --endpoint-url string    required in docker env: access endpoint url of docker env
-g, --group-id string      required: table group id
-h, --help             help for delete
-r, --region string        required in cloud env:region name of table (default "ap-shanghai")
-i, --table-instance-id string   required in cloud env: tcaplusdb table instance id
-n, --table-name string      required: tcaplusdb table name
注意:删除表属于高危动作,尤其在删除线上表时,务必反复确认,避免误删。如果真不幸删除了线上某个表,线上环境作一层保护,将删的表放在回收站中,可参考tcapluscli table recover怎么恢复已删表。
注意:线上操作删除时,务必注意,如果执行同一个删除动作2次(第1次从线上移除,第2次从回收站移除),表将彻底删除,也不会在回收站保留,这个线上操作运维同学尤其注意。

扩容表
扩容指定表或多个表的容量,仅支持腾讯云环境,包括: 磁盘volume, 读CU, 写CU。

扩容单表
执行​​tcapluscli table expand -h​​获取帮助信息:
Expand the specified table quotas, including volume, rcu and wcu. Expand as default value if volume, rcu and wcu are not presented.
Usage:
tcapluscli table expand [flags]
Examples:
./tcapluscli  table expand --region=ap-shanghai --cluster-id=123 --group-id=1 --table-instance-id=tcaplus-12df --table-name=test --volume=2 --rcu=100 --wcu=100
./tcapluscli  table expand --region=ap-shanghai --cluster-id=123 --group-id=1 --table-instance-id=tcaplus-12df --table-name=test
Flags:
-c, --cluster-id string      required: table cluster id
-g, --group-id string      required: table group id
-h, --help             help for expand
-R, --rcu int          optional: table reserved Read Capacity  Units (default 80)
-r, --region string        required:region name of table (default "ap-shanghai")
-i, --table-instance-id string   required: table instance id
-n, --table-name string      required: table name
-v, --volume int         optional: table reserved volume (GB) (default 1)
-W, --wcu int          optional: table reserved Write Capacity Units (default 26)
命令功能:

  • 支持扩容表至指定容量,如命令行参数传入volume, rcu, wcu新值即可
  • 支持扩容表至默认容量,此时命令行不用带volume, rcu,wcu参数,默认值:volume: 1GB, rcu: 80, wcu: 26

扩容多表
执行​​tcapluscli table batchexpand -h​​ 获取帮助信息:
Expand multiple tables' quotas. Save the target table infos into a file. The file format is as below:
[table group id], [table instance id], [table name], [volume], [rcu], [wcu].
Usage:
tcapluscli table batchexpand [flags]
Examples:
./tcapluscli table batchexpand --region=ap-shanghai --cluster-id=123 --expand-file=expand_table.txt
Flags:
-c, --cluster-id string  required: table cluster id
-f, --expand-file string   required: expand file, save the target table quotas that need to be expanded
-h, --help         help for batchexpand
-r, --region string    required:region name of table (default "ap-shanghai")
命令功能:

  • 支持将扩容的多表信息放到一个文件中,文件内容格式如:[table group id], [table instance id], [table name], [volume], [rcu], [wcu]

恢复删除表
仅支持腾讯云环境,用于从腾讯云TcaplusDB控制台回收站恢复删除的表。执行​​tcapluscli table recover -h​​获取帮助信息:
Recover a TcaplusDB table. The deleted table  was in Recycle, call RecoverRecycleTables api to recover the deleted tables to online.
Note: This command does't support docker env
Usage:
tcapluscli table recover [flags]
Examples:
./tcapluscli  table recover --cluster-id=123 --group-id=1 --region=ap-shanghai --table-instance-id=tcaplus-12f397 --table-name=test
Flags:
-c, --cluster-id string      required: table cluster id
-g, --group-id string      required: table group id
-h, --help             help for recover
-r, --region string        required:region name of table (default "ap-shanghai")
-i, --table-instance-id string   required: tcaplusdb table instance id
-n, --table-name string      required: tcaplusdb table name
命令功能:

  • 支持从回收站中恢复表,指定表实例id, 表名
DSC0000.png
TcaplusDB是腾讯出品的分布式NoSQL数据库,存储和调度的代码完全自研。具备缓存+落地融合架构、PB级存储、毫秒级时延、无损水平扩展和复杂数据结构等特性。同时具备丰富的生态、便捷的迁移、极低的运维成本和五个九高可用等特点。客户覆盖游戏、互联网、政务、金融、制造和物联网等领域。


关注下面的标签,发现更多相似文章