The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Installation Guide for Linux

Last updated: 2024-10-15 17:44:22

Overview

This document guides you on installing and using TcaplusDB PB tables in a Linux system environment.

Running Environment

Linux 2.6, SUSE 12 64-bit.

Prerequisites

Before installing and using TcaplusDB PB, install Protobuf. TcaplusDB currently supports Protocol Buffers versions 2.6.1 and 3.5.0. Protobuf is a hybrid language data standard launched by Google and a lightweight structured data storage format. The TcaplusDB system supports using Protobuf format Definition files (.proto) to define data tables. Before using the TcaplusDB PB API, Protobuf must be installed on the development server. It is recommended to use the source code to install Protobuf. The installation method is as follows:
1. Prepare the CVM environment. First, prepare a server with the CentOS6-x86_64 or CentOS7-x86_64 operating system installed. To compile and build Protobuf, the following software needs to be installed. Please refer to relevant resources for the installation methods:
autoconf
automake
libtool
curl (used to download gmock)
make
g++
unzip
2. Download the Protobuf source code installation package. Please see SDK Download.
3. Install the specified version of ProtoBuf according to your actual needs. The following uses protobuf version 2.6.1 as an example.
4. Run the following commands to decompress the source code installation package and enter the source code root directory.
tar -xzvf protobuf-2.6.1.tar.gz
cd ./protobuf-2.6.1
5. Configure and specify the installation path prefix. It is recommended to install it to the path /usr/local/protobuf.
./configure --prefix=/usr/local/protobuf
6. Compile and install.
make
make check
make install
7. Test using the protoc command to verify if the installation is successful. It should display as follows to indicate a successful installation.
# protoc --version
libprotoc 2.6.1

Directions

Step 1: Install the TcaplusDB SDK

First, download the TcaplusDB SDK to the development server, then execute the commands to install the files to the specified installation directory.
tar –xzf <Installation Package Path> -C <Installation Directory>

Step 2: Verify

After installation, the root directory structure is as follows:
Directory and Files
Description
include/tcaplus_service/
TCAPLUS Service-oriented API Header Files
lib/libtcaplusserviceapi.a
TCAPLUS Service-oriented API Library Files
include/tcaplus_service/protobuf/
Protobuf API Header Files
lib/libtcaplusprotobufapi.a
TCAPLUS Protobuf API Library Files
examples/tcaplus/ProtoBuf
TCAPLUS Protobuf API Application Example

Step 3: Run example to access TcaplusDB

For developing data access logic in the GameSvr game server, refer to the API examples in the example directory.
1. Unzip the TcaplusDB PB API release package.
tar -xzvf TcaplusPbApi3.36.0.152096.x86_64_release_20170712.tar.gz
2. Configure TcaplusDB System Connection Information.
2.1 Enter the following code in the command line to navigate to the directory:
cd TcaplusPbApi3.36.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus/C++_common_for_pb2
2.2 Enter the command vi common.h in the command line to edit the common.h header file. Modify the content according to the business scenario as shown in the image. DIR_URL_ARRAY: Cluster access IP address and port number. DIR_URL_COUNT: Fixed value, keep it as 1. TABLE_NAME: Target table to access. APP_ID: Access ID. ZONE_ID: Table group ID to access. SIGNATURE: Cluster access password.

3. Modify the environment configuration file. In the TcaplusPbApi3.36.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus directory, there are examples of invoking API in asynchronous mode and coroutine mode. Here, we'll use coroutine mode to call the Set interface to configure data: Enter the following code in the command line to navigate to the directory:
cd TcaplusPbApi3.18.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus/C++_pb2_coroutine_simpletable/SingleOperation/set
All the codes for the coroutine mode Set example are in this directory. Edit the envcfg.env file, set the PROTOBUF_HOME environment variable to the installation path of protobuf on your local machine (--prefix specified), 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 in the image:

4. Set environment variables and execute the following command in the code directory:
source envcfg.env
bash conv.sh
5. Compile binary program. Execute the make command to compile the example binary. A successful compile generates the mytest executable file.

6. Run binary program. Enter ./mytest on the command line to run the binary program. The execution result will be displayed in the command line standard output. If an error occurs, please check the tcaplus_pb.log log file in the code directory.