当前位置:网站首页>[tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (II)
[tcaplusdb knowledge base] Introduction to tcaplusdb tcapulogmgr tool (II)
2022-06-29 03:32:00 【Database master】
4. updatefields
updatefields The command is used to return files and dynamically change the table structure , The command format is ./tcapulogmgr updatefields --directory= --engine-directory= --tbusid= --conf= [--speed= --seqcontinuous], among , The meanings of the first four required parameters are :
--directory ulog File directory
--engine-directory Cold standby file directory
--tbusid Indicates that you want to perform a fileback operation and dynamically change the table structure svr_id, Used to filter the corresponding... From the directory binlog file
--conf updatefields The configuration file for the command , It specifies DirServerAddr、PassWord、 Tables to retrieve and import data and tables to convert records so file
updatefields Command configuration file template and description
<?xml version="1.0" encoding="GBK" standalone="yes" ?> <tcapulogmgr> <!-- Dynamically change the configuration of the table structure --> <UpdateFieldsCfg UpdateFieldsCfgNum="1"> <!--SourceAppID、SourceZoneID、SourceTableName Used to specify the business of the data table to be archived ID、 District Service ID And table name --> <!--DestAppID、DestZoneID、DestTableName Used to specify the business to save the converted records ID、 District Service ID And table name --> <!--LibFile Used to specify user generated to convert the record structure so file --> <UpdateFieldsCfgItem SourceAppID="2" SourceZoneID="3" SourceTableName="TestData" DestAppID="2" DestZoneID="3" DestTableName="TestData_new" LibFile="do_nothing.so"/> <!--PassWord Is used to specify the DestTableName Password of the business --> <ServiceApiCfg PassWord="**********" ConnectTimeOut="10000" RegistTableTimeOut="10000" DirServerNum="1" > <!--DirServerAddr Is used to specify the DestTableName Directory server address of the business --> <DirServerAddr>tcp://*.*.*.*:9999</DirServerAddr> </ServiceApiCfg> </UpdateFieldsCfg> </tcapulogmgr>
The parameters in square brackets are optional :
--speed Speed control parameters
--seqcontinuous Express binlog The serial number of must be continuous , If it is not continuous, an error will be reported
Suppose the code file used to convert the record structure is do_nothing.cpp, have access to g++ -shared -fPIC -o do_nothing.so do_nothing.cpp Generate the corresponding dynamic link library file . stay do_nothing.cpp In file , It needs to be realized according to specific requirements TransferRecord function .
TransferRecord Example of function
#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;
}Generate... According to the above function example so file , And in tcapulogmgr_cfg.xml After configuring relevant parameters in , perform ./tcapulogmgr updatefields --directory=/txh/ulog/1.2.2.1 --engine-directory=/txh --tbusid=1.2.2.1 --conf=tcapulogmgr_cfg.xml --seqcontinuous. hypothesis /txh In the configuration file SourceTableName Field of the engine file of the data table specified checkpoint by 50,/txh/ulog/1.2.2.1 The largest in the directory sequence by 60, Then the command will redo sequence stay 51 To 60 Between binlog, Yes SourceTableName Field to perform a file retrieval operation on the data table specified by the ; meanwhile , Will use so File right here 10 strip binlog Transform the corresponding record structure , Put it redo To DestTableName In the data table specified by the field .
For more information, please pay attention to TcaplusDB WeChat official account , In the wind and rain , We've been waiting for you !

TcaplusDB It's a distributed product of Tencent NoSQL database , The code for storage and scheduling is completely self-developed . With cache + Landing fusion architecture 、PB Levels of storage 、 Millisecond delay 、 Lossless horizontal expansion and complex data structure . At the same time, it has rich ecological environment 、 Easy migration 、 Extremely low operation and maintenance costs and five nine high availability features . Customer coverage game 、 Internet 、 government affairs 、 Finance 、 Manufacturing and the Internet of things .
边栏推荐
猜你喜欢
![相同的树[从部分到整体]](/img/2d/997b9cb9cd4f8ea8620f5a66fcf00a.png)
相同的树[从部分到整体]

Web APIs 高阶函数 丨黑马程序员

【TcaplusDB知识库】查看tcapdir目录服务器

2022-2028 global pneumatic test probe industry survey and trend analysis report

2022-2028 global bubble CPAP system industry survey and trend analysis report

2022-2028 global CAE engineering service industry research and trend analysis report

FPGA (VIII) RTL code IV (basic circuit design 1)

go实现分布式锁

In depth analysis of Apache bookkeeper series: Part 3 - reading principle
[email protected]"/>无法定位程序输入点 [email protected]
随机推荐
Problème - Ajouter shellerror: permissions d'instrumentation pour le périphérique: vérifier les règles udev.
19.03 vessel description and simple application examples continued
Différents arbres de recherche binaires [arbre de génération rétrospectif ascendant + recherche de mémoire - - espace - temps]
Basic concepts of graph theory
Input input box click with border
Setting alarm mode of Jerry's watch [chapter]
MATALB signal processing - signal transformation (6)
【TcaplusDB知识库】TcaplusDB技术支持介绍
Jerry's watch stops moving [chapter]
相同的树[从部分到整体]
Gcc compiler package
Provide ideas in old texts
Zigzag sequence traversal of binary tree [one of layered traversal methods - > preorder traversal +level]
Solve the problem that the cursor flashes after clicking a point when measuring the distance in Allegro
Unable to locate program input point [email protected]
Laravel, execute PHP artist migrate and report an error alter table `users`add unique `users_ email_ unique`(`email`))
87.(cesium篇)cesium热力图(贴地形)
Laravel v. about laravel using the pagoda panel to connect to the cloud database (MySQL)
Stm32l4 Series MCU ADC accurately calculates input voltage through internal reference voltage
Wechat applet development Basics