tencent cloud

游戏数据库 TcaplusDB

产品动态
产品简介
产品概述
产品优势
应用场景
产品架构
地域介绍
购买指南
产品定价
欠费说明
快速入门
了解基本概念
创建集群
创建表格组
创建表格
获取连接信息
访问 TcaplusDB
操作指南
管理集群与表格组
管理表格
监控与告警
访问管理
标签
任务列表
使用 TcaplusDB client
使用 client 工具访问数据
client 工具命令参考
使用 TcaplusDB SDK
变更历史
SDK 下载
SDK for C++ 接口说明
TcaplusDB 错误码
SDK 安装
PB 表 C++SDK 操作方法
TDR 表 C++SDK 操作方法
使用 TcaplusDB RESTful API
RESTful API 接口说明
Go RESTful API 接口说明
Java RESTful API 接口说明
PHP RESTful API 接口说明
Python RESTful API 接口说明
RESTful API 各语言示例下载
实践教程
表结构设计
数据库交互
常见问题
信息咨询类
数据库使用类
数据库原理类
API 文档
History
Introduction
API Category
Making API Requests
Table Group APIs
Other APIs
Table APIs
Cluster APIs
Data Types
Error Codes
相关协议
服务等级协议
服务条款
词汇表
联系我们

使用 client 工具访问数据

PDF
聚焦模式
字号
最后更新时间: 2024-12-04 09:56:32
本文介绍如何通过客户端工具 tcaplus_client 访问数据。
所有数据操作语句必须带 where 条件,where 条件中必须包含主键字段,如果包含多个主键,则使用 and 将多个主键字段连接起来。

通过 client 工具访问 TcaplusDB 数据

tcaplus_client 是一个 TcaplusDB 表访问的客户端工具,可通过下表中的下载链接进行下载。
Linux x86_64 平台的 TcaplusServiceAPI 发布包包含64位 Linux 版本的 tcaplus_client 工具:
版本
操作系统
Client 下载
3.46.0.200178
Linux x86_64
3.55.0.208149
Linux x86_64
说明:
相关操作需要在用户腾讯云账号下申请的同 VPC 网络、同子网的云服务器 CVM 中进行。
旧版本 3.36.0.192960,可通过 该地址 下载。

安装客户端

下载完成 TcaplusServiceApi 安装包后,将其 通过上传工具 上传至与 TcaplusDB 集群同一 VPC,同一子网的云服务器中。
1. 上传完成后,执行下列命令解压安装包。
tar -xf TcaplusPbApi3.46.0.199033.x86_64_release_20201210.tar.gz -C tcaplus
2. 解压完成后,进入至 tcaplus 的 bin 目录中,并赋予可执行权限:
cd tcaplus/release/x86_64/bin
chmod +x tcaplus_client
3. 直接执行./tcaplus_client命令,会提示连接数据库所需的参数信息,用户可以根据自己的集群信息进行填写。
注意:
下文示例中,app_id 代表集群接入 ID、App 代表集群、zone 代表表格组。
## ./tcaplus_client
--------------------------------------------------------------------------------
invalid parameters, please start the client as following:

./tcaplus_client -a app_id -z zone_id -s signature -d dir_server_url [-t table_name] [-l log_file.xml] [-T tdr_file.tdr] [-e execute_command]

the params in [] are optional, and their order is not important.

-a(--ap_id) APP ID

-z(--zone_id) ZONE ID

-s(--signature) PASSWORD

-d(--dir) dir server addr

-t(--table) table to add

-l(--log) log file name that must be client_log.xml, and log class name be client

-T(--tdr) tdr filename

-e(--execute) SQL command need to execute, the content should be in quotes.

e.g. ./tcaplus_client -a 2 -z 3 -s "FE6533875C8385C3" -d 172.25.40.181:9999 -T table_test.tdr -e "select a, b from table where key = 1;"
--------------------------------------------------------------------------------

连接 TcaplusDB(默认场景)

使用命令连接 TcaplusDB,如下示例中,访问点信息如下,并且在表格组 ID 为1的表格组中创建了表 tb_online。
集群接入 ID:2
连接密码:test@Password1
内网地址:内网端口:10.125.32.21:9999
表格组 ID:1
./tcaplus_client -a 2 -z 1 -s "test@Password1" -d 10.125.32.21:9999
+------------------------------------------------------------------------------+
| tcaplus_client x86_64 build at Wed Jan 18 22:08:38 CST 2017 |
| |
| Welcome! |
+------------------------------------------------------------------------------+

tcaplus>
在提示符之后输入 help,可看到进一步的帮助信息,通过 > help 具体命令 可以查看具体使用方法。
tcaplus>help
--------------------------------------------------------------------------------
help: show usage of commands, example: "help select;".
show: get server status related information. executing "help show;" for details.
exit/quit: exit the client.
count: print record number in the database.

desc: print table field name and type.
select: query records from database.
insert: insert a new record into database.
replace: replace a record into the database.
update: update a record in the database.
delete: delete record(s) from database.

dump: dump records from database.
load: load records into the database.
--------------------------------------------------------------------------------

参数说明

参数
说明
是否必填
-a
接入 ID
-z
表格组 ID
-s
集群密码
-d
集群 IP 地址及端口
-t
表格名
-l
日志文件输出设置,文件名必须是 client_log.xml
-T
tdr 文件路径
-e
需要执行的 SQL 语句
-v
版本查询
<
重定向 SQL 语句到 client 执行

连接 TcaplusDB(使用 TDR)

如果需要使用 using tdr,必须在 client 启动参数中添加 TDR 文件路径,可通过 TDR 工具 把多个 XML 格式的元数据描述库转换成二进制格式。如果多个 XML 文件之间存在依赖关系,则被依赖的 XML 文件必须放在参数表前面。
使用示例:
[root@test-PC0 /opt]# ./tcaplus_client -a 2 -z 3 -s C12901752D0D3347 -d 8.x.x.8:9999 -T /mnt/e/tdr/2.3.table_list.tdr

====== Welcome to use tcaplus_client, use "help" to show usage ======
tcaplus > exit

[root@test-PC0 /opt]# ./tcaplus_client -a 2 -z 3 -s C12901752D0D3347 -d 8.x.x.8:9999 -T /mnt/e/tdr/2.3.table_list.tdr -e "show tables;"
-------------------------------------------
| Table Name Type |
-------------------------------------------
| MTownRoleInfo GENERIC |
| table_generic GENERIC |
| table_generic_xiahuaxian GENERIC |
| table_list LIST |
| test_table GENERIC |
-------------------------------------------

TDR 工具

TDR 文件需要使用 TDR 工具生成,其主要是由数据定义文件(TDR 结构 xml 格式)生成,SDK 包中 tbase 包的 tools 目录下有此工具。
使用示例:
tdr -B -o ov_res.tdr ov_res.xml
#xml 格式元数据库生成 .tdr 二进制库
tdr -C -o ov_res.c --old_xml_tagset ov_res.xml
#使用老标签集的 xml 格式元数据库生成 .c 文件
tdr -H -O "include" --add_custom_prefix="m_" --no_type_prefix
#xml 元数据库生成 .h 文件,生成的文件保存在 include 目录
#结构体(struct)/联合体(union)成员名添加前缀"m_",但不添加类型前缀
tdr -G -m Pkg -x ATTR -o Pkg.xml net_protocol.xml
#为 Pkg 生成 xml 格式的配置文件, 剪切版本为 Pkg 的最大版本, 文件名为 Pkg.xml
tdr -T -u prefixfile
#导出生成 .h 文件时使用的数据成员前缀表到文件 prefixfile 中
tdr -A --indent-size=8 net_protocol.xml
#根据 net_protocol.xml 中描述的协议生成 ActionScript3 语言的类文件,缩进大小为8个空格
tdr -P --indent-size=8 net_protocol.xml
#根据 net_protocol.xml 中描述的协议生成 C++ 语言的类文件,缩进大小为8个空格
tdr -S --indent-size=8 net_protocol.xml
#根据 net_protocol.xml 中描述的协议生成 C# 语言的类文件,缩进大小为8个空格
tdr -E 0x83010404
#查询错误号0x83010404对应的错误信息

tdr2xml 工具

tdr2xml 工具可以把二进制元数据文件反编译成一个 xml 格式的元数据描述文件,SDK 包中 tbase 包的 tools 目录下有此工具。
用法:
tdr2xml [-o --out_file=FILE] [-h --help] [-v --version] DRFILE
各选项的含义如下:
-o, --out_file=FILE 指定输出文件的名字,缺省为 a.xml
-h, --help 输出使用帮助
-v, --version 输出版本信息
使用示例:
tdr2xml –o net_cs.xml net_cs.tdr
将保存在 net_cs.tdr 文件中的元数据描述二进制自定义格式转换成 xml 格式的描述文件。

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈