当前位置:网站首页>【TcaplusDB知识库】TcaplusDB-tcapulogmgr工具介绍(二)
【TcaplusDB知识库】TcaplusDB-tcapulogmgr工具介绍(二)
2022-06-29 03:26:00 【数据库大师】
4. updatefields
updatefields命令用于回档与动态变更表结构,命令格式为 ./tcapulogmgr updatefields --directory= --engine-directory= --tbusid= --conf= [--speed= --seqcontinuous],其中,前四个必填参数的含义分别为:
--directory ulog文件目录
--engine-directory 冷备文件目录
--tbusid 表示要执行回档操作和动态变更表结构的svr_id,用于从目录中过滤出对应的binlog文件
--conf updatefields命令的配置文件,指定了DirServerAddr、PassWord、要回档数据和导入数据的表以及用于转换记录的so文件
updatefields命令的配置文件模板与说明
<?xml version="1.0" encoding="GBK" standalone="yes" ?> <tcapulogmgr> <!--动态变更表结构的配置--> <UpdateFieldsCfg UpdateFieldsCfgNum="1"> <!--SourceAppID、SourceZoneID、SourceTableName用于指定要回档的数据表的业务ID、区服ID和表名--> <!--DestAppID、DestZoneID、DestTableName用于指定保存转换后的记录的业务ID、区服ID和表名--> <!--LibFile用于指定用户生成的用来转换记录结构的so文件--> <UpdateFieldsCfgItem SourceAppID="2" SourceZoneID="3" SourceTableName="TestData" DestAppID="2" DestZoneID="3" DestTableName="TestData_new" LibFile="do_nothing.so"/> <!--PassWord用于指定DestTableName所在业务的密码--> <ServiceApiCfg PassWord="**********" ConnectTimeOut="10000" RegistTableTimeOut="10000" DirServerNum="1" > <!--DirServerAddr用于指定DestTableName所在业务的目录服务器地址--> <DirServerAddr>tcp://*.*.*.*:9999</DirServerAddr> </ServiceApiCfg> </UpdateFieldsCfg> </tcapulogmgr>
方括号中的参数为可选项:
--speed 速度控制参数
--seqcontinuous 表示binlog的序号必须连续,不连续则报错
假如用于转换记录结构的代码文件为do_nothing.cpp,可以使用 g++ -shared -fPIC -o do_nothing.so do_nothing.cpp 生成对应的动态链接库文件。在do_nothing.cpp文件中,需要根据具体需求实现TransferRecord函数。
TransferRecord函数示例
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <assert.h>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <tr1/functional>
#define TCAPLUS_MAX_TABLE_NAME_LEN_FOR_PLUGIN 128
enum EnumTransRecordStatus {
ENUM_TRANS_RECORD_SUC = 0,
ENUM_TRANS_RECORD_NOT_EXIST = 1,
ENUM_TRANS_RECORD_FAIL= -1,
};
typedef int int32_t;
typedef struct {
int32_t iAppID;
int32_t iZoneID;
char szTableName[TCAPLUS_MAX_TABLE_NAME_LEN_FOR_PLUGIN];
std::tr1::function<int(const char*)> pFuncForBillLog;
} TcapsvrImportCallBackPara;
typedef std::map<std::string, std::string> TcapFieldNameValueMap;
typedef std::vector<TcapFieldNameValueMap> VALUELIST;
typedef std::vector<EnumTransRecordStatus> STATUSLIST;
using namespace std;
extern "C" int TransferRecord(const VALUELIST& old_list,
VALUELIST& new_list, STATUSLIST& status_list,
TcapsvrImportCallBackPara* pCallBackPara)
{
if (NULL == pCallBackPara)
{
return -1;
}
VALUELIST::const_iterator it_list;
new_list.clear();
for (it_list = old_list.begin(); it_list != old_list.end(); ++it_list)
{
int ret = ENUM_TRANS_RECORD_SUC;
TcapFieldNameValueMap new_map;
const TcapFieldNameValueMap& old_map = *it_list;
TcapFieldNameValueMap::const_iterator it;
for (it = old_map.begin(); it != old_map.end(); ++it)
{
std::pair<TcapFieldNameValueMap::iterator, bool> result;
result = new_map.insert(std::make_pair(it->first, it->second));
if(!result.second)
{
status_list.push_back(ENUM_TRANS_RECORD_FAIL);
return -1;
}
}
// add new filed: platformid, use default value 0
// int32_t platformid = 0;
// std::string new_value((char*)&platformid, sizeof(platformid));
// std::string new_key = "platformid";
// std::pair<TcapFieldNameValueMap::iterator, bool> result = new_map.insert(std::make_pair(new_key, new_value));
// if(!result.second)
// {
// status_list.push_back(ENUM_TRANS_RECORD_FAIL);
// return -1;
// }
new_list.push_back(new_map);
status_list.push_back((EnumTransRecordStatus)ret);
}
return 0;
}按照上述函数示例生成so文件,并在tcapulogmgr_cfg.xml中配置相关参数后,执行 ./tcapulogmgr updatefields --directory=/txh/ulog/1.2.2.1 --engine-directory=/txh --tbusid=1.2.2.1 --conf=tcapulogmgr_cfg.xml --seqcontinuous。假设/txh目录下由配置文件中SourceTableName字段指定的数据表的引擎文件的checkpoint为50,/txh/ulog/1.2.2.1目录下最大的sequence为60,那么该命令会redo sequence在51到60之间的binlog,对SourceTableName字段指定的数据表进行回档操作;同时,会使用so文件对这10条binlog对应的记录结构进行转换,将其redo到DestTableName字段指定的数据表中。
更多信息请关注TcaplusDB微信公众号,风里雨里,我们一直在等你!

TcaplusDB是腾讯出品的分布式NoSQL数据库,存储和调度的代码完全自研。具备缓存+落地融合架构、PB级存储、毫秒级时延、无损水平扩展和复杂数据结构等特性。同时具备丰富的生态、便捷的迁移、极低的运维成本和五个九高可用等特点。客户覆盖游戏、互联网、政务、金融、制造和物联网等领域。
边栏推荐
- Merge sort
- MATALB signal processing - signal transformation (7)
- Basic concepts of graph theory
- Setting alarm mode of Jerry's watch [chapter]
- FPGA(七)RTL代码之三(复杂电路设计2)
- 2022-2028 global secondary butyl lithium industry research and trend analysis report
- What is the gold content of the equipment supervisor certificate? Is it worth it?
- ssm项目环境初步搭建
- Yyds dry inventory difference between bazel and gradle tools
- leetcode:304. 二维区域和检索 - 矩阵不可变
猜你喜欢

For safe login of wechat applet, the openid returned by wechat must be verified first to ensure the uniqueness of information.

Get error: Unsupported fork ordering: eip150block not enabled, but eip155block enabled at 0
![Restore the binary search tree [simulate according to the meaning of the question - > find the problem - > analyze the problem - > see the bidding]](/img/06/cc3c512e69455416fe81943bebacca.png)
Restore the binary search tree [simulate according to the meaning of the question - > find the problem - > analyze the problem - > see the bidding]
![[flutter topic] 66 diagram basic constraints box (I) yyds dry goods inventory](/img/8b/55a43383e1cb6b37231dba980c7b11.jpg)
[flutter topic] 66 diagram basic constraints box (I) yyds dry goods inventory

2D人体姿态估计 - DeepPose

19.03 vessel description and simple application examples continued

Linear and nonlinear structures

go-redsync分布式锁源码解析

Probe into metacosmic storage, the next explosive point in the data storage market?

Bluebridge cup 2022 preliminaries - minesweeping
随机推荐
PHP实现 mqtt通信
不同的二叉搜索树[自下而上回溯生成树+记忆搜索--空间换时间]
【线程通信】
Sequence traversal of binary tree ii[one of sequence traversal methods - > recursive traversal + level]
Unable to locate program input point [email protected]
Merge sort
2022-2028 global long wave infrared camera and camera core industry research and trend analysis report
map,set用pari作为key值,如何定义
Provide ideas in old texts
Restore the binary search tree [simulate according to the meaning of the question - > find the problem - > analyze the problem - > see the bidding]
迅为i.MX8M开发板yocto系统使用Gstarwmr视频转换
Etcd教程 — 第七章 Etcd之事务API
2022-2028 global industrial lithium chloride industry research and trend analysis report
Tkinter Huarong Road 4x4 Tutorial 4
Synchronous movement state of Jerry's watch [chapter]
go实现分布式锁
【云原生】这么火,你不来了解下?
Open source demo| you draw and I guess -- make your life more interesting
Tu ne peux pas comprendre le feu?
嵌入式开发如何进行源代码保密工作