You can deploy oblogproxy by using the installation package or using the source code. This topic describes how to build oblogproxy by using the source code.
Prerequisites
You have installed CMake 3.20 or later. To download CMake, visit the CMake website.
Compile oblogproxy
Install dependencies
Install dependencies based on the operating system:
Fedora-based operating systems, including CentOS, Fedora, OpenAnolis, Red Hat, and UOS
yum install git wget rpm rpm-build cpio gcc gcc-c++ make glibc-devel glibc-headers libstdc++-static binutilsDebian-based operating systems, including Debian and Ubuntu
apt-get install git wget rpm rpm2cpio cpio gcc make build-essential binutils
Compilation steps
mkdir buildenv && cd buildenv
# Generate
cmake ..
# Execute
make -j 6
Note
After you perform the preceding steps, logproxy binary files are generated in the current directory.
Compilation options
When you run CMake compilation, you can add compilation options to change the default compilation behavior. For example, by default, when the demo is generated after compilation, the demo_client binaries will also be generated in the current directory.
mkdir buildenv && cd buildenv
cmake -DWITH_DEMO=ON ..
make -j 6
Define libobcdc.so
Obtain libobcdc.so
You can download the precompiled obcdc package or build obcdc on your own.
Download the precompiled package
You can download the precompiled package from the Release page. The obcdc package is named in the
oceanbase-ce-cdc-${package_version}format. Download a package for your system and decompress it.rpm2cpio oceanbase-ce-cdc-${package_version} | cpio -idvIn the directory to which the RPM package is decompressed, the
home/admin/oceanbasedirectory exists and contains the following components that are essential for the running of obcdc:- Library files:
libobcdc.soin thelib64/directory. - Header files:
libobcdc.handob_errno.hin theinclude/libobcdc/directory.
- Library files:
Compile obcdc
For more information about operations, see obcdc compilation instructions.
git clone https://github.com/oceanbase/oceanbase.git && cd oceanbase ./build.sh release -DOB_BUILD_CDC=ON --init --makeThe compilation output includes:
libobcdc.so: in the${PROJECT_BUILD_DIR}/src/logservice/libobcdc/src/directory.obcdc_tailf: in the$${PROJECT_BUILD_DIR}/src/logservice/libobcdc/tests/directory.
Compile oblogproxy
If you choose to customize libobcdc.so, enable obcdc customization and specify the path in the compilation command when you compile oblogproxy. The following example assumes that you have put the
libobcdc.soandlibobcdc.hfiles in the/path/to/obcdcdirectory.mkdir buildenv && cd buildenv # Set the CMake environment variables so that CMake can find the precompiled obcdc. CMAKE_INCLUDE_PATH=/path/to/obcdc CMAKE_LIBRARY_PATH=/path/to/obcdc cmake -DUSE_LIBOBLOG=ON .. # Execute make -j 6
All compilation parameters
| Parameter | Default value | Description |
|---|---|---|
| WITH_DEBUG | ON | Specifies to use the Debug symbol in debug mode. |
| WITH_ASAN | OFF | Specifies to use AddressSanitizer in the compilation. |
| WITH_TEST | OFF | Specifies whether to write a binary test file. |
| WITH_DEMO | OFF | Specifies whether to write a demo client. |
| WITH_GLOG | ON | Specifies to use glog. |
| WITH_DEPS | ON | Specifies to automatically download precompiled dependencies. |
| USE_LIBOBLOG | OFF | Specifies to use the custom compiled obcdc. |
| USE_CXX11_ABI | ON | Specifies whether to use C++11 ABI. Notice If you use precompiled dependencies (obcdc), the value of this parameter must be consistent with the one that you specified for obcdc. Otherwise, symbols cannot be found. |
Notes on dependency compilation
By default, CMake automatically downloads and compiles dependency libraries. However, pay attention to the following components:
OpenSSL: The currently used version is 1.0.1e.
Notice
In OpenSSL 1.0.* or 1.1.*, some APIs are incompatible. At present, obcdc and logproxy are both implemented based on 1.0.*. Therefore, you must ensure that the version of your OpenSSL is 1.0.*.
obcdc: As described earlier, you can download a precompiled obcdc or compile it on your own, and then set the environment variables to specify the path of obcdc. LD_LIBRARY_PATH must be specified for running obcdc.
libaio: obcdc dependency.
Install oblogproxy
Configure the sys tenant
The oblogproxy configuration file conf.json can be found in the code directory.
For security, you must specify the username and password of a user for oblogproxy. Only a user in the sys tenant of OceanBase Database can be connected.
Notice
The username of this user cannot contain the cluster name or tenant name.
After you obtain the account and password of the sys tenant of your OBServer node, you must encrypt them and configure them for oblogproxy. Run the following commands to obtain the encrypted strings of the account and password:
# Assume that the account and password are user and pswd.
./logproxy -x user
# After you run the command, you will get the following string: 4B9C75F64934174F4E77EE0E9A58****
./logproxy -x pswd
# After you run the command, you will get the following string: DCE2AF09D006D6A440816880B938****
Copy the encrypted account and password strings to the ob_sys_username and ob_sys_password fields of the conf.json file in the /usr/local/oblogproxy/conf/ directory. Here is an example:
{
"ob_sys_username": "4B9C75F64934174F4E77EE0E9A58****",
"ob_sys_password": "DCE2AF09D006D6A440816880B938****"
}
Organize the program directory
# Create a program directory.
mkdir -p ./oblogproxy/bin ./oblogproxy/run
# Copy the configuration file.
cp -r ../conf ./oblogproxy/
# Copy the start and stop script.
cp ../script/run.sh ./oblogproxy/
# Copy the program binaries.
cp logproxy ./oblogproxy/bin/
Run oblogproxy
You can run the following commands to start the service.
cd ./oblogproxy
# Specify the libobcdc.so directory for dynamic dependence of oblogproxy.
export LD_LIBRARY_PATH=/path/to/libobcdc
bash ./run.sh start
By default, the 2983 port is listened to. You can set the service_port field in the conf.json file to change the port. The service logs of oblogproxy are stored in the logs/ directory. The service logs of the LogReader thread are stored in the run/{client-id}/logs/ directory.
Note
You can then use oblogclient for OceanBase data subscription. For more information, see oblogclient documentation.
Link encryption
TLS communication between oblogclient and oblogproxy
In the conf.json file, make the following changes:
channel_type: "tls". Enable TLS for communication with oblogclient.tls_ca_cert_file: the path of the CA certificate file.tls_cert_file: the path of the server-side signature certificate.tls_key_file: the path of the server-side private key.tls_verify_peer: "true". Enable verification for oblogclient.Notice
- Configure oblogclient accordingly. For more information, see oblogclient link encryption.
- All the preceding paths must be absolute paths.
TLS communication between oblogproxy (obcdc) and an OBServer node
Note
oblogproxy runs obcdc to interact with an OBServer node.
In the conf.json file, make the following changes:
liboblog_tls: specifies whether to enable TLS communication with OBServer nodes. Default value: true.liboblog_tls_cert_path: the absolute path of the related certificate files of the OBServer node. You may copy thewalletfolder in the deployment file directory of the OBServer node. Ensure that the directory contains the following files:ca.pem,client-cert.pem, andclient-key.pem.