This document describes how to install and use TcaplusDB Pb in the Linux environment.
Linux 2.6 and 32/64-bit Suse.
Protobuf needs to be installed before installing and using TcaplusDB Pb. If you have installed Protobuf, skip this section.
Protobuf, a mixed-language data standard developed by Google, provides a lightweight and structured data storage format. The TcaplusDB system supports defining data tables using the Protobuf definition file (.proto). Before using the TcaplusDB Pb APIs, you need to install Protobuf on the GameSvr server. It is recommended to use the source code for Protobuf installation. The installation method is as follows:
Prepare the GameSvr environment.
You need to prepare a GameSvr with the CentOS 6-x86_64 or the CentOS 7-x86_64 operating system. To compile and build Protobuf, you need to install the following software:
Download the Protobuf (syntax = "proto2") source code installer package.
Decompress the source code installer package and enter the root directory of the source code. You can perform the following command lines to do this.
tar -xzvf protobuf-2.6.1.tar.gz cd ./protobuf-2.6.1
Configure and specify the installation path prefix. It is recommended to install it in /usr/local/protobuf. You can perform the following command lines to do this.
Compile and install it. You can perform the following command lines to do this.
make make check make install
Test. Use the "protoc" command to check if the installation is successful. You can perform the following command lines to do this.
Once installed, you will see the following:
Click to Download SDK.
tar –xzf<installer package path> -C <installation directory>
After installation, the root directory structure is shown as follows:
|include/tcaplus_service/||Header files of Tcaplus service API|
|lib/libtcaplusserviceapi.a||Library files of Tcaplus service API|
|include/tcaplus_service/protobuf/||Header files of Protobuf API|
|lib/libtcaplusprotobufapi.a||Library files of Tcaplus Protobuf API|
|examples/tcaplus/ProtoBuf||Application examples of Tcaplus Protobuf API|
For the development of the corresponding data access logic in GameSvr, see APIs in example.
Decompress the TcaplusDB Pb API release package.
tar -xzvf TcaplusPbApi184.108.40.206096.x86_64_release_20170712.tar.gz
Configure TcaplusDB system connection information.
i. Enter the following code on the command line to enter the directory:
ii. Enter vi common.h on the command line to modify the common.h header file, and modify the following content based on your business.
DIR_URL_ARRAY: tcapdir address and port.
DIR_URL_COUNT: tcapdir count.
TABLE_NAME: Destination table to be accessed.
APP_ID: AppID to be accessed.
ZONE_ID: deployment unit ZoneID.
Modify the environment configuration file.
The TcaplusPbApi220.127.116.11096.x86_64_release_20170712/release/x86_64/examples/tcaplus directory shows examples of calling API calls asynchronously and by coroutines. The following shows how to call the Set API by coroutines:
Enter the following code on the command line to enter the directory:
All codes for the Set example by coroutines are displayed in this directory. Modify the envcfg.env file, set the PROTOBUF_HOME environment variable to the installation path of the native protobuf (the specified prefix), and set the TCAPLUS_HOME environment variable to the absolute path of the release/x86_64 directory under the Tcaplus Pb API package, as shown below:
Set environment variables.
Set in the code directory:
source envcfg.env bash conv.sh
Compile a binary program.
make command to compile the example binary. After compiling, a mytest executable file is generated.
Run a binary program.
./mytest on the command line to run the binary program. The running result will be displayed in the standard output of the command line. If you encounter an error, check the tcaplus_pb.log file in the code directory.