gabikripka
gabikripka

Reputation: 43

Astro Airflow cannot locate Oracle Instant Client

I created an Airflow project using the Astro CLI. As I am connecting to a very old Oracle Database, I need to use thick mode to connect to Oracle. Therefore, my Dockerfile from the project is

USER root
RUN mkdir -p /opt/oracle && chown -R astro: /opt/oracle && chown -R astro: /etc
USER astro
COPY include/instantclient-basiclite-linux.x64-21.13.0.0.0dbru.zip /opt/oracle
RUN cd /opt/oracle && unzip ./instantclient-basiclite-linux.x64-21.13.0.0.0dbru.zip
RUN sh -c "echo /opt/oracle/instantclient_21_13 > /etc/ld.so.conf.d/oracle-instantclient.conf"
RUN ldconfig

Of couse, I downloaded the ZIP from the oracle webside, and loaded it to my local folder include. Furthermore, I added the above-used packages to the packages.txt file, and added the oracledb python package in the requirements.txt.

However, when I run a sample file main.py

import oracledb
oracledb.init_oracle_client()

trying to initiate the Oracle client, I get as if the required file is not found.

$ python /usr/local/airfow/dags/main.py
python: can't open file '/usr/local/airfow/dags/main.py': [Errno 2] No such file or directory
$ python /usr/local/airflow/dags/main.py   
Traceback (most recent call last):
  File "/usr/local/airflow/dags/main.py", line 3, in <module>
    oracledb.init_oracle_client()
  File "src/oracledb/impl/thick/utils.pyx", line 467, in oracledb.thick_impl.init_oracle_client
  File "src/oracledb/impl/thick/utils.pyx", line 491, in oracledb.thick_impl.init_oracle_client
  File "src/oracledb/impl/thick/utils.pyx", line 418, in oracledb.thick_impl._raise_from_info
oracledb.exceptions.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://python-oracledb.readthedocs.io/en/latest/user_guide/initialization.html for help
Help: https://python-oracledb.readthedocs.io/en/latest/user_guide/troubleshooting.html#dpi-1047

But when I access the container and go to /opt/oracle/instantclient_21_13 the files are all there:

$ ls /opt/oracle/instantclient_21_13
BASIC_LITE_LICENSE  libclntsh.so.11.1  libclntshcore.so       libnnz21.so      libocci.so.19.1        libocijdbc21.so  uidrvci
BASIC_LITE_README   libclntsh.so.12.1  libclntshcore.so.12.1  libocci.so       libocci.so.20.1        liboramysql.so   xstreams.jar
adrci               libclntsh.so.18.1  libclntshcore.so.18.1  libocci.so.10.1  libocci.so.21.1        network
genezi              libclntsh.so.19.1  libclntshcore.so.19.1  libocci.so.11.1  libocci_gcc53.so       ojdbc11.jar
libclntsh.so        libclntsh.so.20.1  libclntshcore.so.20.1  libocci.so.12.1  libocci_gcc53.so.21.1  ojdbc8.jar
libclntsh.so.10.1   libclntsh.so.21.1  libclntshcore.so.21.1  libocci.so.18.1  libociicus.so          ucp.jar

Upvotes: 0

Views: 156

Answers (0)

Related Questions