1. 程式人生 > 其它 >【TcaplusDB知識庫】表格相關操作命令

【TcaplusDB知識庫】表格相關操作命令

【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, 表名


TcaplusDB是騰訊出品的分散式NoSQL資料庫,儲存和排程的程式碼完全自研。具備快取+落地融合架構、PB級儲存、毫秒級時延、無損水平擴充套件和複雜資料結構等特性。同時具備豐富的生態、便捷的遷移、極低的運維成本和五個九高可用等特點。客戶覆蓋遊戲、網際網路、政務、金融、製造和物聯網等領域。