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
make make check make install
protoccommand 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|
exampleand accessing TcaplusDB
You can develop the corresponding data access logic on the GameSvr game server by referring to API samples in
tar -xzvf TcaplusPbApi184.108.40.206096.x86_64_release_20170712.tar.gz
vi common.hto modify the
common.hheader file. Modify the content in the figure below based on your actual business needs:
3. Modify the environment configuration file.
TcaplusPbApi220.127.116.11096.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:
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
makecommand to compile the binary program of
example. After the compilation succeeded, a
mytestexecutable file will be generated.
./mytestto 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.loglog file in the code directory.