Source code compilation

Docker image

The easiest way to compile source code is to use docker script from github:

git clone https://github.com/bersler/OpenLogReplicator-docker
bash build.sh

Oracle client libraries

To compile source you need an Oracle client downloaded from Oracle. You need 2 files:

  • instantclient-basic-linux.x64-11.2.0.4.0.zip
  • instantclient-sdk-linux.x64-11.2.0.4.0.zip

In this example the Oracle library is uncompressed to /opt/instantclient_11_2. Please mind that zip files do not contain symlinks and you need to create them yourself:

cd /opt/instantclient_11_2
ln -s libocci.so.11.1 libocci.so
ln -s libclntsh.so.11.1 libclntsh.so

You can also used Oracle database binaries. Either way you need to include in the LD_LIBRARY_PATH environment variable a path location where you have the following libraries:

  • libocci.so
  • libnnz11.so
  • libclntsh.so

If your database version is different – please make sure that you create symlinks pointing to Oracle library files.

Required packages

To compile the code on CentOS 7 system you need to have the following packages installed: make, gcc, gcc-c++, git, unzip, libasan, libaio-devel, libnsl, tar

Before starting the compilation update your system and make sure they are installed:

yum -y update
yum -y install make gcc gcc-c++ git unzip libasan libaio-devel libnsl

Required libraries: rapidjson

Download library to /opt/rapidjson. The library does not require compilation.

cd /opt
git clone https://github.com/Tencent/rapidjson/

Required libraries: librdfkafka

Download library to /opt/librdkafka and compile:

cd /opt
git clone https://github.com/edenhill/librdkafka
cd /opt/librdkafka
./configure
make
make install

Download and compile OpenLogReplicator

Download program to /opt/OpenLogReplicator:

cd /opt
git clone https://github.com/bersler/OpenLogReplicator

If your Oracle libraries are in different location than /opt/instantclient_11_2 – please update makefile and src/subdir.mk files with current Oracle libraries location.

Run code compilation:

cd /opt/OpenLogReplicator/Debug
make
cd /opt/OpenLogReplicator/Release
make

Check if the program is running correctly:

export LANG=en_US.UTF-8
export LD_LIBRARY_PATH=/opt/instantclient_11_2:/usr/local/lib
./OpenLogReplicator

You should see a result like:

OpenLogReplicator v.0.6.10 (C) 2018-2020 by Adam Leszczynski (aleszczynski@bersler.com), see LICENSE file for licensing information
ERROR: file OpenLogReplicator.json is missing

This means that the code is properly compiled, libraries are correctly mapped and ready to run,

Troubleshooting

If running OpenLogReplicator gives you a result like:

./OpenLogReplicator 
./OpenLogReplicator: error while loading shared libraries: libocci.so.11.1: cannot open shared object file: No such file or directory

This means that the libraries are not correctly linked. Please check which libraries are missing, example:

ldd OpenLogReplicator 
	linux-vdso.so.1 =>  (0x00007ffe719b8000)
	libasan.so.0 => /lib64/libasan.so.0 (0x00007f7d56c55000)
	libocci.so.11.1 => not found
	librdkafka++.so.1 => not found
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7d56a39000)
	libnnz11.so => not found
	libclntsh.so.11.1 => not found
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f7d56732000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f7d56430000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f7d5621a000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f7d55e4c000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f7d55c48000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f7d59be5000)

In the above example all libraries marked with “not found” are missing. Please check that the environment variable LD_LIBRARY_PATH includes paths where the required files are located. If necessary – create appropriate symlinks.