This document describes how to install and use a TcaplusDB PB table on Linux.
Linux 2.6 and SUSE 12 64-bit.
Before installing and using TcaplusDB PB, you need to install Protobuf. Currently, TcaplusDB supports Protobuf v2.6.1 and v3.5.0.
Protobuf is a cross-language lightweight structured data storage format launched by Google. TcaplusDB supports defining data tables with Protobuf definition files (.proto). Before using a TcaplusDB PB API, you need to install Protobuf on your development server first. You are recommended to use the source code to install Protobuf in the following steps:
tar -xzvf protobuf-2.6.1.tar.gz
cd ./protobuf-2.6.1
/usr/local/protobuf
../configure --prefix=/usr/local/protobuf
make
make check
make install
protoc
command to check whether the installation succeeded. If the following information is displayed, the installation is successful.# protoc --version
libprotoc 2.6.1
Download the TcaplusDB SDK onto the development server and run the following command to install the file to the specified installation directory:
tar –xzf <installation package path> -C <installation directory>,
After the installation, the root directory structure is as shown below:
Directory and File | Description |
---|---|
include/tcaplus_service/ | TcaplusDB service API header file |
lib/libtcaplusserviceapi.a | TcaplusDB service API library file |
include/tcaplus_service/protobuf/ | Protobuf API header file |
lib/libtcaplusprotobufapi.a | TcaplusDB Protobuf API library file |
examples/tcaplus/ProtoBuf | TcaplusDB Protobuf API sample |
example
and accessing TcaplusDBYou can develop the corresponding data access logic on the GameSvr game server by referring to API samples in example
.
tar -xzvf TcaplusPbApi3.36.0.152096.x86_64_release_20170712.tar.gz
cd TcaplusPbApi3.36.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus/C++_common_for_pb2
vi common.h
to modify the common.h
header file. Modify the content in the figure below based on your actual business needs:
3. Modify the environment configuration file.
In the TcaplusPbApi3.36.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus
directory, there are sample files of calling APIs asynchronously or by using a coroutine. This step uses calling the Set
API with a coroutine to set data as an example.
Enter the following code on the command line to enter the directory:
cd TcaplusPbApi3.18.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus/C++_pb2_coroutine_simpletable/SingleOperation/set
All code of the example of calling the Set
API with a coroutine is in the directory. Modify the envcfg.env
file, set the PROTOBUF_HOME
environment variable to the Protobuf installation path on this server (specified by --prefix
), and set the TCAPLUS_HOME
environment variable to the absolute path of the release/x86_64
directory in the TcaplusDB PB API package as shown below:
4. Run the following command under the code directory to set the environment variables:
source envcfg.env
bash conv.sh
make
command to compile the binary program of example
. After the compilation succeeded, a mytest
executable file will be generated../mytest
to run the binary program. The execution result will be displayed in the command line standard output. If any error occurs, please check the tcaplus_pb.log
log file in the code directory.
Was this page helpful?