当前位置:网站首页>【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级存储、毫秒级时延、无损水平扩展和复杂数据结构等特性。同时具备丰富的生态、便捷的迁移、极低的运维成本和五个九高可用等特点。客户覆盖游戏、互联网、政务、金融、制造和物联网等领域。
边栏推荐
- Deeply analyzing the business logic of "chain 2+1" mode
- FPGA (VIII) RTL code IV (basic circuit design 1)
- 目前市面上增额终身寿险利率最高的产品是哪个?
- FortiGate firewall configuration log uploading regularly
- 图论的基本概念
- SSH login without password
- 设备监理师证书含金量怎样?值得考吗?
- Input input box click with border
- Tupu software intelligent energy integrated management and control platform
- Movement state change of monitoring device of Jerry's watch [chapter]
猜你喜欢
![Sequence traversal of binary tree ii[one of sequence traversal methods - > recursive traversal + level]](/img/f9/efb73dd6047e6d5833581376904788.png)
Sequence traversal of binary tree ii[one of sequence traversal methods - > recursive traversal + level]

Yyds dry inventory everything a primary developer should know about activity

The four traversal methods of the map set can be seen at a glance

Allegro's method of setting network flying line and network color

Basic MySQL database operations
![[North Asia data recovery] data recovery case of ibm-ds3512 storage server RAID5 damaged data loss](/img/84/c8604f539db4658049406080d7f09a.jpg)
[North Asia data recovery] data recovery case of ibm-ds3512 storage server RAID5 damaged data loss

FortiGate firewall configuration log uploading regularly

Problème - Ajouter shellerror: permissions d'instrumentation pour le périphérique: vérifier les règles udev.

87.(cesium篇)cesium热力图(贴地形)

2022-2028 global bubble CPAP system industry survey and trend analysis report
随机推荐
广发证券开户是真的安全可靠吗
2022-2028 global UAV detection radar industry research and trend analysis report
2022-2028 global CAE engineering service industry research and trend analysis report
The four traversal methods of the map set can be seen at a glance
Grafana Getting Started tutorial
The method of displaying or closing the network flying line in Allegro design
go实现分布式锁
FPGA(八)RTL代码之四(基本电路设计1)
Certification training | streamnational certification training phase 2
Different binary search trees [bottom-up backtracking spanning tree + memory search -- space for time]
Is it safe for qiniu school to open an account in 2022?
Allegro's method of canceling the routing of a good line
如何理解MySQL的索引?
Counter analysis of the parameter anti content in the backstage of the # yyds dry goods inventory # knife fight shop
Gartner's "voice of customers" has the highest score, and the user experience has become a major breakthrough for China's database
Quick sort, query the k-largest number of the sequence
Vscode plug-in used now
[flutter topic] 66 diagram basic constraints box (I) yyds dry goods inventory
VIM configuration and use
Jerry's watch stops moving [chapter]