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

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, autoconf, automake, libtool

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 autoconf automake libtool

Required library: rapidjson

This is the only required additional library. Download library to /opt/rapidjson. The library does not require compilation.

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

Optional libraries: librdfkafka

If you want to be able to send transactions directly to Kafka you need librdkafka library. Download library and compile to /opt/librdkafka :

#> mkdir /opt/librdkafka-src
#> cd /opt/librdkafka-src
#> git clone https://github.com/edenhill/librdkafka
#> cd librdkafka
#> ./configure --prefix=/opt/librdkafka
#> make
#> make install

Optional library: Oracle client

If you want to be able to run online, asm or standby mode you need to be able to connect to the Oracle instance. You need an Oracle client downloaded from Oracle. You need 2 files:

  • instantclient-basic-linux.x64-19.8.0.0.0dbru.zip
  • instantclient-sdk-linux.x64-19.8.0.0.0dbru.zip

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

#> cd /opt
#> unzip /tmp/instantclient-basic-linux.x64-19.8.0.0.0dbru.zip
#> unzip /tmp/instantclient-sdk-linux.x64-19.8.0.0.0dbru.zip
#> cd /opt/instantclient_19_8
#> ln -s libocci.so.11.1 libocci.so

Download and compile OpenLogReplicator

Download program to /opt/OpenLogReplicator:

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

Provide paths to libraries and run code compilation:

#> autoreconf -f -i
#> ./configure CXXFLAGS='-O3' --with-rapidjson=/opt/rapidjson --with-rdkafka=/opt/librdkafka --with-instantclient=/opt/instantclient_19_8
#> make

Check if the program is running correctly:

#> export LANG=en_US.UTF-8
#> export LD_LIBRARY_PATH=/opt/instantclient_19_8:/opt/librdkafka/lib
./OpenLogReplicator

You should see a result like:

OpenLogReplicator v.0.7.9 (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: libclntshcore.so.19.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 =>  (0x00007fff75ddd000)
	libasan.so.0 => /lib64/libasan.so.0 (0x00007f45c27df000)
	libclntshcore.so.19.1 => not found
	libnnz19.so => not found
	libclntsh.so.19.1 => not found
	librdkafka++.so.1 => not found
	librdkafka.so.1 => not found
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f45c25c3000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f45c22bc000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f45c1fba000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f45c1da4000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f45c19d6000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f45c17d2000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f45c576f000)

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.